Package javajs.util

Class Eigen

java.lang.Object
javajs.util.Eigen
All Implemented Interfaces:
EigenInterface

public class Eigen extends Object implements 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 Details

    • Eigen

      public Eigen()
  • Method Details

    • set

      public Eigen set(int n)
    • setM

      public Eigen setM(double[][] m)
      Specified by:
      setM in interface EigenInterface
    • getEigenvalues

      public double[] getEigenvalues()
      return values sorted from smallest to largest value.
      Specified by:
      getEigenvalues in interface EigenInterface
    • fillFloatArrays

      public void 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.
      Specified by:
      fillFloatArrays in interface EigenInterface
      Parameters:
      eigenVectors - returned vectors
      eigenValues - returned values
    • getEigenvectorsFloatTransposed

      public float[][] getEigenvectorsFloatTransposed()
      Transpose V and turn into floats; sorted from smallest to largest value.
      Specified by:
      getEigenvectorsFloatTransposed in interface EigenInterface
      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))