Accord.Tests.Math.LuDecompositionTest.LuDecompositionConstructorTest C# (CSharp) Method

LuDecompositionConstructorTest() private method

private LuDecompositionConstructorTest ( ) : void
return void
        public void LuDecompositionConstructorTest()
        {
            double[,] value =
            {
               {  2, -1,  0 },
               { -1,  2, -1 },
               {  0, -1,  2 }
            };


            double[,] expectedL =
            {
                {  1.0000,         0,         0 },
                { -0.5000,    1.0000,         0 },
                {       0,   -0.6667,    1.0000 },
            };


            double[,] expectedU =
            {
                { 2.0000,   -1.0000,         0 },
                {      0,    1.5000,   -1.0000 },
                {      0,         0,    1.3333 },
             };


            var target = new LuDecomposition(value);
            double[,] actualL = target.LowerTriangularFactor;
            double[,] actualU = target.UpperTriangularFactor;

            Assert.IsTrue(Matrix.IsEqual(expectedL, actualL, 0.001));
            Assert.IsTrue(Matrix.IsEqual(expectedU, actualU, 0.001));


            target = new LuDecomposition(value.Transpose(), true);

            actualL = target.LowerTriangularFactor;
            actualU = target.UpperTriangularFactor;

            Assert.IsTrue(Matrix.IsEqual(expectedL, actualL, 0.001));
            Assert.IsTrue(Matrix.IsEqual(expectedU, actualU, 0.001));
        }