forked from yixuan/spectra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:pacs-course/spectra
- Loading branch information
Showing
55 changed files
with
439 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,5 +21,5 @@ build/* | |
issues/* | ||
legacy/* | ||
include/Eigen/* | ||
|
||
/build/ | ||
include/unsupported/Eigen/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2018-2022 Yixuan Qiu <[email protected]> | ||
// Copyright (C) 2018-2023 Yixuan Qiu <[email protected]> | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla | ||
// Public License v. 2.0. If a copy of the MPL was not distributed | ||
|
@@ -143,7 +143,7 @@ class GenEigsBase | |
using std::pow; | ||
|
||
// The machine precision, ~= 1e-16 for the "double" type | ||
constexpr Scalar eps = TypeTraits<Scalar>::epsilon(); | ||
const Scalar eps = TypeTraits<Scalar>::epsilon(); | ||
// std::pow() is not constexpr, so we do not declare eps23 to be constexpr | ||
// But most compilers should be able to compute eps23 at compile time | ||
const Scalar eps23 = pow(eps, Scalar(2) / 3); | ||
|
@@ -164,7 +164,7 @@ class GenEigsBase | |
|
||
// A very small value, but 1.0 / near_0 does not overflow | ||
// ~= 1e-307 for the "double" type | ||
constexpr Scalar near_0 = TypeTraits<Scalar>::min() * Scalar(10); | ||
const Scalar near_0 = TypeTraits<Scalar>::min() * Scalar(10); | ||
|
||
Index nev_new = m_nev; | ||
for (Index i = m_nev; i < m_ncv; i++) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2016-2022 Yixuan Qiu <[email protected]> | ||
// Copyright (C) 2016-2023 Yixuan Qiu <[email protected]> | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla | ||
// Public License v. 2.0. If a copy of the MPL was not distributed | ||
|
@@ -83,7 +83,7 @@ class GenEigsComplexShiftSolver : public GenEigsBase<OpType, IdentityBOp> | |
|
||
// Calculate inv(A - r * I) * vj | ||
Vector v_real(m_n), v_imag(m_n), OPv_real(m_n), OPv_imag(m_n); | ||
constexpr Scalar eps = TypeTraits<Scalar>::epsilon(); | ||
const Scalar eps = TypeTraits<Scalar>::epsilon(); | ||
for (Index i = 0; i < m_nev; i++) | ||
{ | ||
v_real.noalias() = m_fac.matrix_V() * m_ritz_vec.col(i).real(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2016-2022 Yixuan Qiu <[email protected]> | ||
// Copyright (C) 2016-2023 Yixuan Qiu <[email protected]> | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla | ||
// Public License v. 2.0. If a copy of the MPL was not distributed | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2016-2022 Yixuan Qiu <[email protected]> | ||
// Copyright (C) 2016-2023 Yixuan Qiu <[email protected]> | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla | ||
// Public License v. 2.0. If a copy of the MPL was not distributed | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2018-2022 Yixuan Qiu <[email protected]> | ||
// Copyright (C) 2018-2023 Yixuan Qiu <[email protected]> | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla | ||
// Public License v. 2.0. If a copy of the MPL was not distributed | ||
|
@@ -42,9 +42,9 @@ class Arnoldi | |
protected: | ||
// A very small value, but 1.0 / m_near_0 does not overflow | ||
// ~= 1e-307 for the "double" type | ||
static constexpr Scalar m_near_0 = TypeTraits<Scalar>::min() * Scalar(10); | ||
const Scalar m_near_0 = TypeTraits<Scalar>::min() * Scalar(10); | ||
// The machine precision, ~= 1e-16 for the "double" type | ||
static constexpr Scalar m_eps = TypeTraits<Scalar>::epsilon(); | ||
const Scalar m_eps = TypeTraits<Scalar>::epsilon(); | ||
|
||
ArnoldiOpType m_op; // Operators for the Arnoldi factorization | ||
const Index m_n; // dimension of A | ||
|
@@ -130,6 +130,8 @@ class Arnoldi | |
// Initialize with an operator and an initial vector | ||
void init(MapConstVec& v0, Index& op_counter) | ||
{ | ||
using std::abs; | ||
|
||
m_fac_V.resize(m_n, m_m); | ||
m_fac_H.resize(m_m, m_m); | ||
m_fac_f.resize(m_n); | ||
|
@@ -158,9 +160,11 @@ class Arnoldi | |
m_fac_H(0, 0) = m_op.inner_product(v, w); | ||
m_fac_f.noalias() = w - v * m_fac_H(0, 0); | ||
|
||
// In some cases f is zero in exact arithmetics, but due to rounding errors | ||
// it may contain tiny fluctuations. When this happens, we force f to be zero | ||
if (m_fac_f.cwiseAbs().maxCoeff() < m_eps) | ||
// In some cases, H[1,1] is already an eigenvalue of A, | ||
// so f would be zero in exact arithmetics. But due to rounding errors, | ||
// it may contain tiny fluctuations. When this happens, we force f to be zero, | ||
// so that it can be restarted in the subsequent Arnoldi factorization | ||
if (m_fac_f.cwiseAbs().maxCoeff() < m_eps * abs(m_fac_H(0, 0))) | ||
{ | ||
m_fac_f.setZero(); | ||
m_beta = Scalar(0); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (C) 2019-2022 Yixuan Qiu <[email protected]> | ||
// Copyright (C) 2019-2023 Yixuan Qiu <[email protected]> | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla | ||
// Public License v. 2.0. If a copy of the MPL was not distributed | ||
|
Oops, something went wrong.