GQCP
Loading...
Searching...
No Matches
NewtonStepUpdate.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
26
27#include <type_traits>
28
29
30namespace GQCP {
31namespace Minimization {
32
33
40template <typename _Scalar, typename _Environment>
42 public Step<_Environment> {
43
44public:
45 using Scalar = _Scalar;
46 using Environment = _Environment;
47 static_assert(std::is_same<Scalar, typename Environment::Scalar>::value, "The scalar type must match that of the environment");
48 static_assert(std::is_base_of<MinimizationEnvironment<Scalar>, Environment>::value, "The environment type must derive from MinimizationEnvironment.");
49
50
51public:
52 /*
53 * PUBLIC OVERRIDDEN METHODS
54 */
55
59 std::string description() const override {
60 return "Calculate a new iteration of the variables and add them to the environment.";
61 }
62
63
69 void execute(Environment& environment) override {
70
71 // Use the non-linear equation Newton step as an implementation
72 const auto& variables = environment.variables.back();
73 const auto& f = environment.gradient_function;
74 const auto& J = environment.hessian_function;
75
76 GQCP::NonLinearEquationEnvironment<Scalar> non_linear_environment {variables, f, J};
77 GQCP::NonLinearEquation::NewtonStepUpdate<Scalar, NonLinearEquationEnvironment<Scalar>>().execute(non_linear_environment); // this adds the Newton-step updated variables to the non-linear environment
78
79 const auto& new_variables = non_linear_environment.variables.back();
80 environment.variables.push_back(new_variables);
81 }
82};
83
84
85} // namespace Minimization
86} // namespace GQCP
Definition: NewtonStepUpdate.hpp:42
_Scalar Scalar
Definition: NewtonStepUpdate.hpp:45
_Environment Environment
Definition: NewtonStepUpdate.hpp:46
void execute(Environment &environment) override
Definition: NewtonStepUpdate.hpp:69
std::string description() const override
Definition: NewtonStepUpdate.hpp:59
Definition: NewtonStepUpdate.hpp:44
Definition: NonLinearEquationEnvironment.hpp:35
Definition: Step.hpp:37
Definition: BaseOneElectronIntegralBuffer.hpp:25