Inexacterror when inverting matrix of Int64

57 views
Skip to first unread message

Atul Shrivastava

unread,
May 11, 2014, 9:02:17 AM5/11/14
to juli...@googlegroups.com

When projecting onto a vector space, I use of inv(A'*A) often in deriving the projection matrix. However, when A = [1 0 0; 0 1 0; 0 0 1; 0 0 0] and B = 2*A (example used from Strang's Linear Algebra book 4th ed, pg 215), I get an InexactError() when invoking inv(B'*B). However inv(A'*A) works fine (A'*A is the 3x3 identity matrix).

When B is array of Float64 (using B = 2.0 *A), the matrix inversion works - the returned array is approx. 0.25 * I (identity matrix).

Saw another post where type conversion (Int64-> Float64) was required in some matrix operation context (not inversion though). Is this type conversion a required step before matrix inversion?

Thanks

Andreas Noack Jensen

unread,
May 11, 2014, 4:00:28 PM5/11/14
to juli...@googlegroups.com
Hi Atul

Thank you for reporting. Generally, Julia takes care of the promotion and she should have done so in your case also. The bug is now fixed. 

Regarding the projection, it might be better to use the QR or SVD of A instead of explicitly calculating inv(A'A).
--
Med venlig hilsen

Andreas Noack Jensen
Reply all
Reply to author
Forward
0 new messages