예제 #1
0
        public void CastRectangularToSquare()
        {
            RectangularMatrix A = GenerateRandomMatrix(2, 3);

            RectangularMatrix AT = A.Transpose;

            RectangularMatrix ATA1 = AT * A;

            SquareMatrix ATA2 = (SquareMatrix)ATA1;

            Assert.IsTrue(ATA2 == ATA1);

            SymmetricMatrix ATA3 = A.MultiplyTransposeBySelf();

            Assert.IsTrue(ATA2 == ATA3);

            RectangularMatrix AAT1 = A * AT;

            SquareMatrix AAT2 = (SquareMatrix)AAT1;

            Assert.IsTrue(AAT2 == AAT1);

            SymmetricMatrix AAT3 = A.MultiplySelfByTranspose();

            Assert.IsTrue(AAT2 == AAT3);
        }
예제 #2
0
        public void MatrixSelfMultiplication()
        {
            RectangularMatrix A = GenerateRandomMatrix(3, 4);

            SymmetricMatrix AAT = A.MultiplySelfByTranspose();

            Assert.IsTrue(TestUtilities.IsNearlyEqual(AAT, A * A.Transpose));

            SymmetricMatrix ATA = A.MultiplyTransposeBySelf();

            Assert.IsTrue(TestUtilities.IsNearlyEqual(ATA, A.Transpose * A));
        }