Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Found a test case where numeric.svd returns an incorrect decomposition #62

Open
corybarr opened this issue Dec 15, 2014 · 1 comment
Open

Comments

@corybarr
Copy link

//tested with numeric.js version 1.2.6

var countsMatrix = [[0,0,1,1,0,0,0,0,0],[0,0,0,0,0,1,0,0,1],[0,1,0,0,0,0,0,1,0],[0,0,0,0,0,0,1,0,1],[1,0,0,0,0,1,0,0,0],[1,1,1,1,1,1,1,1,1],[1,0,1,0,0,0,0,0,0],[0,0,0,0,0,0,1,0,1],[0,0,0,0,0,2,0,0,1],[1,0,1,0,0,0,0,1,0],[0,0,0,1,1,0,0,0,0]];

var svd = numeric.svd(countsMatrix);

var U = svd.U;
var UTranspose = numeric.transpose(U);

//U should be a unitary matrix, so transpose(U) * U should be the identity matrix:
//http://web.mit.edu/be.400/www/SVD/Singular_Value_Decomposition.htm

var shouldBeIdentity = numeric['*'](UTranspose, U);
//However, it isn't the identity matrix:
console.log(JSON.stringify(shouldBeIdentity));
@valette
Copy link

valette commented Jan 6, 2016

Same here:
svd works fine on this matrix:
M = [
[5, 0, 0],
[0, 1, 0],
[ 0, 0, 1]
]
https://jsfiddle.net/bwrkerqv/

but fails on that one (which is the same with switched columns/rows):
M = [
[1, 0, 0],
[0, 1, 0],
[ 0, 0, 5]
]
https://jsfiddle.net/vyvj1o9f/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants