12 #ifndef TAPKEE_EIGENDECOMPOSITION_H_
13 #define TAPKEE_EIGENDECOMPOSITION_H_
16 #ifdef TAPKEE_WITH_ARPACK
25 namespace tapkee_internal
28 #ifdef TAPKEE_WITH_ARPACK
29 template <
class MatrixType,
class MatrixOperationType>
36 arpack(wm,target_dimension+skip,MatrixOperationType::ARPACK_CODE);
38 if (arpack.
info() == Eigen::Success)
55 template <
class MatrixType,
class MatrixOperationType>
58 timed_context context(
"Eigen library dense eigendecomposition");
63 if (solver.info() == Eigen::Success)
65 if (MatrixOperationType::largest)
68 DenseMatrix selected_eigenvectors = solver.eigenvectors().rightCols(target_dimension);
73 DenseMatrix selected_eigenvectors = solver.eigenvectors().leftCols(target_dimension+skip).rightCols(target_dimension);
85 template <
class MatrixType,
class MatrixOperationType>
98 MatrixOperationType operation(wm);
106 Y.col(i) -= r*Y.col(j);
111 for (
int k = i; k<Y.cols(); k++)
114 Y.col(i) *= (1.f / norm);
121 if (eigenOfB.info() == Eigen::Success)
123 if (MatrixOperationType::largest)
126 DenseMatrix selected_eigenvectors = (Y*eigenOfB.eigenvectors()).rightCols(target_dimension);
131 DenseMatrix selected_eigenvectors = (Y*eigenOfB.eigenvectors()).leftCols(target_dimension+skip).rightCols(target_dimension);
170 template <
class MatrixType,
class MatrixOperationType>
172 IndexType target_dimension,
unsigned int skip)
177 #ifdef TAPKEE_WITH_ARPACK
179 return eigendecomposition_impl_arpack<MatrixType, MatrixOperationType>(m, target_dimension, skip);
182 return eigendecomposition_impl_randomized<MatrixType, MatrixOperationType>(m, target_dimension, skip);
184 return eigendecomposition_impl_dense<MatrixType, MatrixOperationType>(m, target_dimension, skip);
EigendecompositionResult eigendecomposition_impl_randomized(const MatrixType &wm, IndexType target_dimension, unsigned int skip)
Randomized redsvd-like implementation of eigendecomposition-based embedding.
EigendecompositionResult eigendecomposition(EigenMethod method, const MatrixType &m, IndexType target_dimension, unsigned int skip)
Multiple implementation handler method for various eigendecomposition methods.
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)
double ScalarType
default scalar value (can be overrided with TAPKEE_CUSTOM_INTERNAL_NUMTYPE define) ...
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.
int IndexType
indexing type (non-overridable) set to int for compatibility with OpenMP 2.0
size_t getNbrIterations() const
EigendecompositionResult eigendecomposition_impl_dense(const MatrixType &wm, IndexType target_dimension, unsigned int skip)
Eigen library dense implementation of eigendecomposition-based embedding.
Eigen::SelfAdjointEigenSolver< tapkee::DenseMatrix > DenseSelfAdjointEigenSolver
selfadjoint solver (non-overridable)
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 eigendecomposition_impl_arpack(const MatrixType &wm, IndexType target_dimension, unsigned int skip)
ARPACK implementation of eigendecomposition-based embedding.
ScalarType gaussian_random()
TAPKEE_INTERNAL_PAIR< tapkee::DenseMatrix, tapkee::DenseVector > EigendecompositionResult