Ejemplo n.º 1
0
 private static void TestMatrixInitWithAnotherMatrixToStringMethod()
 {
     try
     {
         MyMatrix matrix = new MyMatrix(new double[, ] {
             { 4, 2, 3 }, { 4, 5, 6 }
         });
         MyMatrix newMatrix = new MyMatrix(matrix.ToString());
         if (newMatrix.ToString().Equals(matrix.ToString()))
         {
             Console.WriteLine("TestMatrixInitWithAnotherMatrixToStringMethod PASSED");
         }
         else
         {
             Console.WriteLine("TestMatrixInitWithAnotherMatrixToStringMethod FAILED");
         }
     }
     catch (MyMatrixException ex)
     {
         Console.WriteLine("TestMatrixInitWithAnotherMatrixToStringMethod FAILED");
     }
 }
Ejemplo n.º 2
0
        private static void TestTransposeMe()
        {
            MyMatrix actual = new MyMatrix(new double[, ] {
                { 1, 2 }, { 3, 4 }
            }).TransposeMe();
            MyMatrix expected = new MyMatrix(new double[, ] {
                { 1, 3 }, { 2, 4 }
            });

            if (actual.ToString().Equals(expected.ToString()))
            {
                Console.WriteLine("TestTransposeMe PASSED");
            }
            else
            {
                Console.WriteLine("TestTransposeMe FAILED");
            }
        }
Ejemplo n.º 3
0
        private static void TestMultiplyMatrix()
        {
            MyMatrix matrix1 = new MyMatrix(new double[, ] {
                { 4, 2 }, { 4, 5 }
            });
            MyMatrix matrix2 = new MyMatrix(new double[, ] {
                { 1, 3, 5 }, { 2, 7, 10 }
            });
            MyMatrix matrix3 = matrix1 * matrix2;
            MyMatrix result  = new MyMatrix(new double[, ] {
                { 8, 26, 40 }, { 14, 47, 70 }
            });

            if (matrix3.ToString().Equals(result.ToString()))
            {
                Console.WriteLine("TestMultiplyMatrix PASSED");
            }
            else
            {
                Console.WriteLine("TestMultiplyMatrix FAILED");
            }
        }