/** * 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); }
/** * 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); }
/** * 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); }
SpecializedOps.addIdentity(A,M,-eigenvalue); SpecializedOps.addIdentity(A,M,-eigenvalue); } else { SpecializedOps.addIdentity(A,M,-eigenvalue);
SpecializedOps.addIdentity(A,M,-eigenvalue); SpecializedOps.addIdentity(A,M,-eigenvalue); } else { SpecializedOps.addIdentity(A,M,-eigenvalue);
SpecializedOps.addIdentity(A,M,-eigenvalue); SpecializedOps.addIdentity(A,M,-eigenvalue); } else { SpecializedOps.addIdentity(A,M,-eigenvalue);
/** * Computes the most dominant eigen vector of A using an inverted shifted matrix. * The inverted shifted matrix is defined as <b>B = (A - αI)<sup>-1</sup></b> and * can converge faster if α is chosen wisely. * * @param A An invertible square matrix matrix. * @param alpha Shifting factor. * @return If it converged or not. */ public boolean computeShiftInvert( DenseMatrix64F A , double alpha ) { initPower(A); LinearSolver solver = LinearSolverFactory.linear(A.numCols); SpecializedOps.addIdentity(A,B,-alpha); solver.setA(B); boolean converged = false; for( int i = 0; i < maxIterations && !converged; i++ ) { solver.solve(q0,q1); double s = NormOps.normPInf(q1); CommonOps.divide(s,q1,q2); converged = checkConverged(A); } return converged; }
/** * Computes the most dominant eigen vector of A using an inverted shifted matrix. * The inverted shifted matrix is defined as <b>B = (A - αI)<sup>-1</sup></b> and * can converge faster if α is chosen wisely. * * @param A An invertible square matrix matrix. * @param alpha Shifting factor. * @return If it converged or not. */ public boolean computeShiftInvert( DenseMatrix64F A , double alpha ) { initPower(A); LinearSolver solver = LinearSolverFactory.linear(A.numCols); SpecializedOps.addIdentity(A,B,-alpha); solver.setA(B); boolean converged = false; for( int i = 0; i < maxIterations && !converged; i++ ) { solver.solve(q0,q1); double s = NormOps.normPInf(q1); CommonOps.divide(q1,s,q2); converged = checkConverged(A); } return converged; }
SpecializedOps.addIdentity(U, U, c0); CommonOps.addEquals(U, c2, As_2); CommonOps.addEquals(U, c4, As_4); SpecializedOps.addIdentity(temp, temp, c6); CommonOps.addEquals(temp, c8, As_2); CommonOps.addEquals(temp, c10, As_4); SpecializedOps.addIdentity(V, V, c1); CommonOps.addEquals(V, c3, As_2); CommonOps.addEquals(V, c5, As_4); SpecializedOps.addIdentity(temp, temp, c7); CommonOps.addEquals(temp, c9, As_2); CommonOps.addEquals(temp, c11, As_4);
SpecializedOps.addIdentity(U, U, c0); CommonOps.addEquals(U, c2, As_2); CommonOps.addEquals(U, c4, As_4); SpecializedOps.addIdentity(temp, temp, c6); CommonOps.addEquals(temp, c8, As_2); CommonOps.addEquals(temp, c10, As_4); SpecializedOps.addIdentity(V, V, c1); CommonOps.addEquals(V, c3, As_2); CommonOps.addEquals(V, c5, As_4); SpecializedOps.addIdentity(temp, temp, c7); CommonOps.addEquals(temp, c9, As_2); CommonOps.addEquals(temp, c11, As_4);
/** * Computes the most dominant eigen vector of A using an inverted shifted matrix. * The inverted shifted matrix is defined as <b>B = (A - αI)<sup>-1</sup></b> and * can converge faster if α is chosen wisely. * * @param A An invertible square matrix matrix. * @param alpha Shifting factor. * @return If it converged or not. */ public boolean computeShiftInvert( DenseMatrix64F A , double alpha ) { initPower(A); LinearSolver solver = LinearSolverFactory.linear(A.numCols); SpecializedOps.addIdentity(A,B,-alpha); solver.setA(B); boolean converged = false; for( int i = 0; i < maxIterations && !converged; i++ ) { solver.solve(q0,q1); double s = NormOps.normPInf(q1); CommonOps.divide(q1,s,q2); converged = checkConverged(A); } return converged; }
@Override public void solve(DenseMatrix64F b, DenseMatrix64F x) { if (alpha == 0) { linearSolverAlpha0.setA(this.A); linearSolverAlpha0.solve(b, x); } else { tempMatrix1.reshape(A.getNumRows(), A.getNumRows()); CommonOps.multTransB(A, A, tempMatrix1); SpecializedOps.addIdentity(tempMatrix1, tempMatrix1, alpha * alpha); linearSolver.setA(tempMatrix1); tempMatrix2.reshape(A.getNumCols(), b.getNumCols()); linearSolver.solve(b, tempMatrix2); CommonOps.multTransA(A, tempMatrix2, x); } }
@Override public void invert(DenseMatrix64F A_inv) { if (alpha == 0) { linearSolverAlpha0.setA(this.A); linearSolverAlpha0.invert(A_inv); } else { tempMatrix1.reshape(A.getNumRows(), A.getNumRows()); CommonOps.multTransB(A, A, tempMatrix1); SpecializedOps.addIdentity(tempMatrix1, tempMatrix1, alpha * alpha); linearSolver.setA(tempMatrix1); tempMatrix2.reshape(tempMatrix1.getNumRows(), tempMatrix1.getNumCols()); linearSolver.invert(tempMatrix2); CommonOps.multTransA(A, tempMatrix2, A_inv); } }
SpecializedOps.addIdentity(Ns, Ns, 1.0);
SpecializedOps.addIdentity(Ns, Ns, 1.0);