See NaturalNode/node-lapack#2
Using the following on matlab / octave:
A = [ 1, 2; 3, 4; 5, 6];
[u, s, v] = svd(A)
I obtain:
u =
-0.22985 0.88346 0.40825
-0.52474 0.24078 -0.81650
-0.81964 -0.40190 0.40825
s =
9.52552 0.00000
0.00000 0.51430
0.00000 0.00000
v =
-0.61963 -0.78489
-0.78489 0.61963
Now with the js implementation:
require('sylvester');
var A = $M([
[1, 2],
[3, 4],
[5, 6]
]);
var svd = A.svd();
console.log(JSON.stringify(svd));
I obtain nothing because it crashes:
/[...]/node_modules/sylvester/lib/node-sylvester
/matrix.js:60
var e = S.triu(1).unroll().norm();
^
TypeError: Cannot call method 'triu' of null
at Object.svdJs (/[...]/node_modules/sylvester
/lib/node-sylvester/matrix.js:60:15)
Error summary: it breaks because of a null value being returned by qrJs, which in turn starts with the R matrix being null at some point. That comes from identSize.
However, it's mostly just an issue notification. I personally needed to have reliable and fast svd, so I used SVDLIBC and bound it as a C++ module (see node-svd). You may look at SVDLIBC if you think it can help you with svd / qr processing.