public void MatrixDeterminantTest1()
        {
            var a = MatrixOperations.FromArray(2, 2, new double[]{
                1, 5,
                -3, 2,
            });

            Assert.True(Constants.EpsilonCompare(17, MatrixOperations.Determinant(a, MatrixOperation.Cofactor)));
            output.WriteLine(MatrixOperations.Determinant(a, MatrixOperation.Cofactor).ToString());
        }
        public void MatrixDeterminantTest2()
        {
            var a = MatrixOperations.FromArray(3, 3, new double[]{
                1, 2, 6,
                -5, 8, -4,
                2, 6, 4
            });

            Assert.True(Constants.EpsilonCompare(-196, MatrixOperations.Determinant(a, MatrixOperation.Cofactor)));
            Assert.True(Constants.EpsilonCompare(-196, MatrixOperations.Determinant(a, MatrixOperation.Gauss)));
            output.WriteLine(MatrixOperations.Determinant(a, MatrixOperation.Cofactor).ToString());
        }
示例#3
0
        public void Then_determinant_of_minor(string a, int row, int col, double det)
        {
            {
                var actualResult = MatrixOperations.Determinant(MatrixOperations.Minor(cache[a], row, col), MatrixOperation.Cofactor);
                Assert.True(Constants.EpsilonCompare(det, actualResult));
            }

            {
                var actualResult = MatrixOperations.Determinant(MatrixOperations.Minor(cache[a], row, col), MatrixOperation.Gauss);
                Assert.True(Constants.EpsilonCompare(det, actualResult));
            }
        }
        public void MatrixDeterminantTest3()
        {
            var a = MatrixOperations.FromArray(4, 4, new double[]{
                -2, -8, 3, 5,
                -3, 1, 7, 3,
                1, 2, -9, 6,
                -6, 7, 7, -9
            });

            Assert.True(Constants.EpsilonCompare(-4071, MatrixOperations.Determinant(a, MatrixOperation.Gauss)));
            Assert.True(Constants.EpsilonCompare(-4071, MatrixOperations.Determinant(a, MatrixOperation.Cofactor)));
            output.WriteLine(MatrixOperations.Determinant(a, MatrixOperation.Cofactor).ToString());
        }
示例#5
0
        public void Then_matrix_determinant(string a, double det)
        {
            // Invert using Cofactor
            {
                var actualResult = MatrixOperations.Determinant(cache[a], MatrixOperation.Cofactor);
                Assert.True(Constants.EpsilonCompare(det, actualResult));
            }

            // Invert using Gauss
            {
                var actualResult = MatrixOperations.Determinant(cache[a], MatrixOperation.Gauss);
                Assert.True(Constants.EpsilonCompare(det, actualResult));
            }
        }
示例#6
0
        public void And_matrix_is_not_invertible(string id)
        {
            var det = MatrixOperations.Determinant(cache[id], MatrixOperation.Gauss);

            Assert.True(Constants.EpsilonZero(det));
        }