5 #ifndef FML_CPU_LINALG_LINALG_EIGEN_H
6 #define FML_CPU_LINALG_LINALG_EIGEN_H
13 #include "../../_internals/linalgutils.hh"
14 #include "../../_internals/omp.hh"
16 #include "../cpumat.hh"
17 #include "../cpuvec.hh"
28 template <
typename REAL>
29 int eig_sym_internals(
const bool only_values, cpumat<REAL> &x,
30 cpuvec<REAL> &values, cpumat<REAL> &vectors)
33 throw std::runtime_error(
"'x' must be a square matrix");
54 fml::lapack::syevr(jobz,
'A',
'L', n, x.data_ptr(), n, (REAL) 0.f, (REAL) 0.f,
55 0, 0, (REAL) 0.f, &nfound, values.data_ptr(), vectors.data_ptr(), n,
56 support.data_ptr(), &worksize, -1, &liwork, -1,
59 lwork = (int) worksize;
60 cpuvec<REAL> work(lwork);
61 cpuvec<int> iwork(liwork);
63 fml::lapack::syevr(jobz,
'A',
'L', n, x.data_ptr(), n, (REAL) 0.f, (REAL) 0.f,
64 0, 0, (REAL) 0.f, &nfound, values.data_ptr(), vectors.data_ptr(), n,
65 support.data_ptr(), work.data_ptr(), lwork, iwork.data_ptr(), liwork,
92 template <
typename REAL>
97 int info = eig_sym_internals(
true, x, values, ignored);
98 fml::linalgutils::check_info(info,
"syevr");
102 template <
typename REAL>
105 int info = eig_sym_internals(
false, x, values, vectors);
106 fml::linalgutils::check_info(info,
"syevr");