What is the fastest algorithm (a link to C or C++ example would be cool) to check if a small square matrix (<16*16 elements) is singular (non-invertible, det = 0) ?
The fastest way is probably to hard code a determinant function for each size matrix you expect to deal with.
Here is some psuedo-code for N=3, but if you check out The Leibniz formula for determinants the pattern should be clear for all N.
function is_singular3(matrix) {
det = matrix[1][1]*matrix[2][2]*matrix[3][3]
- matrix[1][1]*matrix[2][3]*matrix[3][2]
- matrix[1][2]*matrix[2][1]*matrix[3][3]
+ matrix[1][2]*matrix[2][3]*matrix[3][1]
+ matrix[1][3]*matrix[2][1]*matrix[3][2]
- matrix[1][3]*matrix[2][2]*matrix[3][1];
if(det==0) return true
else return false
}