public EigenvalueDecomposition(double[][] A){
  n=A.length;
  V=new double[n][n];
  d=new double[n];
  e=new double[n];
  issymmetric=true;
  for (int j=0; (j < n) && issymmetric; j++) {
    for (int i=0; (i < n) && issymmetric; i++) {
      issymmetric=(A[i][j] == A[j][i]);
      if (Double.isNaN(A[i][j])) {
        throw new IllegalArgumentException("NaN in EigenvalueDecomposition!");
      }
      if (Double.isInfinite(A[i][j])) {
        throw new IllegalArgumentException("+-inf in EigenvalueDecomposition!");
      }
    }
  }
  if (issymmetric) {
    for (int i=0; i < n; i++) {
      System.arraycopy(A[i],0,V[i],0,n);
    }
    tred2();
    tql2();
  }
 else {
    H=new double[n][n];
    ort=new double[n];
    for (int j=0; j < n; j++) {
      for (int i=0; i < n; i++) {
        H[i][j]=A[i][j];
      }
    }
    orthes();
    hqr2();
  }
}

public EigenvalueDecomposition ( double [ ] [ ] A ) { n = A . length ; V = new double [ n ] [ n ] ; d = new double [ n ] ; e = new double [ n ] ; issymmetric = true ; for ( int j = 0 ; ( j < n ) && issymmetric ; j ++ ) { for ( int i = 0 ; ( i < n ) && issymmetric ; i ++ ) { issymmetric = ( A [ i ] [ j ] == A [ j ] [ i ] ) ; if ( Double . isNaN ( A [ i ] [ j ] ) ) { throw new IllegalArgumentException ( "NaN in EigenvalueDecomposition!" ) ; } if ( Double . isInfinite ( A [ i ] [ j ] ) ) { throw new IllegalArgumentException ( "+-inf in EigenvalueDecomposition!" ) ; } } } if ( issymmetric ) { for ( int i = 0 ; i < n ; i ++ ) { System . arraycopy ( A [ i ] , 0 , V [ i ] , 0 , n ) ; } tred2 ( ) ; tql2 ( ) ; } else { H = new double [ n ] [ n ] ; ort = new double [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { for ( int i = 0 ; i < n ; i ++ ) { H [ i ] [ j ] = A [ i ] [ j ] ; } } orthes ( ) ; hqr2 ( ) ; } }
check for symmetry , then construct the eigenvalue decomposition
