=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/engine/mat.c,v retrieving revision 1.5 retrieving revision 1.8 diff -u -p -r1.5 -r1.8 --- OpenXM_contrib2/asir2000/engine/mat.c 2002/03/01 06:27:23 1.5 +++ OpenXM_contrib2/asir2000/engine/mat.c 2003/03/27 02:59:16 1.8 @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/engine/mat.c,v 1.4 2002/01/04 17:08:23 saito Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/engine/mat.c,v 1.7 2002/05/27 03:00:12 noro Exp $ */ #include "ca.h" #include "../parse/parse.h" @@ -106,9 +106,28 @@ void mulmat(vl,a,b,c) VL vl; Obj a,b,*c; { - if ( !a || !b ) + VECT vect; + MAT mat; + + if ( !a && !b ) *c = 0; - else if ( OID(a) <= O_R ) + else if ( !a || !b ) { + if ( !a ) + a = b; + switch ( OID(a) ) { + case O_VECT: + MKVECT(vect,((VECT)a)->len); + *c = (Obj)vect; + break; + case O_MAT: + MKMAT(mat,((MAT)a)->row,((MAT)a)->col); + *c = (Obj)mat; + break; + default: + *c = 0; + break; + } + } else if ( OID(a) <= O_R ) mulrmat(vl,(Obj)a,(MAT)b,(MAT *)c); else if ( OID(b) <= O_R ) mulrmat(vl,(Obj)b,(MAT)a,(MAT *)c); @@ -180,9 +199,22 @@ MAT a; Obj r; MAT *c; { + int n,i; + MAT t; + if ( !a ) *c = 0; - else if ( !r || !NUM(r) || !RATN(r) || + else if ( !r ) { + if ( a->row != a->col ) { + *c = 0; error("pwrmat : non square matrix"); + } else { + n = a->row; + MKMAT(t,n,n); + for ( i = 0; i < n; i++ ) + t->body[i][i] = ONE; + *c = t; + } + } else if ( !NUM(r) || !RATN(r) || !INT(r) || (SGN((Q)r)<0) || (PL(NM((Q)r))>1) ) { *c = 0; error("pwrmat : invalid exponent"); } else if ( a->row != a->col ) { @@ -455,6 +487,34 @@ MAT a,b,*c; /* C21 = w1+u1+A22*(B21-t2) */ submat(vl, b21, t2, &ans1); mulmatmat(vl, a22, ans1, &ans2); + addmat(vl, w1, u1, &ans1); + addmat(vl, ans1, ans2, &c21); + + /* C22 = w1 + u1 + v1 */ + addmat(vl, ans1, v1, &c22); + } + + for(i =0; irow; i++) { + for ( j=0; j < c11->col; j++) { + t->body[i][j] = c11->body[i][j]; + } + } + if (pflag1 == 0) { + k = c21->row; + } else { + k = c21->row - 1; + } + for(i =0; icol; j++) { + t->body[i+c11->row][j] = c21->body[i][j]; + } + } + if (pflag2 == 0) { + h = c12->col; + } else { + h = c12->col -1; + } + for(i =0; irow; i++) { for ( j=0; j < k; j++) { t->body[i][j+c11->col] = c12->body[i][j]; } @@ -495,6 +555,9 @@ VECT *c; else if ( a->col != b->len ) { *c = 0; error("mulmatvect : size mismatch"); } else { + for ( i = 0; i < b->len; i++ ) + if ( BDY(b)[i] && OID((Obj)BDY(b)[i]) > O_R ) + error("mulmatvect : invalid argument"); arow = a->row; m = a->col; MKVECT(t,arow); for ( i = 0; i < arow; i++ ) { @@ -522,6 +585,9 @@ VECT *c; else if ( a->len != b->row ) { *c = 0; error("mulvectmat : size mismatch"); } else { + for ( i = 0; i < a->len; i++ ) + if ( BDY(a)[i] && OID((Obj)BDY(a)[i]) > O_R ) + error("mulvectmat : invalid argument"); bcol = b->col; m = a->len; MKVECT(t,bcol); for ( j = 0; j < bcol; j++ ) {