could some one point me to an algorithm to find the determinant of a square matrix, not using recursion?

Thanks

Printable View

- 04-07-2002Unregistereddeterminants
could some one point me to an algorithm to find the determinant of a square matrix, not using recursion?

Thanks - 04-07-2002ygfperson
why not using recursion? i'm guessing this is homework

here's a few hints:

Code:`| 3 4 5 |`

| 6 7 8 |

| 9 1 2 |

or by diagonals

Code:`| 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

Code:`#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);

- 04-07-2002Shiro
>why not using recursion?

Since his/her assignment told him not to do. - 04-07-2002Unregistered
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