Cleanup
This commit is contained in:
parent
5eb23c1985
commit
47f332a66c
@ -77,18 +77,19 @@ void jacobi_eigensolver(const arma::mat& A,
|
||||
|
||||
} while (max_offdiag >= eps && ++iterations < maxiter);
|
||||
|
||||
|
||||
// Get the diagonal of A
|
||||
arma::vec res = arma::diagvec(A_m);
|
||||
// Get the indeces of res in sorted order
|
||||
arma::uvec sorted_indeces = arma::sort_index(res);
|
||||
|
||||
eigenvalues.resize(res.n_elem);
|
||||
eigenvectors.resize(res.n_elem, res.n_elem);
|
||||
// The diagonal elements of A_m are the eigenvalues
|
||||
|
||||
// Set the eigenvalues and their corresponding vectors in order
|
||||
for (int i=0; i < res.n_elem; i++) {
|
||||
eigenvalues[i] = res[sorted_indeces[i]];
|
||||
eigenvectors.insert_cols(i, R.col(sorted_indeces[i]));
|
||||
}
|
||||
|
||||
converged = max_offdiag < eps;
|
||||
A_m.print();
|
||||
R.print();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user