DenseGenMatProd.h
Go to the documentation of this file.
1 // Copyright (C) 2016-2025 Yixuan Qiu <yixuan.qiu@cos.name>
2 //
3 // This Source Code Form is subject to the terms of the Mozilla
4 // Public License v. 2.0. If a copy of the MPL was not distributed
5 // with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
6 
7 #ifndef SPECTRA_DENSE_GEN_MAT_PROD_H
8 #define SPECTRA_DENSE_GEN_MAT_PROD_H
9 
10 #include <Eigen/Core>
11 
12 namespace Spectra {
13 
19 
33 template <typename Scalar_, int Flags = Eigen::ColMajor>
35 {
36 public:
40  using Scalar = Scalar_;
41 
42 private:
49 
51 
52 public:
61  template <typename Derived>
63  m_mat(mat)
64  {
65  static_assert(
66  static_cast<int>(Derived::PlainObject::IsRowMajor) == static_cast<int>(Matrix::IsRowMajor),
67  "DenseGenMatProd: the \"Flags\" template parameter does not match the input matrix (Eigen::ColMajor/Eigen::RowMajor)");
68  }
69 
73  Index rows() const { return m_mat.rows(); }
77  Index cols() const { return m_mat.cols(); }
78 
85  // y_out = A * x_in
86  void perform_op(const Scalar* x_in, Scalar* y_out) const
87  {
88  MapConstVec x(x_in, m_mat.cols());
89  MapVec y(y_out, m_mat.rows());
90  y.noalias() = m_mat * x;
91  }
92 
97  {
98  return m_mat * mat_in;
99  }
100 
105  {
106  return m_mat(i, j);
107  }
108 };
109 
110 } // namespace Spectra
111 
112 #endif // SPECTRA_DENSE_GEN_MAT_PROD_H
Spectra::DenseGenMatProd< double >::Scalar
double Scalar
Definition: DenseGenMatProd.h:40
x
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
Definition: gnuplot_common_settings.hh:12
mat
MatrixXf mat
Definition: Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
Spectra::DenseGenMatProd::rows
Index rows() const
Definition: DenseGenMatProd.h:73
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
Spectra::DenseGenMatProd::operator()
Scalar operator()(Index i, Index j) const
Definition: DenseGenMatProd.h:104
Eigen::Map
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:94
y
Scalar * y
Definition: level1_cplx_impl.h:124
Spectra::DenseGenMatProd::m_mat
ConstGenericMatrix m_mat
Definition: DenseGenMatProd.h:50
Spectra::DenseGenMatProd< double >::Index
Eigen::Index Index
Definition: DenseGenMatProd.h:43
Eigen::Ref< const Matrix >
Spectra::DenseGenMatProd::DenseGenMatProd
DenseGenMatProd(const Eigen::MatrixBase< Derived > &mat)
Definition: DenseGenMatProd.h:62
Spectra
Definition: LOBPCGSolver.h:19
Spectra::DenseGenMatProd::perform_op
void perform_op(const Scalar *x_in, Scalar *y_out) const
Definition: DenseGenMatProd.h:86
Spectra::DenseGenMatProd::cols
Index cols() const
Definition: DenseGenMatProd.h:77
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
Eigen::MatrixBase
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Spectra::DenseGenMatProd
Definition: DenseGenMatProd.h:34
Spectra::DenseGenMatProd::operator*
Matrix operator*(const Eigen::Ref< const Matrix > &mat_in) const
Definition: DenseGenMatProd.h:96
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Thu Apr 10 2025 03:01:21