A x = eig x
for both the eigenvector x
and the eigenvalue
eig
. However, since JMP works only on
double-precision numbers, only real eigenvalues will be
revealed. If complex eigenvalues are needed, use {@link
jmp.decomp.EigenvalueDecomposition EigenvalueDecomposition}.
The following example illustrates the basic usage:
double[] eigenvalueSolver(Matrix A, int n) { EigenvalueSolver solver = new PowerIteration(); Vector[] x = new Vector[n]; double[] eig = new double[n]; for (int i = 0; i < n; ++i) x[i] = new DenseVector(A.numRows()); try { solver.solve(A, eig, x); } catch (NotConvergedException e) { System.err.println("Eigenvalue solver did not converge"); System.err.println("Number of iterations = " + e.getIterations()); System.err.print("Reason = "); if (e.getReason() == NotConvergedException.BREAKDOWN) System.err.println("breakdown"); else if (e.getReason() == NotConvergedException.DIVERGENCE) System.err.println("divergence"); else if (e.getReason() == NotConvergedException.ITERATIONS) System.err.println("too many iterations"); } return eig; }
Note that the arrays holding the eigenvectors and the eigenvalues must be allocated. There are two solvers
Like the linear solvers, an iteration object can be attached. The main difference is that there are multiple states to monitor, that is, many eigenvalue/eigenvector pairs. Consequently, the iteration monitors are slightly different.
JMP uses eigenvalue transformations to generate methods such as the inverse iteration or Rayleigh quotient iteration. Use {@link jmp.iter.eig.EigenvalueSolver#setEigenvalueTransformation(jmp.iter.eig.EigenvalueTransformation) EigenvalueSolver.setEigenvalueTransformation} to set a new transformation. Transformations present include
As an example, using
LockedShiftInvertEigenvalueTransformation
with
PowerIteration
gives the inverse iteration, while
using ShiftInvertEigenvalueTransformation
gives the
Rayleigh quotient iteration. Also, note that
ShiftInvertEigenvalueTransformation
does not work
properly with Lanczos
.