KalebDark / redsvd

Automatically exported from code.google.com/p/redsvd
0 stars 0 forks source link

U and V have last column all zeros #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
>cat densa.txt
 1.5  0.0  2.5  2.5
 0.0  2.5  2.5  0.0
 1.5  0.0  2.5  1.0
 0.0  2.5  2.5  0.0
 0.0  2.5  2.5  0.0
2.
redsvd -i densa.txt -o densa -f dense -r 10
3.
>cat densa.U
-0.401793 +0.706597 -0.582481 +0.000000 
-0.486488 -0.308495 -0.038651 +0.000000 
-0.358540 +0.463912 +0.810083 +0.000000 
-0.486488 -0.308495 -0.038651 +0.000000 
-0.486488 -0.308495 -0.038651 +0.000000 
>cat densa.V
-0.165886 +0.472878 +0.409235 +0.000000 
-0.530701 -0.623149 -0.347478 +0.000000 
-0.807177 +0.164981 +0.334580 +0.000000 
-0.198253 +0.600711 -0.774494 +0.000000 

What is the expected output? What do you see instead?
First, I expected U to be 5 by 5. 
Tried same matrix in gnu octave, and the first 3 column match exactly, but the 
last one have values not zero:
octave-3.2.4:1> A=[1.5 0 2.5 2.5;0 2.5 2.5 0; 1.5 0 2.5 1.0; 0 2.5 2.5 0;0 2.5 
2.5 0]
A =

   1.50000   0.00000   2.50000   2.50000
   0.00000   2.50000   2.50000   0.00000
   1.50000   0.00000   2.50000   1.00000
   0.00000   2.50000   2.50000   0.00000
   0.00000   2.50000   2.50000   0.00000

octave-3.2.4:2> [u,s,v]=svd(A);
octave-3.2.4:3> u
u =

  -4.0179e-01   7.0660e-01   5.8248e-01   1.9052e-16  -3.8365e-20
  -4.8649e-01  -3.0849e-01   3.8651e-02   8.1650e-01  -1.2869e-16
  -3.5854e-01   4.6391e-01  -8.1008e-01  -3.1762e-17   3.8365e-20
  -4.8649e-01  -3.0849e-01   3.8651e-02  -4.0825e-01  -7.0711e-01
  -4.8649e-01  -3.0849e-01   3.8651e-02  -4.0825e-01   7.0711e-01

octave-3.2.4:4> v
v =

  -1.6589e-01   4.7288e-01  -4.0924e-01   7.6249e-01
  -5.3070e-01  -6.2315e-01   3.4748e-01   4.5750e-01
  -8.0718e-01   1.6498e-01  -3.3458e-01  -4.5750e-01
  -1.9825e-01   6.0071e-01   7.7449e-01   1.1102e-16

What version of the product are you using? On what operating system?
Ubuntu 12.04
redsvd 0.2.0

Please provide any additional information below.
I don't sure it is an issue, I didn't find any other information to let me know 
if this behavior is expected.

Original issue reported on code.google.com by hecha...@gmail.com on 27 Sep 2012 at 4:27

GoogleCodeExporter commented 8 years ago
Eigen version 3.1.1

Original comment by hecha...@gmail.com on 27 Sep 2012 at 4:37

GoogleCodeExporter commented 8 years ago
densa.txt is rank deficient.
U and V 's last column can have any number.
(A number X can have any number,where A*0=0)
So it's no problem.

if you want to get 5x5 matrix 
Just add dummy data on dens.V(and U) and add 0 dens.S ,

http://en.wikipedia.org/wiki/Singular_value_decomposition

Original comment by you.akir...@gmail.com on 3 Jun 2013 at 7:53