Esempio n. 1
0
///// <summary>
///// Parses strig to
///// </summary>
///// <param name="str"></param>
///// <returns></returns>
//public static Matrix Parse(string str)
//   {
//       string working = str.Trim();

//       if (str.StartsWith("["))
//       {
//           return ParseMatLab(str);
//       }
//       else if (str.StartsWith("{"))
//       {
//           return ParseMathematica(str);
//       }
//       else
//       {
//              System.IO.StringReader reader = new System.IO.StringReader(str);
//               Matrix mat = Load(reader);
//               reader.Close();
//               reader.Dispose();
//               return mat;
//       }
//   }



//

/* ------------------------
 * Private Methods
 * ------------------------ */

        /** Check if size(A) == size(B) **/

        private void CheckMatrixDimensions(MatrixOld B)
        {
            if (B.m != m || B.n != n)
            {
                throw new System.ArgumentException("Matrix dimensions must agree.");
            }
        }
Esempio n. 2
0
 ///<summary>Element-by-element left division in place, A = A.\B</summary>
 ///<param name="B">another matrix</param>
 ///<returns>A.\B</returns>
 public MatrixOld ArrayLeftDivideEquals(MatrixOld B)
 {
     CheckMatrixDimensions(B);
     for (int i = 0; i < m; i++)
     {
         for (int j = 0; j < n; j++)
         {
             A[i, j] = B.A[i, j] / A[i, j];
         }
     }
     return(this);
 }
Esempio n. 3
0
 ///<summary>Element-by-element multiplication in place, A = A.*B</summary>
 ///<param name="B">another matrix</param>
 ///<returns>A.*B</returns>
 public MatrixOld ArrayTimesEquals(MatrixOld B)
 {
     CheckMatrixDimensions(B);
     for (int i = 0; i < m; i++)
     {
         for (int j = 0; j < n; j++)
         {
             A[i, j] = A[i, j] * B.A[i, j];
         }
     }
     return(this);
 }