Esempio n. 1
0
 internal static T Determinant <T>(this Matrix3x3 <T> a)
     where T : IComparable <T> =>
 Operations.Add(
     Operations.Add(
         Operations.Multiply(a[0, 0], a.Cofactor(0, 0)),
         Operations.Multiply(a[0, 1], a.Cofactor(0, 1))),
     Operations.Multiply(a[0, 2], a.Cofactor(0, 2)));
Esempio n. 2
0
        public void TestCalculateDeterminantOf3x3Matrix()
        {
            var a = new Matrix3x3(
                1, 2, 6,
                -5, 8, -4,
                2, 6, 4);

            Assert.Equal(56, a.Cofactor(0, 0));
            Assert.Equal(12, a.Cofactor(0, 1));
            Assert.Equal(-46, a.Cofactor(0, 2));
            Assert.Equal(-196, a.Determinant());
        }
Esempio n. 3
0
        public void TestCalculateCofactorOf3x3Matrix()
        {
            var a = new Matrix3x3(
                3, 5, 0,
                2, -1, -7,
                6, -1, 5);

            Assert.Equal(-12, a.Minor(0, 0));
            Assert.Equal(-12, a.Cofactor(0, 0));
            Assert.Equal(25, a.Minor(1, 0));
            Assert.Equal(-25, a.Cofactor(1, 0));
        }
Esempio n. 4
0
        public void Determinate()
        {
            var matrix = new Matrix3x3(
                1, 2, 6,
                -5, 8, -4,
                2, 6, 4);

            Assert.Equal(56, Matrix3x3.Cofactor(matrix, 0, 0));
            Assert.Equal(12, Matrix3x3.Cofactor(matrix, 0, 1));
            Assert.Equal(-46, Matrix3x3.Cofactor(matrix, 0, 2));
            Assert.Equal(-196, Matrix3x3.Determinate(matrix));
        }
Esempio n. 5
0
        public void Cofactor()
        {
            var matrix = new Matrix3x3(
                3, 5, 0,
                2, -1, -7,
                6, -1, 5);

            Assert.Equal(-12, Matrix3x3.Minor(matrix, 0, 0));
            Assert.Equal(-12, Matrix3x3.Cofactor(matrix, 0, 0));
            Assert.Equal(25, Matrix3x3.Minor(matrix, 1, 0));
            Assert.Equal(-25, Matrix3x3.Cofactor(matrix, 1, 0));
        }
        public void Cofactor_should_return_the_cofactor_of_the_matrix()
        {
            var matrix = new Matrix3x3(
                3, 5, 0,
                2, -1, -7,
                6, -1, 5);

            matrix.Cofactor(0, 0).Should().Be(-12);
            matrix.Cofactor(0, 1).Should().Be(-52);
            matrix.Cofactor(0, 2).Should().Be(4);

            matrix.Cofactor(1, 0).Should().Be(-25);
            matrix.Cofactor(1, 1).Should().Be(15);
            matrix.Cofactor(1, 2).Should().Be(33);

            matrix.Cofactor(2, 0).Should().Be(-35);
            matrix.Cofactor(2, 1).Should().Be(21);
            matrix.Cofactor(2, 2).Should().Be(-13);
        }
Esempio n. 7
0
 internal static double Determinant(this Matrix3x3 a) =>
 (a[0, 0] * a.Cofactor(0, 0)) +
 (a[0, 1] * a.Cofactor(0, 1)) +
 (a[0, 2] * a.Cofactor(0, 2));