We are currently evaluating OjAlgo library as a replacement to commons-math library for SVD computation. For below input, there is a difference between singular values of OjAlgo and commons-math.
I have worked with OjAlgo 47.1.2 and with latest code from develop branch, still the output is same. Is this a bug
double[][] olsColumns = { { 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
{ 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 },
{ 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 },
{ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }, { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0 },
{ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 },
{ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 }, { 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
{ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 }, { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 },
{ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0 } };
double[] observationVector = {26.0, 12.0, 9.0, 18.0, 16.0, 17.0, 24.0, 32.0, 30.0, 21.0, 16.0, 12.0, 21.0, 16.0};
//OjAlgo
final PrimitiveDenseStore tmpOriginal = PrimitiveDenseStore.FACTORY.rows(olsColumns);
SingularValue<Double> tmpSVD = SingularValue.make(tmpOriginal);
tmpSVD.decompose(tmpOriginal);
double[] singularValues = tmpSVD.getSingularValues().toRawCopy1D();
System.out.println("Singular values" + Arrays.toString(singularValues));
//Commons-Math
RealMatrix newPredM = new Array2DRowRealMatrix(olsColumns);
SingularValueDecomposition svd = new SingularValueDecomposition(newPredM);
System.out.println("Singular values" + Arrays.toString(svd.getSingularValues()));
OjAlgo output Singular values[4.000000000000001, 1.4142135623730956, 1.4142135623730951, 1.4142135623730951, 1.4142135623730951, 1.4142135623730945, 1.4142135623730945, 4.566099776030485E-16]
Commons-Math output Singular values[4.000000000000001, 1.4142135623730951, 1.4142135623730951, 1.414213562373095, 1.414213562373095, 1.4142135623730945, 1.4142135623730945, 0.0]
Is there a way to make the last value of OjAlgo singular values i.e.,4.566099776030485E-16 as 0.0