Exemplo n.º 1
0
        public void Matrix33Inverse()
        {
            var m = new Matrix3D(4, 6, 2, 4, 67, 8, 0, 1, 34);

            Assert.AreNotEqual(0d, m.Determinant());
            var m_1   = m.Inverse;
            var ident = m_1 * m;
            var det   = ident.Determinant();

            Assert.AreEqual(1d, det, 0.000001);
            Assert.AreEqual(3d, ident.M11 + ident.M22 + ident.M33, 0.000001);
        }
Exemplo n.º 2
0
        void Matrix3DTest()
        {
            var m = new Matrix3D(new double[] {
                1, .5, 6,
                .1, 2, .05,
                .7, 11, .55
            });

            // det
            Assert.True(m.Determinant().EqualsTol(1e-6, -1.260));

            // inv
            Assert.True(m.Inverse().EqualsTol(1e-3, new Matrix3D(new double[] {
                -0.437, -52.163, 9.504,
                0.016, 2.897, -0.437,
                0.238, 8.452, -1.548
            })));

            // solve
            Assert.True(m.Solve(1.1, 2.2, 3.3).EqualsTol(1e-3, new Vector3D(-83.875, 4.95, 13.75)));
        }
Exemplo n.º 3
0
        public void Determinant()
        {
            Matrix3D m = new Matrix3D(0, 0, 1,
                                      0, 1, 0,
                                      1, 0, 0);

            Assert.AreEqual(-1, m.Determinant());

            m = new Matrix3D(
                5, 7, 1,
                17, 2, 64,
                10, 14, 2);

            Assert.AreEqual(0, m.Determinant());

            m = new Matrix3D(
                1, 2, 3,
                4, 5, 6,
                7, 8, 9);

            Assert.AreEqual(0, m.Determinant());
        }