GQCP
Loading...
Searching...
No Matches
ResidualVectorConvergence.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
32template <typename _Environment>
34 public ConvergenceCriterion<_Environment> {
35
36public:
37 using Environment = _Environment;
38
39
40private:
41 double threshold; // the threshold that is used in checking the norm of the residual vectors
42
43
44public:
45 /*
46 * CONSTRUCTORS
47 */
48
52 ResidualVectorConvergence(const double threshold = 1.0e-08) :
53 threshold {threshold} {}
54
55
56 /*
57 * PUBLIC OVERRIDDEN METHODS
58 */
59
63 std::string description() const override {
64 return "A convergence criterion that checks if the norm of each of the residual vectors is smaller than a threshold.";
65 }
66
67
73 bool isFulfilled(Environment& environment) override {
74
75 const auto& R = environment.R; // the residual vectors
76
77 if (R.cols() > 0) { // if there are residual vectors available
78 const auto are_any_values_larger = (R.colwise().norm().array() > this->threshold).any();
79 return !are_any_values_larger;
80 }
81
82 return false; // there aren't any residual vectors available
83 }
84};
85
86
87} // namespace GQCP
Definition: ConvergenceCriterion.hpp:33
Definition: ResidualVectorConvergence.hpp:34
std::string description() const override
Definition: ResidualVectorConvergence.hpp:63
ResidualVectorConvergence(const double threshold=1.0e-08)
Definition: ResidualVectorConvergence.hpp:52
_Environment Environment
Definition: ResidualVectorConvergence.hpp:37
bool isFulfilled(Environment &environment) override
Definition: ResidualVectorConvergence.hpp:73
Definition: BaseOneElectronIntegralBuffer.hpp:25