could some one point me to an algorithm to find the determinant of a square matrix, not using recursion?
Thanks
This is a discussion on determinants within the C++ Programming forums, part of the General Programming Boards category; could some one point me to an algorithm to find the determinant of a square matrix, not using recursion? Thanks...
could some one point me to an algorithm to find the determinant of a square matrix, not using recursion?
Thanks
why not using recursion? i'm guessing this is homework
here's a few hints:
there are 2 ways to determine determinates by minorsCode:| 3 4 5 | | 6 7 8 | | 9 1 2 |
or by diagonals
the last two columns are repeatsCode:| 3 4 5 3 4 | | 6 7 8 6 7 | | 9 1 2 9 1 |
try this:
assuming a matrix is int a[3][3];, and its filled like above
i havent tested this or anything, but try to figure it out from thisCode:#define BORDER_CONSTANT 3 int t=0, u=0; for (i=0;i<3;i++) for (j=0;j<3;j++) t+=a[(i+j)%BORDER_CONSTANT][i]; for (i=2;i<=0;i--) for (j=0;j<3;j++) u+=a[(i+j)%BORDER_CONSTANT][i]; printf("%d",t-u);
>why not using recursion?
Since his/her assignment told him not to do.
thanks. Yeah its home work, although it didnt say it couldnt be recursion, I didnt want to make it recursion. Also, its not C/C++, some new language(to me). I just couldnt get my algorithm to work right. But thanks