private static void TestDeterminantSingular2(LinearAlgebraProviderChoice providers) { TestSettings.RunMultiproviderTest(providers, delegate() { // singular (rank = 9) var A = Matrix.CreateFromArray(SquareSingularSingleDeficiency10by10.Matrix); LUFactorization factorization = A.FactorLU(); double det = factorization.CalcDeterminant(); comparer.AssertEqual(SquareSingularSingleDeficiency10by10.Determinant, det); }); }
private static void TestDeterminantInvertiblePositive(LinearAlgebraProviderChoice providers) { TestSettings.RunMultiproviderTest(providers, delegate() { // invertible (rank = 10) with positive det var A = Matrix.CreateFromArray(SquareInvertible10by10.Matrix); LUFactorization factorization = A.FactorLU(); double det = factorization.CalcDeterminant(); comparer.AssertEqual(SquareInvertible10by10.Determinant, det); }); }
private static void TestDeterminantInvertibleNegative(LinearAlgebraProviderChoice providers) { TestSettings.RunMultiproviderTest(providers, delegate() { // Switch 2 rows to make the det negative var A = Matrix.CreateFromArray(SquareInvertible10by10.Matrix); Vector row0 = A.GetRow(0); Vector row9 = A.GetRow(9); A.SetSubrow(0, row9); A.SetSubrow(9, row0); LUFactorization factorization = A.FactorLU(); double det = factorization.CalcDeterminant(); comparer.AssertEqual(-SquareInvertible10by10.Determinant, det); }); }