mitrevf / airhead-research

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

The V^t matrix returned by SVD.svd using COLT is not transposed #59

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Here there's a small snippet:

    public void testCompareSVDResults() {
        int m = 5, n = 4;

        Random generator = new Random();
        Matrix mat = new ArrayMatrix(m, n);

        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < n; ++j) {
                mat.set(i, j, Math.abs(generator.nextDouble()) % 100);
            }
        }

        List<SVD.Algorithm> algorithms = new LinkedList<SVD.Algorithm>();

        algorithms.add(SVD.Algorithm.COLT);
        algorithms.add(SVD.Algorithm.JAMA);
        algorithms.add(SVD.Algorithm.SVDLIBJ);

        for (Algorithm algorithm : algorithms) {
            System.out.println("Algorithm is: " + algorithm);

            Matrix[] svd = SVD.svd(mat, algorithm, Math.min(m, n));
            Matrix vt = svd[2];

            System.out.println("V^t is:");
            System.out.println(toString(vt));
        }
    }

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

Algorithm is: COLT
V^t is:
[[0.537,0.522,0.351,0.562]
[0.437,0.220,-0.869,-0.078]
[0.624,-0.130,0.343,-0.690]
[0.363,-0.814,-0.065,0.449]
]
Algorithm is: JAMA
V^t is:
[[0.537,0.437,0.624,0.363]
[0.522,0.220,-0.130,-0.814]
[0.351,-0.869,0.343,-0.065]
[0.562,-0.078,-0.690,0.449]
]
Algorithm is: SVDLIBJ
V^t is:
[[0.537,0.437,0.624,0.363]
[0.522,0.220,-0.130,-0.814]
[-0.351,0.869,-0.343,0.065]
[-0.562,0.078,0.690,-0.449]
]

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

I'm on Debian GNU/Linux, using a version obtained from the SVN repository on 14 
Jul 2010

Original issue reported on code.google.com by p.minerv...@gmail.com on 15 Jul 2010 at 10:36