/** * Matrix condition (2 norm) * * @return ratio of largest to smallest singular value. */ public final double cond() { return new SingularValueDecomposition(this).cond(); }
/** * Matrix rank * * @return effective numerical rank, obtained from SVD. */ public final int rank() { return new SingularValueDecomposition(this).rank(); }
/** * Two norm * * @return maximum singular value. */ public final double norm2() { return (new SingularValueDecomposition(this).norm2()); }
SingularValueDecomposition svd = new SingularValueDecomposition(d); double[][] u = svd.getU(); double[] lambda = svd.getSingularValues(); lambda[0] = FastMath.sqrt(Math.abs(lambda[0])); lambda[1] = FastMath.sqrt(Math.abs(lambda[1]));
double[][] ncmFil = cmFil.destroyToPopulationMatrix(); SingularValueDecomposition svd = new SingularValueDecomposition(ncmUnfil); double[] dia = svd.getSingularValues();
@Test public void testJamaCond() { double[][] condmat = { { 1., 3. }, { 7., 9. } }; SingularValueDecomposition svd = new SingularValueDecomposition(condmat); double[] singularvalues = svd.getSingularValues(); double cond = svd.cond(); double check = singularvalues[0] / singularvalues[Math.min(getRowDimensionality(condmat), getColumnDimensionality(condmat)) - 1]; assertEquals("Matrix condition.", cond, check, 0.); } }
@Test public void testJamaExample() { double[][] M = transpose(new double[][] { { 1., 2., 3., 4. }, { 5., 6., 7., 8. }, { 9., 10., 11., 12. } }); SingularValueDecomposition svd = new SingularValueDecomposition(M); // M = U * S * V^T double[][] M2 = times(svd.getU(), timesTranspose(svd.getS(), svd.getV())); assertTrue("Not a proper decomposition.", almostEquals(M, M2, 1e-14)); }
SingularValueDecomposition svd = new SingularValueDecomposition(mat); Matrix u = svd.getU(); double[] lambda = svd.getSingularValues(); for(int i = 0; i < tdim; i++) { lambda[i] = Math.sqrt(Math.abs(lambda[i]));
double[][] ncmFil = cmFil.destroyToPopulationMatrix(); SingularValueDecomposition svd = new SingularValueDecomposition(ncmUnfil); double[] dia = svd.getSingularValues();
SingularValueDecomposition svd = new SingularValueDecomposition(mat); double[][] u = svd.getU(); double[] lambda = svd.getSingularValues();
SingularValueDecomposition svd = new SingularValueDecomposition(mat); double[][] u = svd.getU(); double[] lambda = svd.getSingularValues();