|
-
March 31st, 2010, 12:08 AM
#1
Inverse of a Matrix: Efficient Code (timewise)
I need to find the inverse of a matrix which contains floating point numbers. Can anyone share an efficient (w.r.t. time) code?
-
March 31st, 2010, 08:24 AM
#2
Re: Inverse of a Matrix: Efficient Code (timewise)
-
March 31st, 2010, 08:53 AM
#3
Re: Inverse of a Matrix: Efficient Code (timewise)
http://people.richland.edu/james/lec.../inverses.html
http://www.wikihow.com/Inverse-a-3X3-Matrix
http://mathworld.wolfram.com/MatrixInverse.html
http://www.mathwords.com/i/inverse_of_a_matrix.htm
For small matrixes, efficiency is a bit of a moot issue since there's very little you can do to optimise things. You can typically get the best results by hardcoding a function for a specific matrix size not using any loops. This will quickly become unwieldy as your matrix size increases. But for 2x2, 3x3 and 4x4 it's definately worth the effort. I would expect a performance oriented 3D lib to have such hardcoded matrix calculations since they typically only have to deal with 1 size matrix.
For large matrixes, there are a number of systems that have varying degrees of performance over the raw calculation.
-
March 31st, 2010, 09:27 AM
#4
Re: Inverse of a Matrix: Efficient Code (timewise)
Usually the fastest approach involves some form of matrix decomposition. LU, SVD, or Cholesky decompositions are common.
As noted, these are probably overkill for small matrices.
-
March 31st, 2010, 11:42 AM
#5
Re: Inverse of a Matrix: Efficient Code (timewise)
I was aiming for a range of 24X24.
I found a file through Google:
http://users.erols.com/mdinolfo/matrix.htm
He's shown an example with 200x200. In that regard I have a naive question to ask:
If I include a header file, but delete all but a single function out of that header file, will my .exe be as large as it would have been if I had used the entire header file? In both cases I am using the same function, but in the first case I am removing the extra baggage. Does the compiler understand and reduce the compiled code?
-
March 31st, 2010, 11:58 AM
#6
Re: Inverse of a Matrix: Efficient Code (timewise)
Compilers are usually pretty good about trimming unused code, especially in a non-DLL context. However, unless you're working on an embedded platform, exe size should be fairly low down your list of priorities IMO.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|