scalanlp / breeze

Breeze is/was a numerical processing library for Scala.
https://www.scalanlp.org
Apache License 2.0
3.45k stars 693 forks source link

what does svd do? #802

Closed jimka2001 closed 3 years ago

jimka2001 commented 3 years ago

I was under the impression that the singular value decomposition of a square matrix would give me a (U,s,V) where U and V are inverses and s is the vector consisting of Eigenvalues. Is that the intent? Or am I hoping for too much?

It seems to me from testing the function, that at least sometimes U is the negative inverse of V. Is that intended to always be the case?

For example if M is the 1x1 matrix consisting of -4.034101137641814 then U is the 1x1 containing -1.0 and V is the 1x2 containing 1.0. Thus UV != I, consequently M^2 != U(D^2)V

Please help me understand what I should expect. Thanks.

dlwh commented 3 years ago

I mean, this is the result wolfram alpha gives: https://www.wolframalpha.com/input/?i=svd+%7B%7B-4.034101137641814%7D%7D Can you find an example where it's not consistent with wolfram alpha or numpy or something?