Abstract function with an arbitrary number of parameters and values. ON_Evaluator is used to pass functions to local solvers. More...
#include <opennurbs_math.h>
Public Member Functions | |
ON_Evaluator (int parameter_count, int value_count, const ON_Interval *domain, const bool *periodic) | |
Construction of the class for a function that takes parameter_count input functions and returns value_count values. If the domain is infinite, pass a nullptr for the domain[] and periodic[] arrays. If the domain is finite, pass a domain[] array with parameter_count increasing intervals. If one or more of the parameters is periodic, pass the fundamental domain in the domain[] array and a true in the periodic[] array. More... | |
virtual | ~ON_Evaluator () |
ON_Interval | Domain (int parameter_index) const |
If a function has a periodic parameter, then the m_domain interval for that parameter is the fundamental domain and the m_bPeriodicParameter bool for that parameter is true. A parameter is periodic if, and only if, m_domain.Count() == m_parameter_count, and m_bPeriodicParameter.Count() == m_parameter_count, and m_bPeriodicParameter[parameter_index] is true. More... | |
virtual int | Evaluate (const double *parameters, double *values, double **jacobian)=0 |
Evaluate the function that takes m_parameter_count parameters and returns a m_value_count dimensional point. More... | |
virtual int | EvaluateHessian (const double *parameters, double *value, double *gradient, double **hessian) |
OPTIONAL ability to evaluate the hessian in the case when m_value_count is one. If your function has more that one value or it is not feasable to evaluate the hessian, then do not override this function. The default implementation returns -1. More... | |
bool | FiniteDomain () const |
Functions can have finite or infinite domains. Finite domains are specified by passing the domain[] array to the constructor or filling in the m_domain[] member variable. If m_domain.Count() == m_parameter_count > 0, then the function has finite domains. More... | |
bool | Periodic (int parameter_index) const |
If a function has a periodic parameter, then the m_domain interval for that parameter is the fundamental domain and the m_bPeriodicParameter bool for that parameter is true. A parameter is periodic if, and only if, m_domain.Count() == m_parameter_count, and m_bPeriodicParameter.Count() == m_parameter_count, and m_bPeriodicParameter[parameter_index] is true. More... | |
Public Attributes | |
ON_SimpleArray< bool > | m_bPeriodicParameter |
ON_SimpleArray< ON_Interval > | m_domain |
const int | m_parameter_count |
const int | m_value_count |
Abstract function with an arbitrary number of parameters and values. ON_Evaluator is used to pass functions to local solvers.
ON_Evaluator::ON_Evaluator | ( | int | parameter_count, |
int | value_count, | ||
const ON_Interval * | domain, | ||
const bool * | periodic | ||
) |
Construction of the class for a function that takes parameter_count input functions and returns value_count values. If the domain is infinite, pass a nullptr for the domain[] and periodic[] arrays. If the domain is finite, pass a domain[] array with parameter_count increasing intervals. If one or more of the parameters is periodic, pass the fundamental domain in the domain[] array and a true in the periodic[] array.
parameter_count | [in] >= 1. Number of input parameters |
value_count | [in] >= 1. Number of output values. |
domain | [in] If not nullptr, then this is an array of parameter_count increasing intervals that defines the domain of the function. |
periodic | [in] if not nullptr, then this is an array of parameter_count bools where b[i] is true if the i-th parameter is periodic. Valid increasing finite domains must be specificed when this parameter is not nullptr. |
|
virtual |
ON_Interval ON_Evaluator::Domain | ( | int | parameter_index | ) | const |
If a function has a periodic parameter, then the m_domain interval for that parameter is the fundamental domain and the m_bPeriodicParameter bool for that parameter is true. A parameter is periodic if, and only if, m_domain.Count() == m_parameter_count, and m_bPeriodicParameter.Count() == m_parameter_count, and m_bPeriodicParameter[parameter_index] is true.
|
pure virtual |
Evaluate the function that takes m_parameter_count parameters and returns a m_value_count dimensional point.
parameters | [in] array of m_parameter_count evaluation parameters |
values | [out] array of m_value_count function values |
jacobian | [out] If nullptr, simply evaluate the value of the function. If not nullptr, this is the jacobian of the function. jacobian[i][j] = j-th partial of the i-th value 0 <= i < m_value_count, 0 <= j < m_parameter_count If not nullptr, then all the memory for the jacobian is allocated, you just need to fill in the answers. |
|
virtual |
OPTIONAL ability to evaluate the hessian in the case when m_value_count is one. If your function has more that one value or it is not feasable to evaluate the hessian, then do not override this function. The default implementation returns -1.
parameters | [in] array of m_parameter_count evaluation parameters |
value | [out] value of the function (one double) |
gradient | [out] The gradient of the function. This is a vector of length m_parameter_count; gradient[i] is the first partial of the function with respect to the i-th parameter. |
hessian | [out] The hessian of the function. This is an m_parameter_count x m_parameter_count symmetric matrix: hessian[i][j] is the second partial of the function with respect to the i-th and j-th parameters. The evaluator is responsible for filling in both the upper and lower triangles. Since the matrix is symmetrix, you should do something like evaluate the upper triangle and copy the values to the lower tiangle. |
bool ON_Evaluator::FiniteDomain | ( | ) | const |
Functions can have finite or infinite domains. Finite domains are specified by passing the domain[] array to the constructor or filling in the m_domain[] member variable. If m_domain.Count() == m_parameter_count > 0, then the function has finite domains.
bool ON_Evaluator::Periodic | ( | int | parameter_index | ) | const |
If a function has a periodic parameter, then the m_domain interval for that parameter is the fundamental domain and the m_bPeriodicParameter bool for that parameter is true. A parameter is periodic if, and only if, m_domain.Count() == m_parameter_count, and m_bPeriodicParameter.Count() == m_parameter_count, and m_bPeriodicParameter[parameter_index] is true.
ON_SimpleArray<bool> ON_Evaluator::m_bPeriodicParameter |
ON_SimpleArray<ON_Interval> ON_Evaluator::m_domain |
const int ON_Evaluator::m_parameter_count |
const int ON_Evaluator::m_value_count |