I need to find the inverse of a matrix which contains floating point numbers. Can anyone share an efficient (w.r.t. time) code?
Printable View
I need to find the inverse of a matrix which contains floating point numbers. Can anyone share an efficient (w.r.t. time) code?
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.
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.
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:
Quote:
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?
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.