/** * Takes a matrix and splits it into a set of row or column vectors. * * @param A original matrix. * @param column If true then column vectors will be created. * @return Set of vectors. */ public static DenseMatrix64F[] splitIntoVectors( RowD1Matrix64F A , boolean column ) { int w = column ? A.numCols : A.numRows; int M = column ? A.numRows : 1; int N = column ? 1 : A.numCols; int o = Math.max(M,N); DenseMatrix64F[] ret = new DenseMatrix64F[w]; for( int i = 0; i < w; i++ ) { DenseMatrix64F a = new DenseMatrix64F(M,N); if( column ) subvector(A,0,i,o,false,0,a); else subvector(A,i,0,o,true,0,a); ret[i] = a; } return ret; }
/** * Computes the most dominant eigen vector of A using a shifted matrix. * The shifted matrix is defined as <b>B = A - αI</b> and can converge faster * if α is chosen wisely. In general it is easier to choose a value for α * that will converge faster with the shift-invert strategy than this one. * * @param A The matrix. * @param alpha Shifting factor. * @return If it converged or not. */ public boolean computeShiftDirect( DenseMatrix64F A ,double alpha) { SpecializedOps.addIdentity(A,B,-alpha); return computeDirect(B); }
@Override public double quality() { return Math.abs(SpecializedOps.diagProd(decomp.getL())); }
@Override public double quality() { // even those it is transposed the diagonal elements are at the same // elements return SpecializedOps.qualityTriangular(true, QR); }
public static double quality( DenseMatrix64F orig , DenseMatrix64F U , DenseMatrix64F W , DenseMatrix64F Vt ) { // foundA = U*W*Vt DenseMatrix64F UW = new DenseMatrix64F(U.numRows,W.numCols); CommonOps.mult(U,W,UW); DenseMatrix64F foundA = new DenseMatrix64F(UW.numRows,Vt.numCols); CommonOps.mult(UW,Vt,foundA); double normA = NormOps.normF(foundA); return SpecializedOps.diffNormF(orig,foundA)/normA; }
public DenseMatrix64F getPivot( DenseMatrix64F pivot ) { return SpecializedOps.pivotMatrix(pivot, this.pivot, LU.numRows, false); }
SpecializedOps.copyChangeRow(pivot,b,x); } else { throw new IllegalArgumentException("Current doesn't support using the same matrix instance");
SimpleMatrix Q_k = SimpleMatrix.wrap(SpecializedOps.createReflector(this.u,nu/tau)); U = U.mult(Q_k); B = Q_k.mult(B);
@Override public double quality() { return SpecializedOps.qualityTriangular(true, R); }
public static double quality( DenseMatrix64F orig , DenseMatrix64F U , DenseMatrix64F W , DenseMatrix64F Vt ) { SimpleMatrix _U = SimpleMatrix.wrap(U); SimpleMatrix _W = SimpleMatrix.wrap(W); SimpleMatrix _Vt = SimpleMatrix.wrap(Vt); SimpleMatrix foundA = _U.mult(_W).mult(_Vt); return SpecializedOps.diffNormF(orig,foundA.getMatrix())/foundA.normF(); }
public DenseMatrix64F getPivot( DenseMatrix64F pivot ) { return SpecializedOps.pivotMatrix(pivot, this.pivot, LU.numRows, false); }
SpecializedOps.copyChangeRow(pivot,b,x); } else { throw new IllegalArgumentException("Current doesn't support using the same matrix instance");
SimpleMatrix Q_k = SimpleMatrix.wrap(SpecializedOps.createReflector(this.u,nu/tau)); U = U.mult(Q_k); B = Q_k.mult(B);
/** * Computes the SVD of A and extracts the essential/fundamental matrix from its null space */ private boolean process(DenseMatrix64F A) { if( !svdNull.decompose(A) ) return false; // extract the two singular vectors // no need to sort by singular values because the two automatic null spaces are being sampled svdNull.getV(V,false); SpecializedOps.subvector(V, 0, 7, 9, false, 0, F1); SpecializedOps.subvector(V, 0, 8, 9, false, 0, F2); return true; }
/** * Computes the most dominant eigen vector of A using a shifted matrix. * The shifted matrix is defined as <b>B = A - αI</b> and can converge faster * if α is chosen wisely. In general it is easier to choose a value for α * that will converge faster with the shift-invert strategy than this one. * * @param A The matrix. * @param alpha Shifting factor. * @return If it converged or not. */ public boolean computeShiftDirect( DenseMatrix64F A ,double alpha) { SpecializedOps.addIdentity(A,B,-alpha); return computeDirect(B); }
@Override public double quality() { return SpecializedOps.qualityTriangular(QR); }
public static double quality( DenseMatrix64F orig , DenseMatrix64F U , DenseMatrix64F W , DenseMatrix64F Vt ) { SimpleMatrix _U = SimpleMatrix.wrap(U); SimpleMatrix _W = SimpleMatrix.wrap(W); SimpleMatrix _Vt = SimpleMatrix.wrap(Vt); SimpleMatrix foundA = _U.mult(_W).mult(_Vt); return SpecializedOps.diffNormF(orig,foundA.getMatrix())/foundA.normF(); }
@Override public double quality() { return Math.abs(SpecializedOps.diagProd(decomp.getL())); }
public DenseMatrix64F getPivot( DenseMatrix64F pivot ) { return SpecializedOps.pivotMatrix(pivot, this.pivot, LU.numRows, false); }
SpecializedOps.copyChangeRow(pivot,b,x); } else { throw new IllegalArgumentException("Current doesn't support using the same matrix instance");