[SciPy-user] null space of a matrix
Nils Wagner
nwagner at mecha.uni-stuttgart.de
Wed Jun 29 16:23:05 EDT 2005
On Wed, 29 Jun 2005 13:08:44 -0700
Robert Kern <rkern at ucsd.edu> wrote:
> Ryan Krauss wrote:
>> This is a completely trivial addition to Richard's
>>submission, but here
>> is the function I am using to implement the null
>>function if anyone
>> wants to copy and paste it into there own code:
>>
>> def null(A, eps=1e-15):
>> u, s, vh = scipy.linalg.svd(A)
>> null_mask = (s <= eps)
>> null_space = scipy.compress(null_mask, vh, axis=0)
>> return scipy.transpose(null_space)
>>
>> (this assumes you have already got an import scipy
>>somewhere in the file)
>> (It made more sense to me to return column vectors.)
>
> Point. You may also need to conjugate() that return
>value when you happen to be dealing with complex values;
>I'm not sure.
Robert,
Your exception is correct
from scipy import *
A = array(([1+0.1j,2,3],[1+0.1j,2,3],[1+0.1j,2+0j,3]))
u, s, vh = linalg.svd(A)
eps = 1.e-10
null_mask = (s <= eps)
null_space = compress(null_mask, vh, axis=0)
print dot(A,transpose(conjugate(null_space)))
print dot(A,transpose(null_space))
Nils
>
> --
> Robert Kern
> rkern at ucsd.edu
>
> "In the fields of hell where the grass grows high
> Are the graves of dreams allowed to die."
> -- Richard Harter
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
More information about the SciPy-User
mailing list