GQCP
Loading...
Searching...
No Matches
ResidualVectorCalculation.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
23
24
25namespace GQCP {
26
27
32 public Step<EigenproblemEnvironment<double>> {
33
34private:
35 size_t number_of_requested_eigenpairs;
36
37
38public:
39 /*
40 * CONSTRUCTORS
41 */
42
46 ResidualVectorCalculation(const size_t number_of_requested_eigenpairs = 1) :
47 number_of_requested_eigenpairs {number_of_requested_eigenpairs} {}
48
49
50 /*
51 * PUBLIC OVERRIDDEN METHODS
52 */
53
57 std::string description() const override {
58 return "Calculate the residual vectors from the new guesses for the eigenvectors.";
59 }
60
61
67 void execute(EigenproblemEnvironment<double>& environment) override {
68
69 const auto dim = environment.dimension;
70
71 const auto& VA = environment.VA; // VA = A * V (implicitly calculated through the matrix-vector product)
72 const auto& Z = environment.Z; // the (requested number of) eigenvectors of the subspace matrix S
73 const auto& Lambda = environment.Lambda; // the (requested number of) eigenvalues of the subspace matrix S
74 const auto& X = environment.X; // contains the new guesses for the eigenvectors (as a linear combination of the current subspace V)
75
76 // Calculate the residual vectors: r_i = VA * z_i - Lambda * x_i
77 environment.R = MatrixX<double>::Zero(dim, this->number_of_requested_eigenpairs);
78 for (size_t column_index = 0; column_index < this->number_of_requested_eigenpairs; column_index++) {
79 environment.R.col(column_index) = VA * Z.col(column_index) - Lambda(column_index) * X.col(column_index);
80 }
81 }
82};
83
84
85} // namespace GQCP
Definition: EigenproblemEnvironment.hpp:35
MatrixX< Scalar > X
Definition: EigenproblemEnvironment.hpp:79
size_t dimension
Definition: EigenproblemEnvironment.hpp:53
MatrixX< Scalar > Z
Definition: EigenproblemEnvironment.hpp:69
VectorX< double > Lambda
Definition: EigenproblemEnvironment.hpp:66
MatrixX< Scalar > VA
Definition: EigenproblemEnvironment.hpp:76
MatrixX< Scalar > R
Definition: EigenproblemEnvironment.hpp:83
Definition: Matrix.hpp:47
Definition: ResidualVectorCalculation.hpp:32
void execute(EigenproblemEnvironment< double > &environment) override
Definition: ResidualVectorCalculation.hpp:67
ResidualVectorCalculation(const size_t number_of_requested_eigenpairs=1)
Definition: ResidualVectorCalculation.hpp:46
std::string description() const override
Definition: ResidualVectorCalculation.hpp:57
Definition: Step.hpp:37
Definition: BaseOneElectronIntegralBuffer.hpp:25