12 #ifndef TAPKEE_EIGENDECOMPOSITION_H_
13 #define TAPKEE_EIGENDECOMPOSITION_H_
16 #ifdef TAPKEE_WITH_ARPACK
25 namespace tapkee_internal
28 #ifdef TAPKEE_WITH_ARPACK
30 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);