13#ifndef OPTIMIST_ROOTFINDER_HH
14#define OPTIMIST_ROOTFINDER_HH
46 template <
typename Real, Integer N,
typename DerivedSolver,
bool ForceEigen = false>
51 static_assert(N != 0,
"Are you sure you want to solve a zero-dimensional system of equations?");
76 std::string
name()
const {
return static_cast<const DerivedSolver *
>(
this)->name_impl();}
129 template <
typename JacobianLambda>
143 template <
typename HessianLambda>
158 template <
typename FunctionLambda>
161 #define CMD "Optimist::RootFinder::solve(...): "
163 static_assert(DerivedSolver::requires_function,
164 CMD "the solver requires a function.");
165 return static_cast<DerivedSolver *
>(
this)->solve_impl(
166 std::forward<FunctionLambda>(function),
182 template <
typename FunctionLambda,
typename JacobianLambda>
183 bool solve(FunctionLambda && function, JacobianLambda && jacobian,
Vector const & x_ini,
186 #define CMD "Optimist::RootFinder::solve(...): "
188 static_assert(DerivedSolver::requires_function,
189 CMD "the solver requires a function.");
190 static_assert(DerivedSolver::requires_first_derivative,
191 CMD "the solver requires the first derivative.");
192 return static_cast<DerivedSolver *
>(
this)->solve_impl(
193 std::forward<FunctionLambda>(function),
194 std::forward<JacobianLambda>(jacobian),
212 template <
typename FunctionLambda,
typename JacobianLambda,
typename HessianLambda>
213 bool solve(FunctionLambda && function, JacobianLambda && jacobian, HessianLambda && hessian,
216 #define CMD "Optimist::RootFinder::solve(...): "
218 static_assert(DerivedSolver::requires_function,
219 CMD "the solver requires the function.");
220 static_assert(DerivedSolver::requires_first_derivative,
221 CMD "the solver requires the first derivative.");
222 static_assert(DerivedSolver::requires_second_derivative,
223 CMD "the solver requires the second derivative.");
224 return static_cast<DerivedSolver *
>(
this)->solve_impl(
225 std::forward<FunctionLambda>(function),
226 std::forward<JacobianLambda>(jacobian),
227 std::forward<HessianLambda>(hessian),
245 template <
typename Real,
typename DerivedSolver>
265 std::string
name()
const {
return static_cast<const DerivedSolver *
>(
this)->name_impl();}
275 template <
typename FunctionLambda>
276 bool solve(FunctionLambda && function, Real x_ini, Real & x_sol)
278 return static_cast<DerivedSolver *
>(
this)->solve_impl(
279 std::forward<FunctionLambda>(function),
293 template <
typename FunctionLambda,
typename FirstDerivativeLambda>
294 bool solve(FunctionLambda && function, FirstDerivativeLambda && first_derivative, Real x_ini,
297 return static_cast<DerivedSolver *
>(
this)->solve_impl(
298 std::forward<FunctionLambda>(function),
299 std::forward<FirstDerivativeLambda>(first_derivative),
315 template <
typename FunctionLambda,
typename FirstDerivativeLambda,
typename SecondDerivativeLambda>
316 bool solve(FunctionLambda && function, FirstDerivativeLambda && first_derivative, SecondDerivativeLambda
317 && second_derivate, Real x_ini, Real & x_sol)
319 return static_cast<DerivedSolver *
>(
this)->solve_impl(
320 std::forward<FunctionLambda>(function),
321 std::forward<FirstDerivativeLambda>(first_derivative),
322 std::forward<SecondDerivativeLambda>(second_derivate),
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:71
bool solve(FunctionLambda &&function, Real x_ini, Real &x_sol)
Definition RootFinder.hh:276
bool solve(FunctionLambda &&function, FirstDerivativeLambda &&first_derivative, SecondDerivativeLambda &&second_derivate, Real x_ini, Real &x_sol)
Definition RootFinder.hh:316
static constexpr bool is_optimizer
Definition RootFinder.hh:252
std::string name() const
Definition RootFinder.hh:265
RootFinder()
Definition RootFinder.hh:259
static constexpr bool is_rootfinder
Definition RootFinder.hh:251
bool solve(FunctionLambda &&function, FirstDerivativeLambda &&first_derivative, Real x_ini, Real &x_sol)
Definition RootFinder.hh:294
Class container for the multi-dimensional root finder.
Definition RootFinder.hh:48
bool solve(FunctionLambda &&function, Vector const &x_ini, Vector &x_sol)
Definition RootFinder.hh:159
bool solve(FunctionLambda &&function, JacobianLambda &&jacobian, HessianLambda &&hessian, Vector const &x_ini, Vector &x_sol)
Definition RootFinder.hh:213
static constexpr bool is_optimizer
Definition RootFinder.hh:56
void max_jacobian_evaluations(Integer t_jacobian_evaluations)
Definition RootFinder.hh:94
std::string name() const
Definition RootFinder.hh:76
typename SolverBase< Real, N, N, DerivedSolver, ForceEigen >::InputType Vector
Definition RootFinder.hh:61
void max_hessian_evaluations(Integer t_hessian_evaluations)
Definition RootFinder.hh:115
bool evaluate_hessian(HessianLambda &&hessian, Vector const &x, Matrix &out)
Definition RootFinder.hh:144
typename SolverBase< Real, N, N, DerivedSolver, ForceEigen >::SecondDerivativeType Tensor
Definition RootFinder.hh:65
RootFinder()
Definition RootFinder.hh:70
bool evaluate_jacobian(JacobianLambda &&jacobian, Vector const &x, Matrix &out)
Definition RootFinder.hh:130
typename SolverBase< Real, N, N, DerivedSolver, ForceEigen >::FirstDerivativeType Matrix
Definition RootFinder.hh:64
Integer hessian_evaluations() const
Definition RootFinder.hh:103
Integer jacobian_evaluations() const
Definition RootFinder.hh:82
static constexpr bool is_rootfinder
Definition RootFinder.hh:55
bool solve(FunctionLambda &&function, JacobianLambda &&jacobian, Vector const &x_ini, Vector &x_sol)
Definition RootFinder.hh:183
Integer max_jacobian_evaluations() const
Definition RootFinder.hh:88
Integer max_hessian_evaluations() const
Definition RootFinder.hh:109
bool evaluate_second_derivative(SecondDerivativeLambda &&function, InputType const &x, SecondDerivativeType &out)
Definition SolverBase.hh:801
Integer max_first_derivative_evaluations() const
Definition SolverBase.hh:289
SolverBase()
Definition SolverBase.hh:105
std::conditional_t< ForceEigen||(SolInDim > 1)||(SolOutDim > 1), std::conditional_t< SolInDim==1||SolOutDim==1, Eigen::Matrix< Real, SolInDim, SolInDim >, std::vector< Eigen::Matrix< Real, SolInDim, SolInDim > > >, Real > SecondDerivativeType
Definition SolverBase.hh:64
typename std::conditional_t< ForceEigen||(SolInDim > 1), Eigen::Vector< Real, SolInDim >, Real > InputType
Definition SolverBase.hh:53
std::conditional_t< ForceEigen||(SolInDim > 1)||(SolOutDim > 1), Eigen::Matrix< Real, SolOutDim, SolInDim >, Real > FirstDerivativeType
Definition SolverBase.hh:62
Integer first_derivative_evaluations() const
Definition SolverBase.hh:283
bool evaluate_first_derivative(FirstDerivativeLambda &&function, InputType const &x, FirstDerivativeType &out)
Definition SolverBase.hh:785
Namespace for the Optimist library.
Definition Optimist.hh:88
OPTIMIST_DEFAULT_INTEGER_TYPE Integer
The Integer type as used for the API.
Definition Optimist.hh:96