6 #ifndef THEORETICA_MULTI_EXTREMA_H
7 #define THEORETICA_MULTI_EXTREMA_H
9 #include "../core/constants.h"
10 #include "../autodiff/autodiff.h"
31 template<
unsigned int N>
46 unsigned int iter = 0;
57 TH_MATH_ERROR(
"multi_minimize_grad", iter, NO_ALGO_CONVERGENCE);
77 template<
unsigned int N>
100 template<
unsigned int N>
109 unsigned int iter = 0;
131 if(iter > max_iter) {
132 TH_MATH_ERROR(
"multi_minimize_lingrad", iter, NO_ALGO_CONVERGENCE);
151 template<
unsigned int N>
160 unsigned int iter = 0;
182 if(iter > max_iter) {
183 TH_MATH_ERROR(
"multi_maximize_lingrad", iter, NO_ALGO_CONVERGENCE);
200 template<
unsigned int N>
218 template<
unsigned int N>
223 return multi_maximize_lingrad<N>(f, guess, tolerance);
Multidual number algebra for functions of the form .
Definition: multidual.h:26
A statically allocated N-dimensional vector with elements of the given type.
Definition: vec.h:88
Type norm() const
Compute the norm of the vector (sqrt(v * v))
Definition: vec.h:292
#define TH_MATH_ERROR(F_NAME, VALUE, EXCEPTION)
TH_MATH_ERROR is a macro which throws exceptions or modifies errno (depending on which compiling opti...
Definition: error.h:219
Extrema approximation of real functions.
auto gradient(Function f, const Vector &x)
Compute the gradient for a given of a scalar field of the form using automatic differentiation.
Definition: autodiff.h:148
real gamma(unsigned int k)
Gamma special function of positive integer argument.
Definition: special.h:23
Main namespace of the library which contains all functions and objects.
Definition: algebra.h:27
double real
A real number, defined as a floating point type.
Definition: constants.h:188
vec< real, N > multi_maximize_lingrad(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE, unsigned int max_iter=OPTIMIZATION_MINGRAD_ITER)
Find a local maximum of the given multivariate function using gradient descent with linear search.
Definition: multi_extrema.h:152
vec< real, N > multi_minimize_grad(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real gamma=OPTIMIZATION_MINGRAD_GAMMA, real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE, unsigned int max_iter=OPTIMIZATION_MINGRAD_ITER)
Find a local minimum of the given multivariate function using fixed-step gradient descent.
Definition: multi_extrema.h:32
constexpr real OPTIMIZATION_MINGRAD_TOLERANCE
Default tolerance for gradient descent minimization.
Definition: constants.h:308
vec< real, N > multi_maximize_grad(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real gamma=OPTIMIZATION_MINGRAD_GAMMA, real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE, unsigned int max_iter=OPTIMIZATION_MINGRAD_ITER)
Find a local maximum of the given multivariate function using fixed-step gradient descent.
Definition: multi_extrema.h:78
constexpr unsigned int OPTIMIZATION_MINGRAD_ITER
Maximum number of iterations for gradient descent minimization.
Definition: constants.h:311
constexpr real MACH_EPSILON
Machine epsilon for the real type.
Definition: constants.h:197
real maximize_goldensection(RealFunction f, real a, real b)
Approximate a function maximum using the Golden Section search algorithm.
Definition: extrema.h:24
real minimize_goldensection(RealFunction f, real a, real b)
Approximate a function minimum using the Golden Section search algorithm.
Definition: extrema.h:69
vec< real, N > multi_minimize(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE)
Use the best available algorithm to find a local minimum of the given multivariate function.
Definition: multi_extrema.h:201
vec< real, N > multi_minimize_lingrad(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE, unsigned int max_iter=OPTIMIZATION_MINGRAD_ITER)
Find a local minimum of the given multivariate function using gradient descent with linear search.
Definition: multi_extrema.h:101
real nan()
Return a quiet NaN number in floating point representation.
Definition: error.h:54
constexpr real OPTIMIZATION_MINGRAD_GAMMA
Default step size for gradient descent minimization.
Definition: constants.h:305
vec< real, N > multi_maximize(multidual< N >(*f)(vec< multidual< N >, N >), vec< real, N > guess=vec< real, N >(0), real tolerance=OPTIMIZATION_MINGRAD_TOLERANCE)
Use the best available algorithm to find a local maximum of the given multivariate function.
Definition: multi_extrema.h:219