hi, i'm working on a program that allows you to enter a matrix, and then do all kinds of stuff to it. i'm having problems with my determinant function, though. I want to use recursion so that if doesn't matter what size matrix is entered. there is a seperate function that gets a sub-matrix for me, but the recursion is killing me.
that's my determinant function as of right now. it gives me an infinite loop. the arguments of my submatrix function are:Code:double determinant(double m [][MAXCOLS], int msize) { double det = 0; double subm [MAXCOLS][MAXCOLS]; int i; int sign = 0; if(msize < 3) det = m[0][0] * m[1][1] - m[0][1] * m[1][0]; else { for(i = 0; i < msize; i++) { if(i%2 == 0) sign = 1; else { sign = -1; } get_submatrix(m, subm, msize, 0, i); det += (sign * m[0][i] * determinant(subm, msize-i)); } } return det; }
arg1, double array [MAXCOLS][MAXCOLS]
arg2, double array [MAXCOLS][MAXCOLS]
arg3, int (the size of the square matrix)
arg4, int (row to be removed)
arg5, int (column to be removed)
if you need more info, just let me know, and i appreciate any help that i can get!



LinkBack URL
About LinkBacks


