[BACK]Return to mattran.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / builtin

Diff for /OpenXM_contrib2/asir2000/builtin/mattran.c between version 1.1 and 1.2

version 1.1, 2003/02/14 18:39:02 version 1.2, 2003/02/22 07:22:16
Line 1 
Line 1 
   /*
    * $OpenXM$
    */
   
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
   
 static void Rowm(NODE, Obj *);  static void MatFund(NODE, Obj *);
 static void Rowch(NODE, Obj *);  static void RowMul(NODE, Obj *);
 static void Rowmadd(NODE, Obj *);  static void RowExh(NODE, Obj *);
 //static void mlowch(NODE, Obj *, Obj *, Obj *);  static void RowMulAdd(NODE, Obj *);
 //static void mlowad(NODE, Obj *, Obj *, Obj *);  static void BodyRowMul(MAT, int, pointer);
   static void BodyRowExh(MAT, int, int);
   static void BodyRowMulAdd(MAT, int, int, pointer);
   static void ColMul(NODE, Obj *);
   static void ColExh(NODE, Obj *);
   static void ColMulAdd(NODE, Obj *);
   static void BodyColMul(MAT, int, pointer);
   static void BodyColExh(MAT, int, int);
   static void BodyColMulAdd(MAT, int, int, pointer);
   
 struct ftab mat_tab[] = {  struct ftab mat_tab[] = {
         {"rowm",Rowm,3},          {"mfund",MatFund,-5},
         {"rowch",Rowch,3},          {"rowm",RowMul,3},
         {"rowmadd",Rowmadd,4},          {"rowx",RowExh,3},
           {"rowa",RowMulAdd,4},
           {"colm",ColMul,3},
           {"colx",ColExh,3},
           {"cola",ColMulAdd,4},
         {0,0,0},          {0,0,0},
 };  };
   
 static void  static void
 Rowm(arg, rp)  MatFund(arg, rp)
 NODE arg;  NODE arg;
 Obj *rp;  Obj *rp;
 {  {
         MAT a;          MAT mat;
         Q s;          pointer *coe;
         int row, size, i;          Q rowq, row2q, colq, col2q;
         pointer *k, *t, *ap;          int sw, row, row2, col, col2;
           sw = QTOS( (Q)ARG0(arg) );
         a = (MAT)ARG0(arg);          mat = (MAT)ARG1(arg);
         size = a->col;          switch (sw) {
         s = (Q)ARG1(arg);                  case 1:
         row = QTOS(s);                          rowq = (Q)ARG2(arg);
         k = (pointer)ARG2(arg);                          row = QTOS( rowq );
         ap = BDY(a)[row];                          coe = (pointer)ARG3(arg);
         for ( i = 0; i < size; i++ ) {                          BodyRowMul( mat, row, coe );
                 mulr(CO,(Obj)ap[i],(Obj)k,(Obj *)&t);                          *rp = (Obj)mat;
                 ap[i]=(Obj)t;                          return;
                   case 2:
                           rowq = (Q)ARG2(arg);
                           row = QTOS( rowq );
                           row2q = (Q)ARG3(arg);
                           row2 = QTOS( row2q );
                           BodyRowExh( mat, row, row2 );
                           *rp = (Obj)mat;
                           return;
                   case 3:
                           rowq = (Q)ARG2(arg);
                           row = QTOS( rowq );
                           row2q = (Q)ARG3(arg);
                           row2 = QTOS( row2q );
                           coe = (pointer)ARG3(arg);
                           BodyRowMulAdd( mat, row, row2, coe );
                           *rp = (Obj)mat;
                           return;
                   case 4:
                           colq = (Q)ARG2(arg);
                           col = QTOS( colq );
                           coe = (pointer)ARG3(arg);
                           BodyColMul( mat, col, coe );
                           *rp = (Obj)mat;
                           return;
                   case 5:
                           colq = (Q)ARG2(arg);
                           col = QTOS( colq );
                           col2q = (Q)ARG3(arg);
                           col2 = QTOS( col2q );
                           BodyColExh( mat, col, col2 );
                           *rp = (Obj)mat;
                           return;
                   case 6:
                           colq = (Q)ARG2(arg);
                           col = QTOS( colq );
                           col2q = (Q)ARG3(arg);
                           col2 = QTOS( col2q );
                           coe = (pointer)ARG3(arg);
                           BodyColMulAdd( mat, col, col2, coe );
                           *rp = (Obj)mat;
                   default:
                           return;
                           *rp = 0;
         }          }
   }
   
         *rp = (Obj)a;  static void
   RowMul(arg, rp)
   NODE arg;
   Obj *rp;
   {
           MAT mat;
           Q rowq;
           pointer *coe;
           int row;
   
           mat = (MAT)ARG0(arg);
           rowq = (Q)ARG1(arg);
           row = QTOS( rowq );
           coe = (pointer)ARG2(arg);
           BodyRowMul( mat, row , coe );
           *rp = (Obj)mat;
 }  }
   
 static void  static void
 Rowch(arg, rp)  RowExh(arg, rp)
 NODE arg;  NODE arg;
 Obj *rp;  Obj *rp;
 {  {
         MAT a;          MAT mat;
         Q sa, sb;          Q QIndexA, QIndexB;
         int rowa, rowb, size, i;          int IndexA, IndexB;
         pointer *k, *t, *ap, *aq;  
   
         a = (MAT)ARG0(arg);          mat = (MAT)ARG0(arg);
         size = a->col;          QIndexA = (Q)ARG1(arg);
         sa = (Q)ARG1(arg);          QIndexB = (Q)ARG2(arg);
         rowa = QTOS(sa);          IndexA = QTOS( QIndexA );
         sb = (Q)ARG2(arg);          IndexB = QTOS( QIndexB );
         rowb = QTOS(sb);          BodyRowExh( mat, IndexA, IndexB );
         ap = BDY(a)[rowa];          *rp = (Obj)mat;
         aq = BDY(a)[rowb];  }
         for ( i = 0; i < size; i++ ) {  
                 t = ap[i];  
                 ap[i] = aq[i];  
                 aq[i] = t;  
         }  
   
         *rp = (Obj)a;  static void
   RowMulAdd(arg, rp)
   NODE arg;
   Obj *rp;
   {
           MAT mat;
           Q QIndexA, QIndexB;
           int IndexA, IndexB;
           pointer *coe;
   
           mat = (MAT)ARG0(arg);
           QIndexA = (Q)ARG1(arg);
           QIndexB = (Q)ARG2(arg);
           coe = (pointer)ARG3(arg);
           IndexA = QTOS( QIndexA );
           IndexB = QTOS( QIndexB );
           BodyRowMulAdd( mat, IndexA, IndexB, coe );
           *rp = (Obj)mat;
 }  }
   
 static void  static void
 Rowmadd(arg, rp)  ColMul(arg, rp)
 NODE arg;  NODE arg;
 Obj *rp;  Obj *rp;
 {  {
         MAT a;          MAT mat;
         Q sa, sb;          Q QIndex;
         int rowa, rowb, size, i;          pointer *coe;
         pointer *k, *t, *ap, *aq;          int Index;
   
         a = (MAT)ARG0(arg);          mat = (MAT)ARG0(arg);
         size = a->col;          QIndex = (Q)ARG1(arg);
         sa = (Q)ARG1(arg);          Index = QTOS( QIndex );
         rowa = QTOS(sa);          coe = (pointer)ARG2(arg);
         sb = (Q)ARG2(arg);          BodyColMul( mat, Index , coe );
         rowb = QTOS(sb);          *rp = (Obj)mat;
         ap = BDY(a)[rowa];  }
         aq = BDY(a)[rowb];  
         k = (pointer)ARG3(arg);  
   
   static void
   ColExh(arg, rp)
   NODE arg;
   Obj *rp;
   {
           MAT mat;
           Q QIndexA, QIndexB;
           int IndexA, IndexB;
   
           mat = (MAT)ARG0(arg);
           QIndexA = (Q)ARG1(arg);
           QIndexB = (Q)ARG2(arg);
           IndexA = QTOS( QIndexA );
           IndexB = QTOS( QIndexB );
           BodyColExh( mat, IndexA, IndexB );
           *rp = (Obj)mat;
   }
   
   static void
   ColMulAdd(arg, rp)
   NODE arg;
   Obj *rp;
   {
           MAT mat;
           Q QIndexA, QIndexB;
           int IndexA, IndexB;
           pointer *coe;
   
           mat = (MAT)ARG0(arg);
           QIndexA = (Q)ARG1(arg);
           QIndexB = (Q)ARG2(arg);
           coe = (pointer)ARG3(arg);
           IndexA = QTOS( QIndexA );
           IndexB = QTOS( QIndexB );
           BodyColMulAdd( mat, IndexA, IndexB, coe );
           *rp = (Obj)mat;
   }
   
   static void
   BodyRowMul( mat, row, coe )
   MAT mat;
   int row;
   pointer coe;
   {
           int size, i;
           pointer *t, *matrow;
   
           size = mat->col;
           matrow = BDY(mat)[row];
         for ( i = 0; i < size; i++ ) {          for ( i = 0; i < size; i++ ) {
                 mulr( CO, (Obj)ap[i], (Obj)k, (Obj *)&t );                  mulr(CO,(Obj)matrow[i],(Obj)coe,(Obj *)&t);
                 addr( CO, (Obj)aq[i], (Obj)t, (Obj *)&t );                  matrow[i]=(Obj)t;
                 aq[i] = t;  
         }          }
   }
   
         *rp = (Obj)a;  static void
   BodyRowExh( mat, IndexA, IndexB )
   MAT mat;
   int IndexA, IndexB;
   {
           int i, size;
           pointer *t, *PRowA, *PRowB;
   
           size = mat->col;
           PRowA = BDY(mat)[IndexA];
           PRowB = BDY(mat)[IndexB];
           for ( i = 0; i < size; i++ ) {
                   t = PRowA[i];
                   PRowA[i] = PRowB[i];
                   PRowB[i] = t;
           }
   }
   
   static void
   BodyRowMulAdd( mat, IndexA, IndexB, coe )
   MAT mat;
   int IndexA, IndexB;
   pointer coe;
   {
           int i, size;
           pointer *t, *PRowA, *PRowB;
   
           size = mat->col;
           PRowA = BDY(mat)[IndexA];
           PRowB = BDY(mat)[IndexB];
   
           for ( i = 0; i < size; i++ ) {
                   mulr( CO, (Obj)PRowB[i], (Obj)coe, (Obj *)&t );
                   addr( CO, (Obj)PRowA[i], (Obj)t, (Obj *)&t );
                   PRowA[i] = t;
           }
   }
   
   static void
   BodyColMul( mat, Index, coe )
   MAT mat;
   int Index;
   pointer coe;
   {
           int size, i;
   
           size = mat->row;
           for ( i = 0; i < size; i++ ) {
                   mulr(CO, BDY(mat)[i][Index], (Obj)coe, (Obj *)&BDY(mat)[i][Index]);
           }
   }
   
   static void
   BodyColExh( mat, IndexA, IndexB )
   MAT mat;
   int IndexA, IndexB;
   {
           int i, size;
           pointer *t;
   
           size = mat->row;
           for ( i = 0; i < size; i++ ) {
                   t = BDY(mat)[i][IndexA];
                   BDY(mat)[i][IndexA] = BDY(mat)[i][IndexB];
                   BDY(mat)[i][IndexB] = t;
           }
   }
   
   static void
   BodyColMulAdd( mat, IndexA, IndexB, coe )
   MAT mat;
   int IndexA, IndexB;
   pointer coe;
   {
           int i, size;
           pointer *t;
   
           size = mat->row;
           for ( i = 0; i < size; i++ ) {
                   mulr( CO, BDY(mat)[i][IndexB], coe, (Obj *)&t );
                   addr( CO, BDY(mat)[i][IndexA], (Obj)t, (Obj *)&BDY(mat)[i][IndexA]);
           }
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>