SingularValueDecomposition implements java.io.Serializable { public double[] getSingularValues() { return s; } SingularValueDecomposition(Matrix arg); double cond(); Matrix getS(); double[] getSingularValues(); Matrix getU(); Matrix getV(); double norm2(); int rank(); @Override String toString();  }
@Test public void testMoreRows() { double[] singularValues = { 123.456, 2.3, 1.001, 0.999 }; int rows = singularValues.length + 2; int columns = singularValues.length; Random r = RandomUtils.getRandom(); SingularValueDecomposition svd = new SingularValueDecomposition(createTestMatrix(r, rows, columns, singularValues)); double[] computedSV = svd.getSingularValues(); assertEquals(singularValues.length, computedSV.length); for (int i = 0; i < singularValues.length; ++i) { assertEquals(singularValues[i], computedSV[i], 1.0e-10); } }
@Test public void testMoreColumns() { double[] singularValues = { 123.456, 2.3, 1.001, 0.999 }; int rows = singularValues.length; int columns = singularValues.length + 2; Random r = RandomUtils.getRandom(); SingularValueDecomposition svd = new SingularValueDecomposition(createTestMatrix(r, rows, columns, singularValues)); double[] computedSV = svd.getSingularValues(); assertEquals(singularValues.length, computedSV.length); for (int i = 0; i < singularValues.length; ++i) { assertEquals(singularValues[i], computedSV[i], 1.0e-10); } }