Thread: determinant

  1. #1
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455

    determinant

    i need some help here.

    ive got a 2d array (vector<vector<double>> v), and i need to find the determinant. im at work, and i have to convert an old matlab program over, but im run into this little problem...ive been googling and i havent found a good definition of what it is. can someone help me out?

    thanks

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Go to www.gamedev.net and read their articles and resources concerning matrices and quaternions - I think its in the math and physics section.

    They have several articles about the determinant and sample code that will find the determinant of a matrix.

  3. #3
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455
    ok, im reading it, alot of it is going way over my head. right now im tringt o sort out the 2d array (which i guess is a matrix), in my other thread.

    ok, i get how to multply them to get one. but i have a question.


    http://www.gamedev.net/reference/art...article877.asp

    If you scroll down to where he multplies and has that huge 4 chunk matrix, are those multplied together or added together to produce the final matrix?

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Code:
    Matrix Matrix_Multiply(Matrix mat1, Matrix mat2) 
    {
      int i, j, k;
      Matrix mat;
    
      // For speed reasons, use the unroll-loops option of your   
      //compiler
      for(i = 0; i < 4; i++)
        for(j = 0; j < 4; j++)
          for(k = 0, mat[i][j] = 0; k < 4; k++)
            mat[i][j] += mat1[i][k] * mat2[k][j];
    
      return mat;
    }
    Multiplied. You concatenate matrices by multiplying them together.

    I would first try this outside of the vector STL. Use a standard 2D array and attempt to find its determinant. Then when you fully understand it, use the STL. Personally, I'd stick with what is straightforward and not worry about all the razzamatazz of the STL. There are times to use it and it is a great tool, but this is not one of those times.

    Also I would not recommend returning a matrix as this can get confusing. If you know the data type of your matrices then there is really no reason to make the function work with all data types - unless you are coding an abstract generic matrix class that has a determinant function. I'm not sure why he (the author) is creating a matrix object but remember its only one approach to the problem.

    If you do not like the 2D array because of the inherent multiplies to fetch elements and set elements, turn the 2D array into a 1D array like the author states.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fast Determinant evaluator
    By jack_carver in forum C Programming
    Replies: 2
    Last Post: 12-28-2009, 08:42 PM
  2. matrix determinant
    By roaan in forum C Programming
    Replies: 1
    Last Post: 06-30-2009, 12:44 PM
  3. Determinant Prob
    By dantu1985 in forum C Programming
    Replies: 2
    Last Post: 08-19-2007, 12:00 AM
  4. Recursive algorithm to find the determinant of a matrix
    By mahesh.mach in forum C Programming
    Replies: 3
    Last Post: 06-07-2007, 09:13 AM
  5. determinant?! HELP!!!
    By ankurtrick in forum C Programming
    Replies: 1
    Last Post: 10-08-2004, 09:12 PM