6 #ifndef TAPKEE_GENERALIZED_EIGENDECOMPOSITION_H_
7 #define TAPKEE_GENERALIZED_EIGENDECOMPOSITION_H_
10 #ifdef TAPKEE_WITH_ARPACK
18 namespace tapkee_internal
21 #ifdef TAPKEE_WITH_ARPACK
23 template <
class LMatrixType,
class RMatrixType,
class MatrixOperationType>
25 const RMatrixType& rhs,
IndexType target_dimension,
unsigned int skip)
27 timed_context context(
"ARPACK DSXUPD generalized eigendecomposition");
30 arpack(lhs,rhs,target_dimension+skip,
"SM");
32 if (arpack.
info() == Eigen::Success)
49 template <
class LMatrixType,
class RMatrixType,
class MatrixOperationType>
51 const RMatrixType& rhs,
IndexType target_dimension,
unsigned int skip)
53 timed_context context(
"Eigen dense generalized eigendecomposition");
57 Eigen::GeneralizedSelfAdjointEigenSolver<DenseMatrix> solver(dense_lhs, dense_rhs);
58 if (solver.info() == Eigen::Success)
60 if (MatrixOperationType::largest)
63 DenseMatrix selected_eigenvectors = solver.eigenvectors().rightCols(target_dimension);
68 DenseMatrix selected_eigenvectors = solver.eigenvectors().leftCols(target_dimension+skip).rightCols(target_dimension);
80 template <
class LMatrixType,
class RMatrixType,
class MatrixOperationType>
82 const RMatrixType& rhs,
83 IndexType target_dimension,
unsigned int skip)
88 #ifdef TAPKEE_WITH_ARPACK
90 return generalized_eigendecomposition_impl_arpack<LMatrixType, RMatrixType, MatrixOperationType>(lhs, rhs, target_dimension, skip);
93 return generalized_eigendecomposition_impl_dense<LMatrixType, RMatrixType, MatrixOperationType>(lhs, rhs, target_dimension, skip);