[SciPy-user] null space of a matrix

Robert Kern rkern at ucsd.edu
Wed Jun 29 16:08:44 EDT 2005


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 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




More information about the SciPy-User mailing list