ARPACK-Armadillo
DenseGenMatProd.h
1 // Copyright (C) 2015 Yixuan Qiu
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #ifndef DENSE_GEN_MAT_PROD_H
8 #define DENSE_GEN_MAT_PROD_H
9 
10 #include <armadillo>
11 
17 
26 template <typename Scalar>
28 {
29 private:
30  typedef arma::Mat<Scalar> Matrix;
31  typedef arma::Col<Scalar> Vector;
32 
33  const Matrix mat;
34 
35 public:
42  DenseGenMatProd(Matrix &mat_) :
43  mat(mat_.memptr(), mat_.n_rows, mat_.n_cols, false)
44  {}
45 
49  int rows() { return mat.n_rows; }
53  int cols() { return mat.n_cols; }
54 
61  // y_out = A * x_in
62  void perform_op(Scalar *x_in, Scalar *y_out)
63  {
64  Vector x(x_in, mat.n_cols, false);
65  Vector y(y_out, mat.n_rows, false);
66  y = mat * x;
67  }
68 };
69 
70 
71 #endif // DENSE_GEN_MAT_PROD_H
DenseGenMatProd(Matrix &mat_)
void perform_op(Scalar *x_in, Scalar *y_out)