Connecting Tech Pros Worldwide Help | Site Map

SVD question

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 18th, 2006, 12:05 AM
smritibhagat@gmail.com
Guest
 
Posts: n/a
Default SVD question

Hi!
I have been trying to figure this out, and need help...
How do I compute an orthogonal complement of a matrix using SVD?
Is there a python lib function or code that does this?
Thanks!


  #2  
Old March 18th, 2006, 12:25 AM
Robert Kern
Guest
 
Posts: n/a
Default Re: SVD question

smritibhagat@gmail.com wrote:[color=blue]
> Hi!
> I have been trying to figure this out, and need help...
> How do I compute an orthogonal complement of a matrix using SVD?[/color]

On the chance that this is homework, I will only point out that Golub and van
Loan's book _Matrix Computations_ is essential reading if you are doing, well,
matrix computations.
[color=blue]
> Is there a python lib function or code that does this?[/color]

numpy has SVD.

http://numeric.scipy.org

--
Robert Kern
robert.kern@gmail.com

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

  #3  
Old March 18th, 2006, 12:55 AM
smritibhagat@gmail.com
Guest
 
Posts: n/a
Default Re: SVD question

Hi Robert!
Oh! Its not a homework problem...
I read the Golub book, it tells me what an orthogonal complement is,
however, I cannot understand how I can code it.
I know about svd from numpy's mlab, but I what I want to know is how
can I compute an orthogonal complement, using SVD or otherwise.
Thanks for the prompt reply :)

  #4  
Old March 18th, 2006, 02:05 AM
Robert Kern
Guest
 
Posts: n/a
Default Re: SVD question

smritibhagat@gmail.com wrote:[color=blue]
> Hi Robert!
> Oh! Its not a homework problem...
> I read the Golub book, it tells me what an orthogonal complement is,
> however, I cannot understand how I can code it.
> I know about svd from numpy's mlab, but I what I want to know is how
> can I compute an orthogonal complement, using SVD or otherwise.[/color]

Assuming A is an array with the vectors as columns and has shape (m, n), then
the null space of A (= the orthogonal complement of the vectors assuming that
the set of vectors is linearly independent):

In [231]: A
Out[231]:
array([[ 0., 1.],
[ 1., 1.],
[ 2., 1.],
[ 3., 1.]])

In [232]: m, n = A.shape

In [233]: u, s, vh = numpy.linalg.svd(A)

In [234]: dot(transpose(u[:, n:]), A)
Out[234]:
array([[ 0.00000000e+00, -1.11022302e-16],
[ -1.42247325e-16, -5.65519853e-16]])

In [235]: ortho_complement = u[:, n:]

In [236]: ortho_complement
Out[236]:
array([[-0.38578674, -0.38880405],
[ 0.22458489, 0.80595386],
[ 0.70819044, -0.44549557],
[-0.54698859, 0.02834576]])

--
Robert Kern
robert.kern@gmail.com

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

  #5  
Old March 18th, 2006, 03:15 PM
smritibhagat@gmail.com
Guest
 
Posts: n/a
Default Re: SVD question

Thanks Robert!
I was using mlab's svd function, which returns an mxn matrix for u, and
hence was unable to see how to compute the orthogonal complement!
I realize that numpy's svd gives the mxm matrix!
Thanks again.
-Smriti

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.