GQCP
Loading...
Searching...
No Matches
GeneralizedEigenproblemEnvironment.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
24
25
26namespace GQCP {
27
28
34template <typename _Scalar>
36public:
37 // The scalar type of the matrix elements: real or complex.
38 using Scalar = _Scalar;
39
40
41public:
42 // The matrix whose eigenvalue problem should be solved.
44
45 // The transformation matrix needed to solve the generalized eigenvalue problem.
47
48 // The eigenvalues of the matrix A.
50
51 // The eigenvectors of the matrix A.
53
54
55public:
56 /*
57 * MARK: Constructors
58 */
59
64 A {A},
65 S {S} {}
66
67
68 /*
69 * MARK: Named constructors
70 */
71
78
79
80 /*
81 * MARK: Access
82 */
83
89 std::vector<Eigenpair<double, Scalar>> eigenpairs(const size_t number_of_requested_eigenpairs = 1) const {
90
91 if (number_of_requested_eigenpairs > this->eigenvectors.cols()) {
92 throw std::invalid_argument("GeneralEigenproblemEnvironment::eigenpairs(const size_t): You cannot retrieve that many eigenpairs.");
93 }
94
95 std::vector<Eigenpair<double, Scalar>> eigenpairs {};
96 eigenpairs.reserve(number_of_requested_eigenpairs);
97
98 for (size_t i = 0; i < number_of_requested_eigenpairs; i++) {
99 const auto& eigenvalue = this->eigenvalues(i);
100 const auto& eigenvector = this->eigenvectors.col(i);
101
102 eigenpairs.emplace_back(eigenvalue, eigenvector);
103 }
104
105 return eigenpairs;
106 }
107};
108
109
110} // namespace GQCP
Definition: GeneralizedEigenproblemEnvironment.hpp:35
SquareMatrix< Scalar > S
Definition: GeneralizedEigenproblemEnvironment.hpp:46
std::vector< Eigenpair< double, Scalar > > eigenpairs(const size_t number_of_requested_eigenpairs=1) const
Definition: GeneralizedEigenproblemEnvironment.hpp:89
GeneralizedEigenproblemEnvironment(const SquareMatrix< Scalar > &A, const SquareMatrix< Scalar > &S)
Definition: GeneralizedEigenproblemEnvironment.hpp:63
static GeneralizedEigenproblemEnvironment Dense(const SquareMatrix< Scalar > &A, const SquareMatrix< Scalar > &S)
Definition: GeneralizedEigenproblemEnvironment.hpp:77
_Scalar Scalar
Definition: GeneralizedEigenproblemEnvironment.hpp:38
SquareMatrix< Scalar > A
Definition: GeneralizedEigenproblemEnvironment.hpp:43
MatrixX< Scalar > eigenvectors
Definition: GeneralizedEigenproblemEnvironment.hpp:52
VectorX< double > eigenvalues
Definition: GeneralizedEigenproblemEnvironment.hpp:49
Definition: Matrix.hpp:47
Definition: SquareMatrix.hpp:39
Definition: BaseOneElectronIntegralBuffer.hpp:25