Spectra
1.2.0
Header-only C++ Library for Large Scale Eigenvalue Problems
Toggle main menu visibility
Loading...
Searching...
No Matches
SymGEigsSolver.h
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_SYM_GEIGS_SOLVER_H
8
#define SPECTRA_SYM_GEIGS_SOLVER_H
9
10
#include "HermEigsBase.h"
11
#include "Util/GEigsMode.h"
12
#include "MatOp/internal/SymGEigsCholeskyOp.h"
13
#include "MatOp/internal/SymGEigsRegInvOp.h"
14
15
namespace
Spectra {
16
22
42
43
// Empty class template
44
template
<
typename
OpType,
typename
BOpType, GEigsMode Mode>
45
class
SymGEigsSolver
46
{};
47
146
147
// Partial specialization for mode = GEigsMode::Cholesky
148
template
<
typename
OpType,
typename
BOpType>
149
class
SymGEigsSolver
<OpType, BOpType,
GEigsMode
::
Cholesky
> :
150
public
HermEigsBase
<SymGEigsCholeskyOp<OpType, BOpType>, IdentityBOp>
151
{
152
private
:
153
using
Scalar =
typename
OpType::Scalar;
154
using
Index = Eigen::Index;
155
using
Matrix = Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>;
156
using
Vector = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;
157
158
using
ModeMatOp = SymGEigsCholeskyOp<OpType, BOpType>;
159
using
Base =
HermEigsBase<ModeMatOp, IdentityBOp>
;
160
161
const
BOpType& m_Bop;
162
163
public
:
188
SymGEigsSolver
(OpType& op, BOpType& Bop, Index nev, Index ncv) :
189
Base(ModeMatOp(op, Bop), IdentityBOp(), nev, ncv),
190
m_Bop(Bop)
191
{}
192
194
195
Matrix eigenvectors(Index nvec)
const override
196
{
197
Matrix res = Base::eigenvectors(nvec);
198
Vector tmp(res.rows());
199
const
Index nconv = res.cols();
200
for
(Index i = 0; i < nconv; i++)
201
{
202
m_Bop.upper_triangular_solve(&res(0, i), tmp.data());
203
res.col(i).noalias() = tmp;
204
}
205
206
return
res;
207
}
208
209
Matrix eigenvectors()
const override
210
{
211
return
SymGEigsSolver<OpType, BOpType, GEigsMode::Cholesky>::eigenvectors
(this->m_nev);
212
}
213
215
};
216
248
249
// Partial specialization for mode = GEigsMode::RegularInverse
250
template
<
typename
OpType,
typename
BOpType>
251
class
SymGEigsSolver
<OpType, BOpType,
GEigsMode
::
RegularInverse
> :
252
public
HermEigsBase
<SymGEigsRegInvOp<OpType, BOpType>, BOpType>
253
{
254
private
:
255
using
Index = Eigen::Index;
256
257
using
ModeMatOp = SymGEigsRegInvOp<OpType, BOpType>;
258
using
Base =
HermEigsBase<ModeMatOp, BOpType>
;
259
260
public
:
283
SymGEigsSolver
(OpType& op, BOpType& Bop, Index nev, Index ncv) :
284
Base(ModeMatOp(op, Bop), Bop, nev, ncv)
285
{}
286
};
287
288
}
// namespace Spectra
289
290
#endif
// SPECTRA_SYM_GEIGS_SOLVER_H
Spectra::HermEigsBase
Definition
HermEigsBase.h:45
Spectra::HermEigsBase< SymGEigsCholeskyOp< OpType, BOpType >, IdentityBOp >::eigenvectors
virtual Matrix eigenvectors(Index nvec) const
Definition
HermEigsBase.h:447
Spectra::SymGEigsSolver< OpType, BOpType, GEigsMode::Cholesky >::SymGEigsSolver
SymGEigsSolver(OpType &op, BOpType &Bop, Index nev, Index ncv)
Definition
SymGEigsSolver.h:188
Spectra::SymGEigsSolver< OpType, BOpType, GEigsMode::RegularInverse >::SymGEigsSolver
SymGEigsSolver(OpType &op, BOpType &Bop, Index nev, Index ncv)
Definition
SymGEigsSolver.h:283
Spectra::SymGEigsSolver
Definition
SymGEigsSolver.h:46
Spectra::GEigsMode
GEigsMode
Definition
GEigsMode.h:18
Spectra::GEigsMode::RegularInverse
@ RegularInverse
Regular inverse mode for generalized eigenvalue solver.
Definition
GEigsMode.h:20
Spectra::GEigsMode::Cholesky
@ Cholesky
Using Cholesky decomposition to solve generalized eigenvalues.
Definition
GEigsMode.h:19
Spectra
SymGEigsSolver.h
Generated by
1.17.0