Spectra
1.2.0
Header-only C++ Library for Large Scale Eigenvalue Problems
Toggle main menu visibility
Loading...
Searching...
No Matches
DenseHermMatProd.h
1
// Copyright (C) 2024-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_HERM_MAT_PROD_H
8
#define SPECTRA_DENSE_HERM_MAT_PROD_H
9
10
#include <Eigen/Core>
11
12
namespace
Spectra {
13
29
template
<
typename
Scalar_,
int
Uplo = Eigen::Lower,
int
Flags = Eigen::ColMajor>
30
class
DenseHermMatProd
31
{
32
public
:
36
using
Scalar
= Scalar_;
37
38
private
:
39
using
Index = Eigen::Index;
40
using
Matrix = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Flags>;
41
using
Vector = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;
42
using
MapConstVec = Eigen::Map<const Vector>;
43
using
MapVec = Eigen::Map<Vector>;
44
using
ConstGenericMatrix =
const
Eigen::Ref<const Matrix>;
45
46
ConstGenericMatrix m_mat;
47
48
public
:
57
template
<
typename
Derived>
58
DenseHermMatProd
(
const
Eigen::MatrixBase<Derived>& mat) :
59
m_mat(mat)
60
{
61
static_assert
(
62
static_cast<
int
>
(Derived::PlainObject::IsRowMajor) ==
static_cast<
int
>
(Matrix::IsRowMajor),
63
"DenseHermMatProd: the \"Flags\" template parameter does not match the input matrix (Eigen::ColMajor/Eigen::RowMajor)"
);
64
}
65
69
Index
rows
()
const
{
return
m_mat.rows(); }
73
Index
cols
()
const
{
return
m_mat.cols(); }
74
81
// y_out = A * x_in
82
void
perform_op
(
const
Scalar
* x_in,
Scalar
* y_out)
const
83
{
84
MapConstVec x(x_in, m_mat.cols());
85
MapVec y(y_out, m_mat.rows());
86
y.noalias() = m_mat.template selfadjointView<Uplo>() * x;
87
}
88
};
89
90
}
// namespace Spectra
91
92
#endif
// SPECTRA_DENSE_HERM_MAT_PROD_H
Spectra::DenseHermMatProd::Scalar
Scalar_ Scalar
Definition
DenseHermMatProd.h:36
Spectra::DenseHermMatProd::DenseHermMatProd
DenseHermMatProd(const Eigen::MatrixBase< Derived > &mat)
Definition
DenseHermMatProd.h:58
Spectra::DenseHermMatProd::cols
Index cols() const
Definition
DenseHermMatProd.h:73
Spectra::DenseHermMatProd::perform_op
void perform_op(const Scalar *x_in, Scalar *y_out) const
Definition
DenseHermMatProd.h:82
Spectra::DenseHermMatProd::rows
Index rows() const
Definition
DenseHermMatProd.h:69
Spectra
MatOp
DenseHermMatProd.h
Generated by
1.17.0