gtsam
3rdparty
Spectra
GenEigsRealShiftSolver.h
Go to the documentation of this file.
1
// Copyright (C) 2016-2019 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 GEN_EIGS_REAL_SHIFT_SOLVER_H
8
#define GEN_EIGS_REAL_SHIFT_SOLVER_H
9
10
#include <Eigen/Core>
11
12
#include "
GenEigsBase.h
"
13
#include "
Util/SelectionRule.h
"
14
#include "
MatOp/DenseGenRealShiftSolve.h
"
15
16
namespace
Spectra
{
17
38
template
<
typename
Scalar
= double,
39
int
SelectionRule =
LARGEST_MAGN
,
40
typename
OpType = DenseGenRealShiftSolve<double> >
41
class
GenEigsRealShiftSolver
:
public
GenEigsBase
<Scalar, SelectionRule, OpType, IdentityBOp>
42
{
43
private
:
44
typedef
Eigen::Index
Index
;
45
typedef
std::complex<Scalar>
Complex
;
46
typedef
Eigen::Array<Complex, Eigen::Dynamic, 1>
ComplexArray
;
47
48
const
Scalar
m_sigma
;
49
50
// First transform back the Ritz values, and then sort
51
void
sort_ritzpair
(
int
sort_rule)
52
{
53
// The eigenvalues we get from the iteration is nu = 1 / (lambda - sigma)
54
// So the eigenvalues of the original problem is lambda = 1 / nu + sigma
55
ComplexArray
ritz_val_org =
Scalar
(1.0) / this->
m_ritz_val
.head(this->
m_nev
).array() +
m_sigma
;
56
this->
m_ritz_val
.head(this->
m_nev
) = ritz_val_org;
57
GenEigsBase<Scalar, SelectionRule, OpType, IdentityBOp>::sort_ritzpair
(sort_rule);
58
}
59
60
public
:
79
GenEigsRealShiftSolver
(OpType* op,
Index
nev,
Index
ncv,
Scalar
sigma
) :
80
GenEigsBase
<
Scalar
, SelectionRule, OpType,
IdentityBOp
>(op,
NULL
, nev, ncv),
81
m_sigma
(
sigma
)
82
{
83
this->
m_op
->
set_shift
(m_sigma);
84
}
85
};
86
87
}
// namespace Spectra
88
89
#endif // GEN_EIGS_REAL_SHIFT_SOLVER_H
DenseGenRealShiftSolve.h
Spectra::GenEigsRealShiftSolver::sort_ritzpair
void sort_ritzpair(int sort_rule)
Definition:
GenEigsRealShiftSolver.h:51
Eigen::Array
General-purpose arrays with easy API for coefficient-wise operations.
Definition:
Array.h:45
sampling::sigma
static const double sigma
Definition:
testGaussianBayesNet.cpp:170
Spectra::IdentityBOp
Definition:
ArnoldiOp.h:90
Spectra::GenEigsRealShiftSolver::Complex
std::complex< Scalar > Complex
Definition:
GenEigsRealShiftSolver.h:45
Spectra::GenEigsRealShiftSolver::Index
Eigen::Index Index
Definition:
GenEigsRealShiftSolver.h:44
Spectra::GenEigsBase< double, LARGEST_MAGN, DenseGenRealShiftSolve< double >, IdentityBOp >::m_op
DenseGenRealShiftSolve< double > * m_op
Definition:
GenEigsBase.h:61
Spectra::GenEigsRealShiftSolver
Definition:
GenEigsRealShiftSolver.h:41
Spectra::DenseGenRealShiftSolve::set_shift
void set_shift(Scalar sigma)
Definition:
DenseGenRealShiftSolve.h:66
Spectra::GenEigsBase
Definition:
GenEigsBase.h:40
Spectra::LARGEST_MAGN
@ LARGEST_MAGN
Definition:
SelectionRule.h:32
Spectra::GenEigsBase::sort_ritzpair
virtual void sort_ritzpair(int sort_rule)
Definition:
GenEigsBase.h:214
SelectionRule.h
Spectra
Definition:
LOBPCGSolver.h:19
Spectra::GenEigsRealShiftSolver::m_sigma
const Scalar m_sigma
Definition:
GenEigsRealShiftSolver.h:48
NULL
#define NULL
Definition:
ccolamd.c:609
Spectra::GenEigsBase< double, LARGEST_MAGN, DenseGenRealShiftSolve< double >, IdentityBOp >::m_ritz_val
ComplexVector m_ritz_val
Definition:
GenEigsBase.h:71
Spectra::GenEigsBase< double, LARGEST_MAGN, DenseGenRealShiftSolve< double >, IdentityBOp >::m_nev
const Index m_nev
Definition:
GenEigsBase.h:64
Spectra::GenEigsRealShiftSolver::GenEigsRealShiftSolver
GenEigsRealShiftSolver(OpType *op, Index nev, Index ncv, Scalar sigma)
Definition:
GenEigsRealShiftSolver.h:79
Spectra::GenEigsRealShiftSolver::ComplexArray
Eigen::Array< Complex, Eigen::Dynamic, 1 > ComplexArray
Definition:
GenEigsRealShiftSolver.h:46
Scalar
SCALAR Scalar
Definition:
bench_gemm.cpp:46
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition:
Meta.h:74
GenEigsBase.h
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:34