Optimist  0.0.0
A C++ library for optimization
Loading...
Searching...
No Matches
Optimist::ScalarFunction< Real, DerivedFunction > Class Template Reference

Class container for the scalar function. More...

#include <ScalarFunction.hh>

Inherits Optimist::Function< Real, 1, 1, DerivedFunction >.

Public Member Functions

 ScalarFunction ()
 
std::string name () const
 
void evaluate (Real x, Real &out) const
 
void first_derivative (Real x, Real &out) const
 
void second_derivative (Real x, Real &out) const
 
- Public Member Functions inherited from Optimist::Function< Real, 1, 1, DerivedFunction >
 Function ()
 
std::string name () const
 
void evaluate (const InputType &x, OutputType &out) const
 
void first_derivative (const InputType &x, FirstDerivativeType &out) const
 
void second_derivative (const InputType &x, SecondDerivativeType &out) const
 
constexpr Integer input_dimension () const
 
constexpr Integer output_dimension () const
 
const std::vector< InputType > & solutions () const
 
const std::vector< InputType > & guesses () const
 
const InputTypesolution (const Integer i) const
 
const InputTypeguess (const Integer i) const
 
bool is_solution (const InputType &x, const Real tol=EPSILON_LOW) const
 

Public Attributes

friend Function< Real, 1, 1, ScalarFunction< Real, DerivedFunction > >
 

Additional Inherited Members

- Public Types inherited from Optimist::Function< Real, 1, 1, DerivedFunction >
using InputType
 
using OutputType
 
using FirstDerivativeType
 
using SecondDerivativeType
 
- Protected Attributes inherited from Optimist::Function< Real, 1, 1, DerivedFunction >
std::vector< InputTypem_solutions
 
std::vector< InputTypem_guesses
 

Detailed Description

template<typename Real, typename DerivedFunction>
class Optimist::ScalarFunction< Real, DerivedFunction >

Function

The Function class in Optimist provides a common interface for representing and evaluating mathematical functions. This class is designed to handle a generic function \(\mathbf{f}(\mathbf{x}): \mathbb{R}^{n} \rightarrow \mathbb{R}^{m}\), where \(\mathbf{x}\) is a vector of input variables and \(\mathbf{f}(\mathbf{x})\) is a vector of output values.

The Function class serves as a base class for developing specific function representations that can be used in various numerical algorithms. In general, the Function class and its derived classes are designed to support:

  • Root-finding problems of the form

    \[ \mathbf{f}(\mathbf{x}) = \mathbf{0} \text{,} \quad \text{with} \quad \mathbf{f}: \mathbb{R}^{n} \rightarrow \mathbb{R}^{n} \text{,} \]

  • Optimization problems of the form

    \[ \min_{\mathbf{x}} f(\mathbf{x}) \text{,} \quad f: \mathbb{R}^{n} \rightarrow \mathbb{R} \text{.} \]

If \(n > 1\), the function is multi-dimensional, otherwise, it is scalar. The linear algebra operations required for multi-dimensional functions are performed using the Eigen library, which provides a high-level interface for matrix operations. For scalar functions ( \(n = 1\)), the base type changes to Real, a scalar type defined in the Optimist library.

Template Parameters
RealScalar number type.
DerivedFunctionDerived scalar function class.

Constructor & Destructor Documentation

◆ ScalarFunction()

template<typename Real, typename DerivedFunction>
Optimist::ScalarFunction< Real, DerivedFunction >::ScalarFunction ( )
inline

Class constructor for the function.

Member Function Documentation

◆ evaluate()

template<typename Real, typename DerivedFunction>
void Optimist::ScalarFunction< Real, DerivedFunction >::evaluate ( Real x,
Real & out ) const
inline

Compute the function value at the input point.

Parameters
[in]xInput point.
[out]outThe function value.

◆ first_derivative()

template<typename Real, typename DerivedFunction>
void Optimist::ScalarFunction< Real, DerivedFunction >::first_derivative ( Real x,
Real & out ) const
inline

Compute the function first derivative at the input point.

Parameters
[in]xInput point.
[out]outThe function first derivative.

◆ name()

template<typename Real, typename DerivedFunction>
std::string Optimist::ScalarFunction< Real, DerivedFunction >::name ( ) const
inline

Get the function name.

Returns
The function name.

◆ second_derivative()

template<typename Real, typename DerivedFunction>
void Optimist::ScalarFunction< Real, DerivedFunction >::second_derivative ( Real x,
Real & out ) const
inline

Compute the function second derivative at the input point.

Parameters
[in]xInput point.
[out]outThe function second derivative.

Member Data Documentation

◆ Function< Real, 1, 1, ScalarFunction< Real, DerivedFunction > >

template<typename Real, typename DerivedFunction>
friend Optimist::ScalarFunction< Real, DerivedFunction >::Function< Real, 1, 1, ScalarFunction< Real, DerivedFunction > >

The documentation for this class was generated from the following file: