Annotation of OpenXM_contrib2/asir2000/engine/vect.c, Revision 1.1
1.1 ! noro 1: /* $OpenXM: OpenXM/src/asir99/engine/vect.c,v 1.1.1.1 1999/11/10 08:12:26 noro Exp $ */
! 2: #include "ca.h"
! 3:
! 4: void addvect(vl,a,b,c)
! 5: VL vl;
! 6: VECT a,b,*c;
! 7: {
! 8: int len,i;
! 9: VECT t;
! 10: pointer *ab,*bb,*tb;
! 11:
! 12: if ( !a )
! 13: *c = b;
! 14: else if ( !b )
! 15: *c = a;
! 16: else if ( a->len != b->len ) {
! 17: *c = 0; error("addvect : size mismatch");
! 18: } else {
! 19: len = a->len;
! 20: MKVECT(t,len);
! 21: for ( i = 0, ab = BDY(a), bb = BDY(b), tb = BDY(t); i < len; i++ )
! 22: addr(vl,(Obj)ab[i],(Obj)bb[i],(Obj *)&tb[i]);
! 23: *c = t;
! 24: }
! 25: }
! 26:
! 27: void subvect(vl,a,b,c)
! 28: VL vl;
! 29: VECT a,b,*c;
! 30: {
! 31: int len,i;
! 32: VECT t;
! 33: pointer *ab,*bb,*tb;
! 34:
! 35: if ( !a )
! 36: chsgnvect(b,c);
! 37: else if ( !b )
! 38: *c = a;
! 39: else if (a->len != b->len ) {
! 40: *c = 0; error("subvect : size mismatch");
! 41: } else {
! 42: len = a->len;
! 43: MKVECT(t,len);
! 44: for ( i = 0, ab = BDY(a), bb = BDY(b), tb = BDY(t);
! 45: i < len; i++ )
! 46: subr(vl,(Obj)ab[i],(Obj)bb[i],(Obj *)&tb[i]);
! 47: *c = t;
! 48: }
! 49: }
! 50:
! 51: void mulvect(vl,a,b,c)
! 52: VL vl;
! 53: Obj a,b,*c;
! 54: {
! 55: if ( !a || !b )
! 56: *c = 0;
! 57: else if ( OID(a) <= O_R )
! 58: mulrvect(vl,a,(VECT)b,(VECT *)c);
! 59: else if ( OID(b) <= O_R )
! 60: mulrvect(vl,b,(VECT)a,(VECT *)c);
! 61: else
! 62: notdef(vl,a,b,c);
! 63: }
! 64:
! 65: void divvect(vl,a,b,c)
! 66: VL vl;
! 67: Obj a,b,*c;
! 68: {
! 69: Obj t;
! 70:
! 71: if ( !b )
! 72: error("divvect : division by 0");
! 73: else if ( !a )
! 74: *c = 0;
! 75: else if ( OID(b) > O_R )
! 76: notdef(vl,a,b,c);
! 77: else {
! 78: divr(vl,(Obj)ONE,b,&t); mulrvect(vl,(Obj)t,(VECT)a,(VECT *)c);
! 79: }
! 80: }
! 81:
! 82: void chsgnvect(a,b)
! 83: VECT a,*b;
! 84: {
! 85: VECT t;
! 86: int len,i;
! 87: pointer *ab,*tb;
! 88:
! 89: if ( !a )
! 90: *b = 0;
! 91: else {
! 92: len = a->len;
! 93: MKVECT(t,len);
! 94: for ( i = 0, ab = BDY(a), tb = BDY(t);
! 95: i < len; i++ )
! 96: chsgnr((Obj)ab[i],(Obj *)&tb[i]);
! 97: *b = t;
! 98: }
! 99: }
! 100:
! 101: void mulrvect(vl,a,b,c)
! 102: VL vl;
! 103: Obj a;
! 104: VECT b,*c;
! 105: {
! 106: int len,i;
! 107: VECT t;
! 108: pointer *bb,*tb;
! 109:
! 110: if ( !a || !b )
! 111: *c = 0;
! 112: else {
! 113: len = b->len;
! 114: MKVECT(t,len);
! 115: for ( i = 0, bb = BDY(b), tb = BDY(t); i < len; i++ )
! 116: mulr(vl,a,(Obj)bb[i],(Obj *)&tb[i]);
! 117: *c = t;
! 118: }
! 119: }
! 120:
! 121: int compvect(vl,a,b)
! 122: VL vl;
! 123: VECT a,b;
! 124: {
! 125: int i,len,t;
! 126:
! 127: if ( !a )
! 128: return b?-1:0;
! 129: else if ( !b )
! 130: return 1;
! 131: else if ( a->len != b->len )
! 132: return a->len>b->len ? 1 : -1;
! 133: else {
! 134: for ( i = 0, len = a->len; i < len; i++ )
! 135: if ( t = compr(vl,(Obj)BDY(a)[i],(Obj)BDY(b)[i]) )
! 136: return t;
! 137: return 0;
! 138: }
! 139: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>