GQCP
Loading...
Searching...
No Matches
Eigenpair.hpp
Go to the documentation of this file.
1// This file is part of GQCG-GQCP.
2//
3// Copyright (C) 2017-2020 the GQCG developers
4//
5// GQCG-GQCP is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GQCG-GQCP is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GQCG-GQCP. If not, see <http://www.gnu.org/licenses/>.
17
18#pragma once
19
20
22
23
24namespace GQCP {
25
26
33template <typename _EigenvalueScalar, typename _EigenvectorScalar>
34class Eigenpair {
35public:
36 // The scalar type for the representation of an eigenvalue: real or complex.
37 using EigenvalueScalar = _EigenvalueScalar;
38
39
40 // The scalar type for the representation of one of the coefficients of an eigenvector: real or complex.
41 using EigenvectorScalar = _EigenvectorScalar;
42
43
44private:
45 EigenvalueScalar m_eigenvalue;
46 VectorX<EigenvectorScalar> m_eigenvector;
47
48
49public:
50 // CONSTRUCTORS
51
57 m_eigenvalue {eigenvalue},
58 m_eigenvector {eigenvector} {}
59
65 explicit Eigenpair(const size_t dimension = 1) :
66 Eigenpair(0.0, VectorX<EigenvectorScalar>::Zero(dimension)) {}
67
68
69 // PUBLIC METHODS
70
74 EigenvalueScalar eigenvalue() const { return this->m_eigenvalue; };
75
81 const VectorX<EigenvectorScalar>& eigenvector() const { return this->m_eigenvector; };
82
91 bool isEqualTo(const Eigenpair& other, const double tolerance = 1.0e-08) const {
92
93 if (this->eigenvector().size() != other.eigenvector().size()) {
94 throw std::invalid_argument("Eigenpair::isEqualTo(Eigenpair, double): Can't compare eigenpairs with eigenvectors of different dimension.");
95 }
96
97 if (std::abs(this->eigenvalue() - other.eigenvalue()) < tolerance) {
98 if ((this->eigenvector()).isEqualEigenvectorAs(other.eigenvector(), tolerance)) {
99 return true;
100 }
101 }
102
103 return false;
104 }
105};
106
107
108} // namespace GQCP
Definition: Eigenpair.hpp:34
Eigenpair(const size_t dimension=1)
Definition: Eigenpair.hpp:65
_EigenvectorScalar EigenvectorScalar
Definition: Eigenpair.hpp:41
Eigenpair(const EigenvalueScalar eigenvalue, const VectorX< EigenvectorScalar > &eigenvector)
Definition: Eigenpair.hpp:56
_EigenvalueScalar EigenvalueScalar
Definition: Eigenpair.hpp:37
const VectorX< EigenvectorScalar > & eigenvector() const
Definition: Eigenpair.hpp:81
EigenvalueScalar eigenvalue() const
Definition: Eigenpair.hpp:74
bool isEqualTo(const Eigenpair &other, const double tolerance=1.0e-08) const
Definition: Eigenpair.hpp:91
Definition: Matrix.hpp:47
Definition: BaseOneElectronIntegralBuffer.hpp:25