Closed clvcooke closed 9 years ago
Complete and committed to the master
We should consider using the Leibniz formula (http://en.wikipedia.org/wiki/Leibniz_formula_for_determinants) for calculating determinants considering the current recursive formula is insanely inefficient.
Quoting from the first paragraph...
Directly evaluating the Leibniz formula from the definition requires \Omega(n! \cdot n) operations in general—that is, a number of operations asymptotically proportional to n factorial—because n! is the number of order-n permutations. This is impractically difficult for large n. Instead, the determinant can be evaluated in O(n3) operations by forming the LU decomposition A = LU (typically via Gaussian elimination or similar methods), in which case \det A = (\det L) (\det U) and the determinants of the triangular matrices L and U are simply the products of their diagonal entries.
True that makes a lot more sense (too busy trying to make sense of the equation to read the paragraphs). We definitely need an rref function before we proceed so I'll open up a thread for that
Write a function within the Matrix class which calculates and returns its determinant.