ARPACK-Eigen
DenseGenMatProd.h
1 #ifndef DENSE_GEN_MAT_PROD_H
2 #define DENSE_GEN_MAT_PROD_H
3 
4 #include <Eigen/Core>
5 
11 
20 template <typename Scalar>
22 {
23 private:
24  typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix;
25  typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
26  typedef Eigen::Map<const Matrix> MapMat;
27  typedef Eigen::Map< Eigen::Matrix<Scalar, Eigen::Dynamic, 1> > MapVec;
28 
29  typedef const Eigen::Ref<const Matrix> ConstGenericMatrix;
30 
31  const MapMat mat;
32 
33 public:
42  DenseGenMatProd(ConstGenericMatrix &mat_) :
43  mat(mat_.data(), mat_.rows(), mat_.cols())
44  {}
45 
49  int rows() { return mat.rows(); }
53  int cols() { return mat.cols(); }
54 
61  // y_out = A * x_in
62  void perform_op(Scalar *x_in, Scalar *y_out)
63  {
64  MapVec x(x_in, mat.cols());
65  MapVec y(y_out, mat.rows());
66  y = mat * x;
67  }
68 };
69 
70 
71 #endif // DENSE_GEN_MAT_PROD_H
DenseGenMatProd(ConstGenericMatrix &mat_)
void perform_op(Scalar *x_in, Scalar *y_out)