示例#1
0
 // ********************************************************************
 // Multiply matrix 'm1' by 'm2' to give result in this
 //
 // Usage:  A.mult (A1, A2); multiply A1 by A2 giving A
 //
 // ********************************************************************
 public Matrix mult(Matrix m1, Matrix m2)
 {
     if (m1.c == m2.r)
     {
         resize(m1.r, m2.c);
         int m1_col = m1.c;
         for (int i = 0; i < r; i++)
         {
             for (int j = 0; j < m2.c; j++)
             {
                 var sum = new SimpleComplex(0.0, 0.0);
                 for (int k = 0; k < m1_col; k++)
                 {
                     sum = SimpleComplex.complexAdd(sum, SimpleComplex.complexMult(m1[i, k], m2[k, j]));
                 }
                 this[i, j] = sum;
             }
         }
         return(this);
     }
     else
     {
         throw new EMatrixSizeError("Incompatible matrix operands to multiply");
     }
 }
示例#2
0
 // ********************************************************************
 // Multiply the diagonal of the matrix 'm1' by complex number z to give
 // result in this
 //
 // Usage:  A.multDiag (A1, A2); multiply A1 by A2 giving A
 //
 // ********************************************************************
 public Matrix multDiag(Matrix m, SimpleComplex z)
 {
     for (int i = 0; i < m.r; i++)
     {
         this[i, i] = SimpleComplex.complexMult(m[i, i], z);
     }
     return(this);
 }
示例#3
0
 // ********************************************************************
 // Multiply matrix 'm1' by complex number z to give result in this
 //
 // Usage:  A.mult (A1, z); multiply A1 by z giving A
 //
 // ********************************************************************
 public Matrix mult(Matrix m, SimpleComplex z)
 {
     for (int i = 0; i < m.r; i++)
     {
         for (int j = 0; j < m.c; j++)
         {
             this[i, j] = SimpleComplex.complexMult(m[i, j], z);
         }
     }
     return(this);
 }
示例#4
0
 // ********************************************************************
 // Multiply matrix 'm1' by scalar k to give result in Self
 //
 // Usage:  A.mult (A1, A2); multiply A1 by A2 giving A
 //
 // ********************************************************************
 public Matrix mult(Matrix m, double k)
 {
     for (int i = 0; i < m.r; i++)
     {
         for (int j = 0; j < m.c; j++)
         {
             this[i, j] = SimpleComplex.complexMult(m[i, j], new SimpleComplex(k, 0.0));
         }
     }
     return(this);
 }