[SciPy-user] null space of a matrix
Ryan Krauss
ryanfedora at comcast.net
Wed Jun 29 16:45:25 EDT 2005
Thanks to Nils and Robert for catching the complex conjugate thing. I
am going to be working with complex matrices and not knowing that may
have caused me a bit of pain.
When you transpose a complex matrix in Matlab it always takes the
complex conjugate transpose. Is this desirable behavior for SciPy/Numeric?
Ryan
Nils Wagner wrote:
> 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
>
>
>
>
> _______________________________________________
> 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