/** * Returns the rank of the decomposed matrix. * * @see SingularOps#rank(org.ejml.interfaces.decomposition.SingularValueDecomposition, double) * * @return The matrix's rank */ public int rank() { return SingularOps.rank(svd,10.0* UtilEjml.EPS); }
/** * The nullity of the decomposed matrix. * * @see SingularOps#nullity(org.ejml.interfaces.decomposition.SingularValueDecomposition, double) * * @return The matrix's nullity */ public int nullity() { return SingularOps.nullity(svd,10.0*UtilEjml.EPS); }
/** * Computes the null space from an SVD. For more information see {@link SingularOps#nullSpace}. * @return Null space vector. */ public SimpleMatrix nullSpace() { // TODO take advantage of the singular values being ordered already return SimpleMatrix.wrap(SingularOps.nullSpace(svd,null,tol)); }
/** * Extracts the rank of a matrix using a preexisting decomposition and default threshold. * * @see #singularThreshold(org.ejml.interfaces.decomposition.SingularValueDecomposition) * * @param svd A precomputed decomposition. Not modified. * @return The rank of the decomposed matrix. */ public static int rank( SingularValueDecomposition svd ) { double threshold = singularThreshold(svd); return rank(svd,threshold); }
/** * Extracts the nullity of a matrix using a preexisting decomposition and default threshold. * * @see #singularThreshold(org.ejml.interfaces.decomposition.SingularValueDecomposition) * * @param svd A precomputed decomposition. Not modified. * @return The nullity of the decomposed matrix. */ public static int nullity( SingularValueDecomposition svd ) { double threshold = singularThreshold(svd); return nullity(svd, threshold); }
/** * Computes the decomposition from an essential matrix. * * @param E essential matrix */ public void decompose( DenseMatrix64F E ) { if( svd.inputModified() ) { E_copy.set(E); E = E_copy; } if( !svd.decompose(E)) throw new RuntimeException("Svd some how failed"); U = svd.getU(U,false); V = svd.getV(V,false); S = svd.getW(S); SingularOps.descendingOrder(U,false,S,V,false); decompose(U, S, V); }
SingularOps.descendingOrder(U,false,svdU.getSingularValues(),svdU.numberOfSingularValues(),null,false); int rank = SingularOps.rank(svdU, 1e-13); Up.reshape(U.numRows,rank); CommonOps.extract(U,0,U.numRows,0,Up.numCols,Up,0,0); SingularOps.nullVector(svdV,true,xp);
public SimpleSVD( DenseMatrix64F mat , boolean compact ) { this.mat = mat; svd = DecompositionFactory.svd(mat.numRows,mat.numCols,true,true,compact); if( !svd.decompose(mat) ) throw new RuntimeException("Decomposition failed"); U = (T)SimpleMatrix.wrap(svd.getU(null,false)); W = (T)SimpleMatrix.wrap(svd.getW(null)); V = (T)SimpleMatrix.wrap(svd.getV(null,false)); // order singular values from largest to smallest SingularOps.descendingOrder(U.getMatrix(),false,W.getMatrix(),V.getMatrix(),false); tol = SingularOps.singularThreshold(svd); }
checkSvdMatrixSize(U, tranU, W, V, tranV); swapRowOrCol(V, tranV, i, bigIndex); swapRowOrCol(U, tranU, i, bigIndex);
swapRowOrCol(V, tranV, i, bigIndex); swapRowOrCol(U, tranU, i, bigIndex);
DenseMatrix64F V = svd.getV(null,false); SingularOps.descendingOrder(null,false,singularValues,3,V,false);
checkSvdMatrixSize(U, tranU, W, V, tranV); swapRowOrCol(V, tranV, i, bigIndex); swapRowOrCol(U, tranU, i, bigIndex);
swapRowOrCol(V, tranV, i, bigIndex); swapRowOrCol(U, tranU, i, bigIndex);
SingularOps.descendingOrder(null, false, W, V_t, true);
/** * Returns the rank of the decomposed matrix. * * @see SingularOps#rank(org.ejml.interfaces.decomposition.SingularValueDecomposition, double) * * @return The matrix's rank */ public int rank() { return SingularOps.rank(svd,10.0* UtilEjml.EPS); }
checkSvdMatrixSize(U, tranU, W, V, tranV); swapRowOrCol(V, tranV, i, bigIndex); swapRowOrCol(U, tranU, i, bigIndex);
/** * The nullity of the decomposed matrix. * * @see SingularOps#nullity(org.ejml.interfaces.decomposition.SingularValueDecomposition, double) * * @return The matrix's nullity */ public int nullity() { return SingularOps.nullity(svd,10.0*UtilEjml.EPS); }
/** * Computes the null space from an SVD. For more information see {@link SingularOps#nullSpace}. * @return Null space vector. */ public SimpleMatrix nullSpace() { // TODO take advantage of the singular values being ordered already return SimpleMatrix.wrap(SingularOps.nullSpace(svd,null,UtilEjml.EPS)); }
swapRowOrCol(V, tranV, i, bigIndex); swapRowOrCol(U, tranU, i, bigIndex);
public SimpleSVD( DenseMatrix64F mat , boolean compact ) { this.mat = mat; svd = DecompositionFactory.svd(mat.numRows,mat.numCols,true,true,compact); if( !svd.decompose(mat) ) throw new RuntimeException("Decomposition failed"); U = (T)SimpleMatrix.wrap(svd.getU(null,false)); W = (T)SimpleMatrix.wrap(svd.getW(null)); V = (T)SimpleMatrix.wrap(svd.getV(null,false)); // order singular values from largest to smallest SingularOps.descendingOrder(U.getMatrix(),false,W.getMatrix(),V.getMatrix(),false); }