13#ifndef OPTIMIST_ROOT_FINDER_HH
14#define OPTIMIST_ROOT_FINDER_HH
45 template <
typename Real, Integer N,
typename DerivedSolver>
50 static_assert(N !=
static_cast<Integer>(0),
51 "Are you sure you want to solve a zero-dimensional system of equations?");
52 static_assert(N !=
static_cast<Integer>(1),
53 "C'mon, let's not kid ourselves. Use a scalar solver...");
89 std::string
name()
const {
return static_cast<const DerivedSolver *
>(
this)->name_impl();}
166 #define CMD "Optimist::RootFinder::solve(...): "
168 static_assert(DerivedSolver::requires_function,
169 CMD "the solver requires a function.");
170 return static_cast<DerivedSolver *
>(
this)->solve_impl(function, x_ini, x_sol);
185 #define CMD "Optimist::RootFinder::solve(...): "
187 static_assert(DerivedSolver::requires_function,
188 CMD "the solver requires a function.");
189 static_assert(DerivedSolver::requires_first_derivative,
190 CMD "the solver requires the first derivative.");
191 return static_cast<DerivedSolver *
>(
this)->solve_impl(function, jacobian, x_ini, x_sol);
206 const & x_ini,
Vector & x_sol)
208 #define CMD "Optimist::RootFinder::solve(...): "
210 static_assert(DerivedSolver::requires_function,
211 CMD "the solver requires the function.");
212 static_assert(DerivedSolver::requires_first_derivative,
213 CMD "the solver requires the first derivative.");
214 static_assert(DerivedSolver::requires_second_derivative,
215 CMD "the solver requires the second derivative.");
216 return static_cast<DerivedSolver *
>(
this)->solve_impl(function, jacobian, hessian, x_ini, x_sol);
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:70
Class container for the multi-dimensional root finder.
Definition RootFinder.hh:47
static constexpr bool is_optimizer
Definition RootFinder.hh:58
Integer max_hessian_evaluations() const
Definition RootFinder.hh:122
static constexpr bool requires_function
Definition RootFinder.hh:60
RootFinder()
Definition RootFinder.hh:83
typename Solver< Real, N, N, DerivedSolver >::FirstDerivativeWrapper JacobianWrapper
Definition RootFinder.hh:77
typename Solver< Real, N, N, DerivedSolver >::InputType Vector
Definition RootFinder.hh:69
std::string name() const
Definition RootFinder.hh:89
void max_hessian_evaluations(Integer t_hessian_evaluations)
Definition RootFinder.hh:128
Integer max_jacobian_evaluations() const
Definition RootFinder.hh:101
void max_jacobian_evaluations(Integer t_jacobian_evaluations)
Definition RootFinder.hh:107
void evaluate_jacobian(JacobianWrapper jacobian, const Vector &x, Matrix &out)
Definition RootFinder.hh:140
typename Solver< Real, N, N, DerivedSolver >::SecondDerivativeType Tensor
Definition RootFinder.hh:73
static constexpr bool is_rootfinder
Definition RootFinder.hh:57
typename Solver< Real, N, N, DerivedSolver >::FunctionWrapper FunctionWrapper
Definition RootFinder.hh:76
static constexpr bool requires_second_derivative
Definition RootFinder.hh:62
static constexpr bool requires_first_derivative
Definition RootFinder.hh:61
void evaluate_hessian(HessianWrapper hessian, const Vector &x, Matrix &out)
Definition RootFinder.hh:151
typename Solver< Real, N, N, DerivedSolver >::SecondDerivativeWrapper HessianWrapper
Definition RootFinder.hh:78
Integer hessian_evaluations() const
Definition RootFinder.hh:116
bool solve(FunctionWrapper function, Vector const &x_ini, Vector &x_sol)
Definition RootFinder.hh:164
bool solve(FunctionWrapper function, JacobianWrapper jacobian, Vector const &x_ini, Vector &x_sol)
Definition RootFinder.hh:183
typename Solver< Real, N, N, DerivedSolver >::FirstDerivativeType Matrix
Definition RootFinder.hh:72
bool solve(FunctionWrapper function, JacobianWrapper jacobian, HessianWrapper hessian, Vector const &x_ini, Vector &x_sol)
Definition RootFinder.hh:205
Integer jacobian_evaluations() const
Definition RootFinder.hh:95
Class container for the generic root-finding/optimization problem solver.
Definition Solver.hh:43
Integer first_derivative_evaluations() const
Definition Solver.hh:266
Solver()
Definition Solver.hh:106
typename std::conditional_t< SolInDim==1, Real, Eigen::Vector< Real, SolInDim > > InputType
Definition Solver.hh:53
typename std::function< void(const InputType &, FirstDerivativeType &)> FirstDerivativeWrapper
Definition Solver.hh:67
std::conditional_t< SolInDim==1 &&SolOutDim==1, Real, std::conditional_t< SolInDim==1||SolOutDim==1, Eigen::Matrix< Real, SolInDim, SolInDim >, std::vector< Eigen::Matrix< Real, SolInDim, SolInDim > > > > SecondDerivativeType
Definition Solver.hh:61
Integer max_first_derivative_evaluations() const
Definition Solver.hh:272
typename std::function< void(const InputType &, SecondDerivativeType &)> SecondDerivativeWrapper
Definition Solver.hh:68
typename std::function< void(const InputType &, OutputType &)> FunctionWrapper
Definition Solver.hh:66
void evaluate_first_derivative(FirstDerivativeWrapper function, const InputType &x, FirstDerivativeType &out)
Definition Solver.hh:724
std::conditional_t< SolInDim==1 &&SolOutDim==1, Real, Eigen::Matrix< Real, SolOutDim, SolInDim > > FirstDerivativeType
Definition Solver.hh:60
void evaluate_second_derivative(SecondDerivativeWrapper function, const InputType &x, SecondDerivativeType &out)
Definition Solver.hh:738
Namespace for the Optimist library.
Definition Optimist.hh:87
OPTIMIST_DEFAULT_INTEGER_TYPE Integer
The Integer type as used for the API.
Definition Optimist.hh:95