Loading...
Searching...
No Matches
TeamEigen.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3
4#include "TeamEigen.h"
5
6#include <Eigen/Eigenvalues>
7#include <limits>
8
9namespace gpr::linalg {
10
11bool teamDivideConquerEigen(const Eigen::MatrixXd& sym, Eigen::VectorXd& evals,
12 Eigen::MatrixXd& evecs)
13{
14 if (sym.rows() != sym.cols()) return false;
15 if (sym.rows() > static_cast<Eigen::Index>(std::numeric_limits<int>::max()))
16 return false;
17 const int n = static_cast<int>(sym.rows());
18 if (n == 0) {
19 evals.resize(0);
20 evecs.resize(0, 0);
21 return true;
22 }
23 // Eigen's blocked tridiagonalization, compiled without a BLAS kernel.
24 // The pairs do not follow OPENBLAS_CORETYPE.
25 Eigen::SelfAdjointEigenSolver<Eigen::MatrixXd> solver(
26 sym.selfadjointView<Eigen::Lower>());
27 if (solver.info() != Eigen::Success) return false;
28 evals = solver.eigenvalues();
29 evecs = solver.eigenvectors();
30 return true;
31}
32
33} // namespace gpr::linalg
Dense and structured linear algebra behind the GP: Cholesky and eigen solvers, linear operators,...
bool teamDivideConquerEigen(const Eigen::MatrixXd &sym, Eigen::VectorXd &evals, Eigen::MatrixXd &evecs)
Definition TeamEigen.cpp:11