Determinant of a matrix

please can someone tell me how do i write a code for calculating determinant of a matrix in c.That works for all size of matrices eg. 33,44,7*7…and so on…

This may help you…:slight_smile:

Check this one also…:slight_smile:

Leibniz gives an O(N!) algorithm (or O(exp(number of nonzero entries of the matrix))), so it’s useless in programming.

The basic way of calculating the det. is to convert the matrix to upper triangular (having only zeroes below the main diagonal), when you’re only allowed to add/subtract multiples of some row to/from some other row - this operation doesn’t change the det., or swap some 2 rows - this multiplies the determinant by -1. And finding the det. of an upper triangular matrix is cakewalk - just multiply the numbers on its main diagonal.

The complexity of this is O(N^3), same as GEM.

//