You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Here is an example of inv that doesn't throw an error when dealing with singular matrix and return wrong results.
import numpy as np
import scipy as si
A=np.array([[1,2,3],[4,5,6],[7,8,9]])
b=np.array([15,15,15])
print np.dot(np.linalg.inv(A),b)
array([-32., 48., -24.] ## wrong result
np.linalg.solve(A,b) # the result of np.dot(np.linalg.inv(A),b) should be same as this.
array([-39., 63., -24.]) # correct result
It is necessary to say that scipy throws an error though.
np.dot(si.linalg.inv(A),b)
My numpy version is '1.9.2' and python 2.7.6.
The text was updated successfully, but these errors were encountered:
rasoolfa
changed the title
Singular matrix inverse does't throw error
Singular matrix inverse does't throw an error
Aug 7, 2015
Hi,
Here is an example of inv that doesn't throw an error when dealing with singular matrix and return wrong results.
import numpy as np
import scipy as si
A=np.array([[1,2,3],[4,5,6],[7,8,9]])
b=np.array([15,15,15])
print np.dot(np.linalg.inv(A),b)
array([-32., 48., -24.] ## wrong result
np.linalg.solve(A,b) # the result of np.dot(np.linalg.inv(A),b) should be same as this.
array([-39., 63., -24.]) # correct result
It is necessary to say that scipy throws an error though.
np.dot(si.linalg.inv(A),b)
My numpy version is '1.9.2' and python 2.7.6.
The text was updated successfully, but these errors were encountered: