thouis / numpy-trac-migration

numpy Trac to github issues migration
2 stars 3 forks source link

Poor precision using linalg.solve for certain matrices (migrated from Trac #1655) #3206

Closed thouis closed 12 years ago

thouis commented 12 years ago

Original ticket http://projects.scipy.org/numpy/ticket/1655 Reported 2010-10-30 by trac user zoof, assigned to atmention:pv.

There appears to be a bug in either the linear system solver or in the way than linalg computes LU decompositions. On a number of different distributions, using somewhat different versions of numpy, I get much better precision by inverting the matrix (linalg.inv) and multiplying than by either linalg.solve alone or linalg.cholesky in combination with linalg.solve. An example has been posted to: http://pastebin.com/KpXdTVh7

numpy 1.3.0 on Ubuntu Lucid numpy 1.5.0 on Arch numpy 1.5.1rc1 on Centos

thouis commented 12 years ago

Comment in Trac by trac user zoof, 2010-10-30

thouis commented 12 years ago

Comment in Trac by atmention:pv, 2010-10-30

Not a bug.

If you want right solve, do p=linalg.solve(Q.T,a)

thouis commented 12 years ago

Comment in Trac by trac user zoof, 2010-10-31

The help file indicates that it solves systems of the form A x = b. From what I understand is happening is that because my "b" is a row vector, it is solving x A = b. Either linalg.solve should throw an error when it gets a row vector or else the documentation should be amended.

thouis commented 12 years ago

Comment in Trac by atmention:pv, 2010-10-31

No, linalg.solve is always solving "A x = b", i.e., it does the left inverse. In your code, you assume it solves "x A = b", which it does not.