示例#1
0
  /**
   * Computes the most dominant eigen vector of A using an inverted shifted matrix. The inverted
   * shifted matrix is defined as <b>B = (A - &alpha;I)<sup>-1</sup></b> and can converge faster if
   * &alpha; 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;
  }
示例#2
0
  /**
   * Computes the most dominant eigen vector of A using a shifted matrix. The shifted matrix is
   * defined as <b>B = A - &alpha;I</b> and can converge faster if &alpha; is chosen wisely. In
   * general it is easier to choose a value for &alpha; 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);
  }