7 #ifndef PARTIAL_SVD_SOLVER_H 8 #define PARTIAL_SVD_SOLVER_H 11 #include "../SymEigsSolver.h" 16 template <
typename Scalar>
20 virtual int rows()
const = 0;
21 virtual int cols()
const = 0;
32 template <
typename Scalar,
typename MatrixType>
54 int rows()
const {
return m_dim; }
55 int cols()
const {
return m_dim; }
60 MapConstVec
x(x_in, m_mat.cols());
61 MapVec
y(y_out, m_mat.cols());
62 m_cache.noalias() = m_mat *
x;
63 y.noalias() = m_mat.transpose() * m_cache;
70 template <
typename Scalar,
typename MatrixType>
92 int rows()
const {
return m_dim; }
93 int cols()
const {
return m_dim; }
98 MapConstVec
x(x_in, m_mat.rows());
99 MapVec
y(y_out, m_mat.rows());
100 m_cache.noalias() = m_mat.transpose() *
x;
101 y.noalias() = m_mat * m_cache;
107 template <
typename Scalar = double,
127 m_mat(mat), m_m(mat.
rows()), m_n(mat.
cols()), m_evecs(0, 0)
170 if (m_evecs.
cols() < 1)
177 return m_evecs.leftCols(nu);
180 return m_mat * (m_evecs.leftCols(nu).array().rowwise() / m_eigs->
eigenvalues().head(nu).transpose().array().sqrt()).
matrix();
186 if (m_evecs.
cols() < 1)
193 return m_evecs.leftCols(nv);
196 return m_mat.transpose() * (m_evecs.leftCols(nv).array().rowwise() / m_eigs->
eigenvalues().head(nv).transpose().array().sqrt()).
matrix();
202 #endif // PARTIAL_SVD_SOLVER_H SVDMatOp< Scalar > * m_op
int compute(int maxit=1000, Scalar tol=1e-10)
Vector eigenvalues() const
const Eigen::Ref< const MatrixType > ConstGenericMatrix
virtual void perform_op(const Scalar *x_in, Scalar *y_out)=0
A matrix or vector expression mapping an existing array of data.
virtual int rows() const =0
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
virtual ~PartialSVDSolver()
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
void perform_op(const Scalar *x_in, Scalar *y_out)
const Eigen::Ref< const MatrixType > ConstGenericMatrix
SVDTallMatOp(ConstGenericMatrix &mat)
Eigen::Map< const Vector > MapConstVec
Eigen::Map< Vector > MapVec
Eigen::Map< const Vector > MapConstVec
SymEigsSolver< Scalar, LARGEST_ALGE, SVDMatOp< Scalar > > * m_eigs
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Index compute(Index maxit=1000, Scalar tol=1e-10, int sort_rule=LARGEST_ALGE)
SVDWideMatOp(ConstGenericMatrix &mat)
void init(const Scalar *init_resid)
void perform_op(const Scalar *x_in, Scalar *y_out)
Eigen::Map< Vector > MapVec
PartialSVDSolver(ConstGenericMatrix &mat, int ncomp, int ncv)
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
const Eigen::Ref< const MatrixType > ConstGenericMatrix
virtual Matrix eigenvectors(Index nvec) const
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
virtual int cols() const =0
Vector singular_values() const