I'm looking for non regression between Mathnet.Iridium and Mathnet.Numerics. Here is my code, using Mathnet.Numerics :
double[][] symJaggedArray = new double[5][];
symJaggedArray[0] = new double[] { 3, 0, 0, 0, 0 };
symJaggedArray[1] = new double[] { 0, 2, 4, 0, 0 };
symJaggedArray[2] = new double[] { 0, 4, 5, -4, 5 };
symJaggedArray[3] = new double[] { 0, 0, -4, -8, 12 };
symJaggedArray[4] = new double[] { 0, 0, 5, 12, -5 };
symDenseMatrix = DenseMatrix.OfArray(new Matrix(symJaggedArray).CopyToArray());// not optimal but it's not the point
Svd svd = new UserSvd(symDenseMatrix , true);
Matrix<double> recompo = svd.U().Multiply(svd.W()).Multiply(svd.VT());
When i compare recompo and the initial matrix, they are different. I found this difference when comparing each decomposition matrix with the previous implementation :
- U and singularValueDecomposition.LeftSingularVectors are equal
- W and singularValueDecomposition.S are equal
- VT and Matrix.Transpose(singulaValueDecomposition.RightSingularVectors) are different
Finally, recomposition with older API is correct.
MathNet.Numerics version used : Math.NET Numerics v2.5.0
So my question is : Where is my mistake when rebuilding initial matrix with the new API ?
RecompoMatrix =
- 3 0 0 0 0
- 0 -1.216846655456 2.83903817786199 1.4472680220698 2.89215520227421
- 0 -2.46695399700557 8.657344064164 0.92863757484644 -0.31963101527516
- 0 0.349540484418384 8.20515629935223 -2.26741625715781 -12.3049605878983
- 0 -0.402667067831389 -6.32914150795323 9.13315298351198 8.3884053064068