469,332 Members | 6,650 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

Matrix Inversion Algorithm or Memory Storage Issue?

2
Hello all.. I wrote code in C to invert n x n matrices, where 1<n<39 and the matrices are guaranteed to be invertible. Prior to this task, I haven't really seen linear algebra since my sophmore year of undergrad, but I believe my algorithm implements Gaussian elimination. I append an identity matrix to the right of the one I wish to invert, use row addition to first turn the lower matrix to zeroes and then turn the upper matrix to zeroes, and finally divide each row by the remaining diagonal values in the original matrix to turn the original matrix into an identity matrix.

Here's where I hit a wall: the code works fine until I attempt to invert a 10x10 matrix or larger. I replicated my algorithm in Microsoft Excel, step-by-step (painful), to assess what the intermediate values should be. Some of the values in the appended identity matrix get divided numerous times, often by very large numbers (e.g., 10^17), and it seems as if C's storage of resulting values loses precision past a certain point. I reproduced in Excel my code's results, though the MINVERSE function in Excel produces the correct matrix inversion.

I thought that by using LONG DOUBLE data types to hold values I would be in good shape, but such is not the case.

Question: Is this problem attributable to limits on how very large or very small numbers get represented and stored in memory? If yes, is there a better inversion algorithm that will not bump against memory representation constraints? Thank you in advance for any good thoughts on this.

P.S. The three linear algebra calculations I need to perform for my purposes are:

a. (X transposed)(Y inverted)(X)
b. (Identity transposed)(Y inverted)(X)
c. (Identity transposed)(Y inverted)(Identity)
Nov 11 '07 #1
3 4601
chazzy69
196 100+
Hey i have no real experience with matrix's but have tried using a void??

Thought it might help
Nov 12 '07 #2
JosAH
11,448 Expert 8TB
Trying to find an explicit inverse of a matrix is a very numerically unstable operation.
Do you use row pivots (swapping of rows) to find more stable (read: large) pivots?
If not, it explains the results you get. Better google for 'LUP' decomposition; it's
as simple as Gaussian elimination; it just takes a bit more of bookkeeping.

kind regards,

Jos
Nov 12 '07 #3
PeteJ
2
Thanks for the tip. In case anyone like me needs to brush up on linear algebra, I found the following link that points to an intuitive, step-by-step .ppt refresher on LU decomposition:

http://numericalmethods.eng.usf.edu/mws/gen/04sle/mws_gen_sle_ppt_ludecomp.ppt

Pete
Nov 13 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by vishnu mahendra | last post: by
3 posts views Thread by Jack Middleton | last post: by
20 posts views Thread by Frank-O | last post: by
10 posts views Thread by Ing. Carlos Villaseñor M. | last post: by
21 posts views Thread by =?UTF-8?B?TWFydGluIFDDtnBwaW5n?= | last post: by
14 posts views Thread by Paul McGuire | last post: by
3 posts views Thread by lancered | last post: by
1 post views Thread by haryvincent176 | last post: by
reply views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.