Exemple #1
0
 private double[,] GetTransponedArray(MyMatrix ob)
 {
     double[,] result = new double[ob.height, ob.width];
     for (int i = 0; i < result.GetLength(0); i++)
     {
         for (int j = 0; j < result.GetLength(1); j++)
         {
             result[i, j] = ob[j, i];
         }
     }
     return(result);
 }
Exemple #2
0
        public void filingOfMatrix(MyMatrix ob)
        {
            Random rand = new Random();

            for (int i = 0; i < ob.height; i++)
            {
                for (int j = 0; j < ob.width; j++)
                {
                    ob.matrix[i, j] = rand.Next(-1, 9);
                }
            }
        }
Exemple #3
0
        public static MyMatrix operator *(MyMatrix matrixA, MyMatrix matrixB)
        {
            if (matrixA.matrix.Length != matrixB.matrix.Length)
            {
                throw new Exception("Множення не можливе тому, що кількість стовпчиків не дорівнює кількості рядків.");
            }

            MyMatrix matrixC = new MyMatrix(matrixA.height, matrixB.width);

            for (var i = 0; i < matrixA.height; i++)
            {
                for (var j = 0; j < matrixB.width; j++)
                {
                    matrixC[i, j] = 0;

                    for (var k = 0; k < matrixA.width; k++)
                    {
                        matrixC[i, j] += matrixA[i, k] * matrixB[k, j];
                    }
                }
            }

            return(matrixC);
        }
Exemple #4
0
 public MyMatrix(MyMatrix mx)
 {
     matrix      = mx.matrix;
     this.height = mx.height;
     this.width  = mx.width;
 }
Exemple #5
0
 public void TransponeMe(MyMatrix ob)
 {
     this.matrix = GetTransponedArray(ob);
 }
Exemple #6
0
 public MyMatrix GetTransponedCopy(MyMatrix ob)
 {
     double[,] resultArr = GetTransponedArray(ob);
     return(new MyMatrix(resultArr));
 }