determinants

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...

  1. #1
    Unregistered
    Guest

    determinants

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

    Thanks

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    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 |
    there are 2 ways to determine determinates by minors
    or by diagonals
    Code:
    | 3 4 5 3 4 |
    | 6 7 8 6 7 |
    | 9 1 2 9 1 |
    the last two columns are repeats

    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);
    i havent tested this or anything, but try to figure it out from this

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >why not using recursion?

    Since his/her assignment told him not to do.

  4. #4
    Unregistered
    Guest
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trying to make this code faster & Cramer
    By just2peachy in forum C++ Programming
    Replies: 3
    Last Post: 12-03-2004, 09:54 AM
  2. determinants
    By linuxdude in forum Game Programming
    Replies: 4
    Last Post: 11-18-2004, 06:38 PM
  3. cramer's rule (which uses determinants)
    By alvarorahul in forum C Programming
    Replies: 2
    Last Post: 07-16-2004, 01:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21