23#include "Mathematical/Optimization/LinearEquation/LinearEquationEnvironment.hpp"
24#include "Mathematical/Optimization/LinearEquation/LinearEquationSolver.hpp"
32namespace NonLinearEquation {
42template <
typename _Scalar,
typename _Environment,
typename LinearSolver = decltype(LinearEquationSolver<_Scalar>::ColPivHouseholderQR())>
44 public Step<_Environment> {
49 static_assert(std::is_same<Scalar, typename Environment::Scalar>::value,
"The scalar type must match that of the environment");
50 static_assert(std::is_base_of<NonLinearEquationEnvironment<Scalar>,
Environment>::value,
"The environment type must derive from NonLinearEquationEnvironment.");
54 LinearSolver linear_solver;
65 NewtonStepUpdate(
const LinearSolver& linear_solver = LinearEquationSolver<Scalar>::ColPivHouseholderQR()) :
66 linear_solver {linear_solver} {}
77 return "Calculate a new iteration of the variables and add them to the environment.";
88 const auto&
x = environment.variables.back();
89 const auto& f = environment.f;
90 const auto& J = environment.J;
97 auto linear_environment = LinearEquationEnvironment<Scalar>(J_matrix, -f_vector);
98 this->linear_solver.perform(linear_environment);
100 const auto dx = linear_environment.x;
101 environment.variables.push_back(
x + dx);
Definition: Matrix.hpp:47
Definition: NewtonStepUpdate.hpp:44
_Environment Environment
Definition: NewtonStepUpdate.hpp:48
std::string description() const override
Definition: NewtonStepUpdate.hpp:76
void execute(Environment &environment) override
Definition: NewtonStepUpdate.hpp:86
_Scalar Scalar
Definition: NewtonStepUpdate.hpp:47
NewtonStepUpdate(const LinearSolver &linear_solver=LinearEquationSolver< Scalar >::ColPivHouseholderQR())
Definition: NewtonStepUpdate.hpp:65
Definition: SquareMatrix.hpp:39
Definition: BaseOneElectronIntegralBuffer.hpp:25
@ x
Definition: CartesianDirection.hpp:28