[R] La.svd of a symmetric matrix

David Winsemius dwinsemius at comcast.net
Sat Jan 16 17:28:12 CET 2010


On Jan 16, 2010, at 8:10 AM, Stefano Sofia wrote:

> Dear R list users,
> the singluar value decomposition of a symmetric matrix M is UDV^(T),  
> where U = V.
> La.svd(M) gives as output three elements: the diagonal of D and the  
> two orthogonal matrices u and vt (which is already the transpose of  
> v).
>
> I noticed that the transpose of vt is not exactly u. Why is that?

Well, it would have been u and t(vt) that you might have been thinking  
should be equal. And they are equal up to an orthonormal transformation.

 > samp <-sample(1:100, 9)
 > M <- matrix(samp,3)+matrix(samp,3,byrow=T)
 >  all.equal( La.svd(M)$vt *c(1,-1,1) , t(La.svd(M)$u) )
[1] "Mean relative difference: 0.6169069"
 > M
      [,1] [,2] [,3]
[1,]   66  101   95
[2,]  101   76  104
[3,]   95  104   26
 > La.svd(M)$vt
            [,1]       [,2]        [,3]
[1,] -0.5853410 -0.6225788 -0.51939540
[2,]  0.2966601  0.4317295 -0.85182300
[3,]  0.7545652 -0.6526908 -0.06801466
 >  t(La.svd(M)$u)
            [,1]       [,2]        [,3]
[1,] -0.5853410 -0.6225788 -0.51939540
[2,] -0.2966601 -0.4317295  0.85182300
[3,] -0.7545652  0.6526908  0.06801466
 >  all.equal( La.svd(M)$vt *c(1,-1,-1) , t(La.svd(M)$u) )
[1] TRUE

And, of course, numerical accuracy gets in the way of exact equality:
 >   La.svd(M)$vt *c(1,-1,-1) == t(La.svd(M)$u)
       [,1]  [,2]  [,3]
[1,] FALSE FALSE FALSE
[2,] FALSE FALSE FALSE
[3,]  TRUE FALSE  TRUE

-- 
David.

>
> thank you for your attention and your help
> Stefano
>
> AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu?  
> contenere informazioni confidenziali, pertanto ? destinato solo a  
> persone autorizzate alla ricezione. I messaggi di posta elettronica  
> per i client di Regione Marche possono contenere informazioni  
> confidenziali e con privilegi legali. Se non si ? il destinatario  
> specificato, non leggere, copiare, inoltrare o archiviare questo  
> messaggio. Se si ? ricevuto questo messaggio per errore, inoltrarlo  
> al mittente ed eliminarlo completamente dal sistema del proprio  
> computer. Ai sensi dell'art. 6 della  DGR n. 1394/2008 si segnala  
> che, in caso di necessit? ed urgenza, la risposta al presente  
> messaggio di posta elettronica pu? essere visionata da persone  
> estranee al destinatario.
> IMPORTANT NOTICE: This e-mail message is intended to be received  
> only by persons entitled to receive the confidential information it  
> may contain. E-mail messages to clients of Regione Marche may  
> contain information that is confidential and legally privileged.  
> Please do not read, copy, forward, or store this message unless you  
> are an intended recipient of it. If you have received this message  
> in error, please forward it to the sender and delete it completely  
> from your computer system.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list