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
22 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);
Eigen::Matrix< tapkee::ScalarType, Eigen::Dynamic, Eigen::Dynamic > DenseMatrix
dense matrix type (non-overridable)
ARPACK-based method (requires the ARPACK library binaries to be available around). Recommended to be used as a default method. Supports both generalized and standard eigenproblems.
Eigen library dense method (could be useful for debugging). Computes all eigenvectors thus can be ver...
std::string get_eigen_method_name(EigenMethod m)
EigendecompositionResult generalized_eigendecomposition(EigenMethod method, const LMatrixType &lhs, const RMatrixType &rhs, IndexType target_dimension, unsigned int skip)
An exception type that is thrown when eigendecomposition is failed.
Randomized method (implementation taken from the redsvd lib). Supports only standard but not generali...
EigenMethod
Eigendecomposition methods.
EigendecompositionResult generalized_eigendecomposition_impl_dense(const LMatrixType &lhs, const RMatrixType &rhs, IndexType target_dimension, unsigned int skip)
Eigen library dense implementation of eigendecomposition.
int IndexType
indexing type (non-overridable) set to int for compatibility with OpenMP 2.0
size_t getNbrIterations() const
const Matrix< Scalar, Dynamic, Dynamic > & eigenvectors() const
Returns the eigenvectors of given matrix.
void message_info(const std::string &msg)
const Matrix< Scalar, Dynamic, 1 > & eigenvalues() const
Returns the eigenvalues of given matrix.
ComputationInfo info() const
Reports whether previous computation was successful.
static LoggingSingleton & instance()
EigendecompositionResult generalized_eigendecomposition_impl_arpack(const LMatrixType &lhs, const RMatrixType &rhs, IndexType target_dimension, unsigned int skip)
ARPACK implementation of eigendecomposition-based embedding.
An exception type that is thrown when unsupported method is called.
TAPKEE_INTERNAL_PAIR< tapkee::DenseMatrix, tapkee::DenseVector > EigendecompositionResult