24 eigs_sym(
const CSparse &A, RArpack::EigType t,
size_t neig, CTensor *eigenvectors,
25 const CTensor::elt_t *initial_guess)
27 size_t n = A.columns();
35 return eigs_sym(full(A), t, neig, eigenvectors, initial_guess);
39 std::cerr <<
"In eigs(): Can only compute eigenvalues of square matrices.";
43 RArpack data(ndouble, t, neig);
46 data.set_start_vector((
const double *)initial_guess);
48 size_t bytes = ndouble *
sizeof(double);
49 while (data.update() < RArpack::Finished) {
50 CTensor x(n, (CTensor::elt_t *)data.get_x_vector());
51 CTensor y = mmult(A, x);
52 memcpy(data.get_y_vector(), (
const double *)x.pointer(), bytes);
54 if (data.get_status() == RArpack::Finished) {
56 *eigenvectors = CTensor(n, neig);
58 return data.get_data((
double *)eigenvectors->pointer());
60 std::cerr << data.error_message() <<
'\n';
RTensor eigs_sym(const RTensor &A, int eig_type, size_t neig, RTensor *vectors=NULL, const double *initial_guess=NULL)
Find out a few eigenvalues and eigenvectors of a symmetric real matrix.