Package javajs.util
Class Eigen
java.lang.Object
javajs.util.Eigen
- All Implemented Interfaces:
EigenInterface
Eigenvalues and eigenvectors of a real matrix.
See javajs.api.EigenInterface() as well.
adapted by Bob Hanson from http://math.nist.gov/javanumerics/jama/ (public
domain); adding quaternion superimposition capability; removing
nonsymmetric reduction to Hessenberg form, which we do not need in Jmol.
Output is as a set of double[n] columns, but for the EigenInterface
we return them as V3[3] and float[3] (or double[3]) values.
Eigenvalues and eigenvectors are sorted from smallest to largest eigenvalue.
If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is diagonal and the eigenvector matrix V is orthogonal. I.e. A = V.times(D.times(V.transpose())) and V.times(V.transpose()) equals the identity matrix.
If A is not symmetric, then the eigenvalue matrix D is block diagonal with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues, lambda + i*mu, in 2-by-2 blocks, [lambda, mu; -mu, lambda]. The columns of V represent the eigenvectors in the sense that A*V = V*D, i.e. A.times(V) equals V.times(D). The matrix V may be badly conditioned, or even singular, so the validity of the equation A = V*D*inverse(V) depends upon V.cond().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
calc
(double[][] A) Check for symmetry, then construct the eigenvalue decompositionvoid
fillFloatArrays
(V3[] eigenVectors, float[] eigenValues) Specifically for 3x3 systems, returns eigenVectors as V3[3] and values as float[3]; sorted from smallest to largest value.double[]
return values sorted from smallest to largest value.float[][]
Transpose V and turn into floats; sorted from smallest to largest value.double[]
Return the imaginary parts of the eigenvaluesdouble[]
Return the real parts of the eigenvaluesset
(int n) setM
(double[][] m)
-
Constructor Details
-
Eigen
public Eigen()
-
-
Method Details
-
set
-
setM
- Specified by:
setM
in interfaceEigenInterface
-
getEigenvalues
public double[] getEigenvalues()return values sorted from smallest to largest value.- Specified by:
getEigenvalues
in interfaceEigenInterface
-
fillFloatArrays
Specifically for 3x3 systems, returns eigenVectors as V3[3] and values as float[3]; sorted from smallest to largest value.- Specified by:
fillFloatArrays
in interfaceEigenInterface
- Parameters:
eigenVectors
- returned vectorseigenValues
- returned values
-
getEigenvectorsFloatTransposed
public float[][] getEigenvectorsFloatTransposed()Transpose V and turn into floats; sorted from smallest to largest value.- Specified by:
getEigenvectorsFloatTransposed
in interfaceEigenInterface
- Returns:
- ROWS of eigenvectors f[0], f[1], f[2], etc.
-
calc
public void calc(double[][] A) Check for symmetry, then construct the eigenvalue decomposition- Parameters:
A
- Square matrix
-
getRealEigenvalues
public double[] getRealEigenvalues()Return the real parts of the eigenvalues- Returns:
- real(diag(D))
-
getImagEigenvalues
public double[] getImagEigenvalues()Return the imaginary parts of the eigenvalues- Returns:
- imag(diag(D))
-