Пример #1
0
        public void TransposeTestTransposesMatrix()
        {
            SparseMatrix expected = new SparseMatrix(5, 3);
            expected[0, 0] = 3.0f;
            expected[2, 0] = 4.4f;
            expected[3, 1] = 2.1f;
            expected[4, 1] = 1.1f;
            expected[0, 2] = 0.5f;
            expected[2, 2] = 3.5f;

            TestMatrix = TestMatrix.Transpose();

            Assert.IsTrue(expected.ApproximatelyEqual(TestMatrix));
        }
Пример #2
0
        public void ScalarMultiplicationTestWhenScalarZero()
        {
            SparseMatrix expected = new SparseMatrix(3, 5);

            TestMatrix = TestMatrix.ScalarMultiplication(0.0f);

            Assert.IsTrue(expected.ApproximatelyEqual(TestMatrix));
        }
Пример #3
0
        public void ProductTestGreaterThanZero()
        {
            SparseMatrix expected = new SparseMatrix(3, 3);
            expected[0, 0] = 13.2000008f;
            expected[0, 2] = 2.69999981f;
            expected[1, 1] = 1.64f;
            expected[2, 0] = 10.5f;
            expected[2, 2] = 0.45f;

            SparseMatrix factor = new SparseMatrix(3, 5);
            factor[0, 1] = 2.0f;
            factor[0, 2] = 3.0f;
            factor[1, 3] = 0.1f;
            factor[1, 4] = 1.3f;
            factor[2, 0] = 0.9f;
            factor[2, 1] = 1.5f;
            factor = factor.Transpose();

            SparseMatrix result = TestMatrix.Product(factor);

            Assert.IsTrue(expected.ApproximatelyEqual(result));
        }
Пример #4
0
        public void ScalarMultiplicationTestWhenScalarLessThanZero()
        {
            SparseMatrix expected = new SparseMatrix(3, 5);
            expected[0, 0] = -9.0f;
            expected[0, 2] = -13.2000008f;
            expected[1, 3] = -6.29999971f;
            expected[1, 4] = -3.30000019f;
            expected[2, 0] = -1.5f;
            expected[2, 2] = -10.5f;

            TestMatrix = TestMatrix.ScalarMultiplication(-3.0f);

            Assert.IsTrue(expected.ApproximatelyEqual(TestMatrix));
        }
Пример #5
0
        public void NormalizeRowsTestCorrectly()
        {
            SparseMatrix expected = new SparseMatrix(3, 5);
            expected[0, 0] = 0.5633368f;
            expected[0, 2] = 0.826227367f;
            expected[1, 3] = 0.885831535f;
            expected[1, 4] = 0.46400702f;
            expected[2, 0] = 0.141421363f;
            expected[2, 2] = 0.989949465f;

            SparseMatrix result = TestMatrix.NormalizeRows();

            Assert.IsTrue(expected.ApproximatelyEqual(result));
        }