示例#1
0
        public void InverseTest()
        {
            var matrix = new Matrix(new[]
            {
                new Vector(new[] { new Number(3), new Number(7), new Number(2), new Number(5) }),
                new Vector(new[] { new Number(1), new Number(8), new Number(4), new Number(2) }),
                new Vector(new[] { new Number(2), new Number(1), new Number(9), new Number(3) }),
                new Vector(new[] { new Number(5), new Number(4), new Number(7), new Number(1) })
            });
            var expected = new Matrix(new[]
            {
                new Vector(new[] { new Number(0.0970873786407767), new Number(-0.18270079435128), new Number(-0.114739629302736), new Number(0.224183583406884) }),
                new Vector(new[] { new Number(-0.0194174757281553), new Number(0.145631067961165), new Number(-0.0679611650485437), new Number(0.00970873786407767) }),
                new Vector(new[] { new Number(-0.087378640776699), new Number(0.0644307149161518), new Number(0.103265666372463), new Number(-0.00176522506619595) }),
                new Vector(new[] { new Number(0.203883495145631), new Number(-0.120035304501324), new Number(0.122683142100618), new Number(-0.147396293027361) })
            });

            var actual = MatrixExtensions.Inverse(matrix, null);

            Assert.Equal(expected, actual);
        }