bool EigenvalueDecomposition::decompose(const MatrixFloat &a){ n = a.getNumCols(); eigenvectors.resize(n,n); realEigenvalues.resize(n); complexEigenvalues.resize(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 (issymmetric) { for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { eigenvectors[i][j] = a[i][j]; } } // Tridiagonalize. tred2(); // Diagonalize. tql2(); } else { h.resize(n,n); ort.resize(n); for(int j = 0; j < n; j++) { for(int i = 0; i < n; i++) { h[i][j] = a[i][j]; } } // Reduce to Hessenberg form. orthes(); // Reduce Hessenberg to real Schur form. hqr2(); } return true; }
void eigen(int n, double *a, double *ev, double *work, int *ierr) { orthes(n, 1, n, a, work); hqr(n, 1, n, a, ev, ierr); }