Accord.Tests.Math.MatrixTest.SolveTest3 C# (CSharp) Method

SolveTest3() private method

private SolveTest3 ( ) : void
return void
        public void SolveTest3()
        {
            // Test with more rows than columns
            {
                double[,] matrix = 
                {
                    { 1, 2 },
                    { 3, 4 },
                    { 5, 6 },
                };

                double[] rightSide = { 7, 8, 9 };

                Assert.IsTrue(matrix.GetLength(0) > matrix.GetLength(1));

                double[] expected = { -6, 6.5 };

                double[] actual = Matrix.Solve(matrix, rightSide);

                Assert.IsTrue(expected.IsEqual(actual, 1e-10));
            }

            // test with more columns than rows
            {
                double[,] matrix = 
                {
                    { 1, 2, 3 },
                    { 4, 5, 6 },
                };

                double[] rightSide = { 7, 8 };

                Assert.IsTrue(matrix.GetLength(0) < matrix.GetLength(1));


                double[] expected = { -55 / 18.0, 1 / 9.0, 59 / 18.0 };

                double[] actual = Matrix.Solve(matrix, rightSide);

                Assert.IsTrue(expected.IsEqual(actual, 1e-10));
            }
        }
MatrixTest