[SciPy-user] null space of a matrix - correction

Ryan Krauss ryanfedora at comcast.net
Wed Jun 29 15:03:47 CDT 2005


Sorry, I meant Robert's submission.  I hope that doesn't confuse anyone 
trying to follow this thread.

Ryan Krauss wrote:

> This is a completely trivial addition to Robert'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.)
>
> Ryan
>
>
> Ryan Krauss wrote:
>
>> Thanks Robert.  This works very well.  You seem to always submit high 
>> quality input to the list.
>>
>> Ryan
>>
>> Robert Kern wrote:
>>
>>> Ryan Krauss wrote:
>>>
>>>> This is probably a Numeric question, but is there an easy way to 
>>>> find the null space of a matrix in SciPy?
>>>
>>>
>>>
>>>
>>> The SVD is one way.
>>>
>>> u, s, vh = linalg.svd(A)
>>> null_mask = (s <= eps)
>>> null_space = compress(null_mask, vh, axis=0)
>>>
>>> The rows in null_space span the null space of A.
>>>
>>
>> _______________________________________________
>> SciPy-user mailing list
>> SciPy-user at scipy.net
>> http://www.scipy.net/mailman/listinfo/scipy-user
>>
>
> _______________________________________________
> 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