static void test2() { CoFactorMethod.createAllSubMatrix(); testCofactorDeterminant("-76 2 10 8 2"); testCofactorDeterminant("0 5 9 10 18"); testCofactorDeterminant("-358 6 3 8 2 4 10 8 9 3"); testCofactorDeterminant("0 6 3 8 12 6 16 8 9 3"); //testDefinitionDeterminant("358 6 3 8 2 4 10 8 9 3"); // Will Fail //testDefinitionDeterminant("10 6 3 8 12 6 16 8 9 3"); // Will Fail testCofactorDeterminant("-648 10 2 6 1 5 10 3 6 7 2 9 7 4 6 8 9"); testCofactorDeterminant("1718 6 4 10 1 10 5 1 9 3 2 9 10 6 2 6 2"); testCofactorDeterminant("52 4 6 10 7 1 4 9 8 10 2 10 7 10 7 6 10 3 6 1 10 10 7 1 8 3"); }
static bool testCofactorDeterminant(string s, bool printAll = true) { var l0 = s.Split(' ').Select(int.Parse).ToList(); var det0 = l0[0]; var l1 = l0.Skip(1).ToList(); var mat = list2matrix(l1); var det1 = CoFactorMethod.ComputeDeterminant(mat); if (printAll || det0 != det1) { foreach (var r in mat) { Console.WriteLine(string.Join(" ", r)); } var info = det0 != det1 ? $"Bad; {det0,10} != {det1}" : $"Good; {det0,10} == {det1}"; Console.WriteLine($"=> {info} cofactorDeterminant"); Console.WriteLine(); } return(det0 == det1); }