2
$\begingroup$
A<-matrix(c(1,1,1,2,0,0,0,1,2,1,0,1,0,1,0,0,0,0,1,0,2,2,1,1,0,0,0, 
0,1,1,1,0,0,0,0,0,2,2,1,1), nrow=5,byrow = TRUE)
svd<-svd(A)
U<-svd$u
V<-svd$v
d<-svd$d

U%*%d%*%t(V)

Fairly basic question. By the definition of SVD, this matrix should recompose, but it doesn't. I'm clearly making a very stupid mistake here, but I don't understand where this function varies from the definition of SVD.

$\endgroup$
1
$\begingroup$

d are the singular values of M. you need to place d in a diagonal matrix:

enter image description here

U%*%diag(d) %*% t(V)
$\endgroup$
1
  • $\begingroup$ Ah yes it was something really stupid. Thank you. $\endgroup$ – Tanner Phillips Mar 12 '20 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.