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)
48 template <
class LMatrixType,
class RMatrixType,
class MatrixOperationType>
50 const RMatrixType& rhs,
IndexType target_dimension,
unsigned int skip)
52 timed_context context(
"Eigen dense generalized eigendecomposition");
56 Eigen::GeneralizedSelfAdjointEigenSolver<DenseMatrix> solver(dense_lhs, dense_rhs);
57 if (solver.info() == Eigen::Success)
59 if (MatrixOperationType::largest)
62 DenseMatrix selected_eigenvectors = solver.eigenvectors().rightCols(target_dimension);
67 DenseMatrix selected_eigenvectors = solver.eigenvectors().leftCols(target_dimension+skip).rightCols(target_dimension);
79 template <
typename LMatrixType,
typename RMatrixType>
82 #ifdef TAPKEE_WITH_ARPACK 97 #ifdef TAPKEE_WITH_ARPACK 108 (lhs,rhs,target_dimension,eigen_strategy.
skip());
125 (lhs,rhs,target_dimension,eigen_strategy.
skip());
140 #ifdef TAPKEE_WITH_ARPACK 151 (lhs,rhs,target_dimension,0);
168 (lhs,rhs,target_dimension,0);
180 template <
class LMatrixType,
class RMatrixType>
183 const LMatrixType& lhs,
const RMatrixType& rhs,
IndexType target_dimension)
187 #ifdef TAPKEE_WITH_ARPACK 190 .
arpack(lhs, rhs, strategy, eigen_strategy, target_dimension);
194 .
dense(lhs, rhs, strategy, eigen_strategy, target_dimension);
Eigen::DiagonalMatrix< tapkee::ScalarType, Eigen::Dynamic > DenseDiagonalMatrix
dense diagonal matrix
static const EigenMethod Dense("Dense")
Eigen library dense method (could be useful for debugging). Computes all eigenvectors thus can be ver...
static const EigendecompositionStrategy SmallestEigenvalues("Smallest eigenvalues", 1)
static const EigenMethod Randomized("Randomized")
Randomized method (implementation taken from the redsvd lib). Supports only standard but not generali...
Matrix-matrix operation used to compute smallest eigenvalues and associated eigenvectors of a dense m...
const Matrix< Scalar, Dynamic, Dynamic > & eigenvectors() const
Returns the eigenvectors of given matrix.
EigendecompositionResult dense(const SparseWeightMatrix &lhs, const DenseDiagonalMatrix &rhs, const ComputationStrategy &strategy, const EigendecompositionStrategy &eigen_strategy, IndexType target_dimension)
Eigen::Matrix< tapkee::ScalarType, Eigen::Dynamic, Eigen::Dynamic > DenseMatrix
dense matrix type (non-overridable)
EigendecompositionResult arpack(const LMatrixType &lhs, const RMatrixType &rhs, const ComputationStrategy &strategy, const EigendecompositionStrategy &eigen_strategy, IndexType target_dimension)
EigendecompositionResult dense(const LMatrixType &lhs, const RMatrixType &rhs, const ComputationStrategy &strategy, const EigendecompositionStrategy &eigen_strategy, IndexType target_dimension)
EigendecompositionResult generalized_eigendecomposition(const EigenMethod &method, const ComputationStrategy &strategy, const EigendecompositionStrategy &eigen_strategy, const LMatrixType &lhs, const RMatrixType &rhs, IndexType target_dimension)
ComputationInfo info() const
Reports whether previous computation was successful.
EigendecompositionResult arpack(const SparseWeightMatrix &lhs, const DenseDiagonalMatrix &rhs, const ComputationStrategy &strategy, const EigendecompositionStrategy &eigen_strategy, IndexType target_dimension)
An exception type that is thrown when eigendecomposition is failed.
EigendecompositionResult dense(const DenseMatrix &lhs, const DenseMatrix &rhs, const ComputationStrategy &strategy, const EigendecompositionStrategy &eigen_strategy, IndexType target_dimension)
Eigen::SparseMatrix< tapkee::ScalarType > SparseWeightMatrix
sparse weight matrix type (non-overridable)
static const EigenMethod Arpack("Arpack")
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.
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
Matrix-matrix operation used to compute smallest eigenvalues and associated eigenvectors of a sparse ...
EigendecompositionResult arpack(const DenseMatrix &lhs, const DenseMatrix &rhs, const ComputationStrategy &strategy, const EigendecompositionStrategy &eigen_strategy, IndexType target_dimension)
static const ComputationStrategy HomogeneousCPUStrategy("CPU")
void message_info(const std::string &msg)
std::string get_eigen_method_name(const EigenMethod &m)
const Matrix< Scalar, Dynamic, 1 > & eigenvalues() const
Returns the eigenvalues of given matrix.
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
size_t getNbrIterations() const
bool is(const M &m) const