7 #ifndef SPECTRA_SPARSE_SYM_MAT_PROD_H
8 #define SPECTRA_SPARSE_SYM_MAT_PROD_H
11 #include <Eigen/SparseCore>
30 template <
typename Scalar_,
int Uplo = Eigen::Lower,
int Flags = Eigen::ColMajor,
typename StorageIndex =
int>
40 using Index = Eigen::Index;
41 using Vector = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;
42 using MapConstVec = Eigen::Map<const Vector>;
43 using MapVec = Eigen::Map<Vector>;
44 using Matrix = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>;
45 using SparseMatrix = Eigen::SparseMatrix<Scalar, Flags, StorageIndex>;
46 using ConstGenericSparseMatrix =
const Eigen::Ref<const SparseMatrix>;
48 ConstGenericSparseMatrix m_mat;
58 template <
typename Derived>
63 static_cast<int>(Derived::PlainObject::IsRowMajor) ==
static_cast<int>(SparseMatrix::IsRowMajor),
64 "SparseSymMatProd: the \"Flags\" template parameter does not match the input matrix (Eigen::ColMajor/Eigen::RowMajor)");
70 Index
rows()
const {
return m_mat.rows(); }
74 Index
cols()
const {
return m_mat.cols(); }
85 MapConstVec x(x_in, m_mat.cols());
86 MapVec y(y_out, m_mat.rows());
87 y.noalias() = m_mat.template selfadjointView<Uplo>() * x;
93 Matrix
operator*(
const Eigen::Ref<const Matrix>& mat_in)
const
95 return m_mat.template selfadjointView<Uplo>() * mat_in;
103 return m_mat.coeff(i, j);
SparseSymMatProd(const Eigen::SparseMatrixBase< Derived > &mat)
void perform_op(const Scalar *x_in, Scalar *y_out) const
Matrix operator*(const Eigen::Ref< const Matrix > &mat_in) const
Scalar operator()(Index i, Index j) const