There is a Bug in the method for calculating the determining factor of the descending order method (the original article has been corrected, which is the corrected part)
I have found a mistake when using this function to solve the equation today. I hereby correct it:
////// Calculate the determinant using the descending order method //////Order N Determinant///Zero optimization?///
Calculation Result
Public static decimal CalcDeterminantAij (decimal [,] Determinants, bool ZeroOptimization = false) {var theN = Determinants. getLength (0); // if it is Level 2, calculate if (theN = 2) {return Determinants [0, 0] * Determinants [1, 1]-Determinants [0, 1] * Determinants [1, 0];} if (theN = 1) {return Determinants [0, 0];} if (theN = 0) {throw new Exception ("parameter error! ");} If (ZeroOptimization) {// find the row with the most 0 int theRowIndex = 0; int theMaxZeroCountR =-1; for (int I = 0; I <theN; I ++) {int theZeroNum = 0; for (int j = 0; j <theN; j ++) {if (Determinants [I, j] = 0) {theZeroNum ++ ;}} if (theZeroNum> theMaxZeroCountR) {theRowIndex = I; theMaxZeroCountR = theZeroNum ;}// you can find the column with the most 0 int theColIndex = 0; int theMaxZeroCountC =-1; for (int I = 0; I <theN; I ++) {int theZeroNum = 0; for (int j = 0; j <theN; j ++) {if (Determinants [j, I] = 0) {theZeroNum ++ ;}} if (theZeroNum> theMaxZeroCountC) {theColIndex = I; theMaxZeroCountC = theZeroNum;} if (theMaxZeroCountR >=themaxzerocountc) {decimal theRetDec = 0; // expand int I = theRowIndex + 1 in line I = theRowIndex + 1; for (int j = 1; j <= theN; j ++) {var theSign = CalcDeterMijSign (I, j); var theNewMij = GetDeterminantMij (Determinants, I, j ); theRetDec + = theSign * Determinants [I-1, j-1] * CalcDeterminantAij (theNewMij, ZeroOptimization);} return theRetDec;} else {decimal theRetDec = 0; // expand int j = theColIndex + 1 in column j = theColIndex + 1; for (int I = 1; I <= theN; I ++) {var theSign = sums (I, j); var theNewMij = GetDeterminantMij (Determinants, I, j); theRetDec + = theSign * Determinants [I, j] * CalcDeterminantAij (theNewMij, zeroOptimization);} return theRetDec;} else {// use the Random method to expand a line var I = new Random (). next (1, theN); decimal theRetDec = 0; for (int j = 1; j <= theN; j ++) {var theSign = CalcDeterMijSign (I, j ); var theNewMij = GetDeterminantMij (Determinants, I, j); // modify theRetDec + = theSign * Determinants [I, j] * CalcDeterminantAij (theNewMij, ZeroOptimization) here ); theRetDec + = theSign * Determinants [I-1, J-1] * CalcDeterminantAij (theNewMij, ZeroOptimization);} return theRetDec ;}}