mitrevf / airhead-research

Automatically exported from code.google.com/p/airhead-research
0 stars 0 forks source link

svd.jar does not always produce correct results #66

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm aware that this project did not port svdlibj, but as you provide a command 
line interface and I do not know how to contact the original authors I am 
reporting this here.

What steps will reproduce the problem?

1. Create the following dense matrix:

12 9
1 0 0 1 0 0 0 0 0
1 0 1 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0
0 1 1 0 1 0 0 0 0
0 1 1 2 0 0 0 0 0
0 1 0 0 1 0 0 0 0
0 1 0 0 1 0 0 0 0
0 0 1 1 0 0 0 0 0
0 1 0 0 0 0 0 0 1
0 0 0 0 0 1 1 1 0
0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 1 1

2. Run svd.jar:

$ java -jar svd.jar -d 2 -r dt test.mat

What is the expected output? What do you see instead?

The nine singular values ought to be [3.34 2.54 2.35 1.64 1.50 1.31 0.85 0.56 
0.36], but unless the reduced dimensionality is 1, 3 or 9 you get different 
values. Eg for 2 the singular values are [2.41 3.01] and for 4 they are [2.02 
2.28 1.29 2.00]. 

libsvdc returns the correct singular values for this matrix for all dimensions.

What version of the product are you using? On what operating system?

svd.jar (May 21, 2010)
Mac OS X 10.6.4
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)

Please provide any additional information below.

Note that the matrix is the same one used in the DeerwesterTest included with 
svdlibj. If you modify the dimensionality in that test you get the same 
incorrect results.

Original issue reported on code.google.com by b...@sussex.ac.uk on 26 Aug 2010 at 2:24

GoogleCodeExporter commented 9 years ago
I have another example, hope it helps:

What steps will reproduce the problem?
1. Create a matrix file (cluto format) containing:
5 7
1 1 0 0 0 0 1
0 1 1 0 0 0 0
1 0 0 0 0 0 0
0 0 0 1 1 1 0
0 0 0 1 0 1 1

2. Run the following Java code:
Matrix[] result = SVD.svd(new File("samplematrix.cluto"), Algorithm.SVDLIBJ, 
Format.CLUTO_DENSE, 2);
Matrix U = result[0];
Matrix S = result[1];
Matrix Vt = result[2];
Matrix C = Matrices.multiply(S, Vt);
MatrixIO.writeMatrix(C, new File("c.cluto"), Format.CLUTO_DENSE);

What is the expected output? What do you see instead?
The expected output is:
2 5
0.89453775 0.27084422 0.20789784 1.3732798 1.5811776 
-1.4221323 -0.8210684 -0.52053654 0.8210684 0.3005319

The output was:
2 5
0.13197954 0.8717977 1.0037771 0.56787837 0.17193973 
0.542207 0.19846153 -0.93913 -0.542207 -0.34374544 

What version of the product are you using? On what operating system?
I am using svd.jar (May 2010) on Ubuntu Linux 10.04

Please provide any additional information below.
I've also checked the same code with SVDLIBC and it worked fine.

Original comment by alpgar...@gmail.com on 16 Feb 2011 at 6:32

Attachments: