5 #ifndef FML_MPI_LINALG_LINALG_EIGEN_H
6 #define FML_MPI_LINALG_LINALG_EIGEN_H
12 #include "../../_internals/linalgutils.hh"
13 #include "../../cpu/cpuvec.hh"
15 #include "../internals/bcutils.hh"
16 #include "../internals/mpi_utils.hh"
19 #include "../mpimat.hh"
21 #include "linalg_blas.hh"
22 #include "linalg_err.hh"
23 #include "scalapack.hh"
32 template <
typename REAL>
33 int eig_sym_internals(
const bool only_values, mpimat<REAL> &x,
34 cpuvec<REAL> &values, mpimat<REAL> &vectors)
37 throw std::runtime_error(
"'x' must be a square matrix");
40 int val_found, vec_found;
51 vectors.resize(n, n, x.bf_rows(), x.bf_cols());
57 fml::scalapack::syevr(jobz,
'A',
'L', n, x.data_ptr(), x.desc_ptr(),
58 (REAL) 0.f, (REAL) 0.f, 0, 0, &val_found, &vec_found,
59 values.data_ptr(), vectors.data_ptr(), vectors.desc_ptr(),
60 &worksize, -1, &liwork, -1, &info);
62 lwork = (int) worksize;
63 cpuvec<REAL> work(lwork);
64 cpuvec<int> iwork(liwork);
66 fml::scalapack::syevr(jobz,
'A',
'L', n, x.data_ptr(), x.desc_ptr(),
67 (REAL) 0.f, (REAL) 0.f, 0, 0, &val_found, &vec_found,
68 values.data_ptr(), vectors.data_ptr(), vectors.desc_ptr(),
69 work.data_ptr(), lwork, iwork.data_ptr(), liwork, &info);
97 template <
typename REAL>
102 int info = eig_sym_internals(
true, x, values, ignored);
103 fml::linalgutils::check_info(info,
"syevr");
107 template <
typename REAL>
110 err::check_grid(x, vectors);
112 int info = eig_sym_internals(
false, x, values, vectors);
113 fml::linalgutils::check_info(info,
"syevr");