Optimist
0.0.0
A C++ library for optimization
|
Class container for the quadratic function. More...
#include <Quadratic.hh>
Inherits Optimist::Function< Real, 1, 1, Quadratic< Real > >.
Public Member Functions | |
Quadratic () | |
std::string | name_impl () const |
void | evaluate_impl (Real x, Real &out) const |
void | first_derivative_impl (Real x, Real &out) const |
void | second_derivative_impl (Real, Real &out) const |
Public Member Functions inherited from Optimist::Function< Real, 1, 1, Quadratic< Real > > | |
Function () | |
std::string | name () const |
void | evaluate (const InputVector &x, OutputVector &out) const |
void | jacobian (const InputVector &x, Matrix &out) const |
void | hessian (const InputVector &x, Tensor &out) const |
Public Member Functions inherited from Optimist::FunctionBase< Real, N, M, Quadratic< Real >, false > | |
FunctionBase () | |
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 InputType & | solution (const Integer i) const |
const InputType & | guess (const Integer i) const |
bool | is_solution (const InputType &x, const Real tol=EPSILON_LOW) const |
Private Attributes | |
Real | m_a {1.0} |
Real | m_b {1.0} |
Real | m_c {-1.0} |
Additional Inherited Members | |
Public Types inherited from Optimist::Function< Real, 1, 1, Quadratic< Real > > | |
using | InputVector |
using | OutputVector |
using | Matrix |
using | Tensor |
Public Types inherited from Optimist::FunctionBase< Real, N, M, Quadratic< Real >, false > | |
using | InputType |
using | OutputType |
using | FirstDerivativeType |
using | SecondDerivativeType |
Protected Attributes inherited from Optimist::FunctionBase< Real, N, M, Quadratic< Real >, false > | |
std::vector< InputType > | m_solutions |
std::vector< InputType > | m_guesses |
Class container for the quadratic function, which is defined as:
\[f(x) = ax^2 + bx + c \text{.} \]
The function has roots at
\[x = \sqrt{\displaystyle\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}} \text{,} \]
and a minimum at
\[x = -\displaystyle\frac{b}{2a} \text{.} \]
The default coefficients are \(a = 1\), \(b = 1\), and \(c = -1\), and the function initial guess is \(x = 0\).
Real | Scalar number type. |
|
inline |
< Basic constants. Class constructor for the quadratic function.
|
inline |
Compute the function value at the input point.
[in] | x | Input point. |
[out] | out | The function value. |
|
inline |
Compute the first derivative value at the input point.
[in] | x | Input point. |
[out] | out | The first derivative value. |
|
inline |
Get the function name.
|
inline |
Compute the second derivative value at the input point.
[in] | x | Input point. |
[out] | out | The second derivative value. |
|
private |
Coefficient \(a\).
|
private |
Coefficient \(b\).
|
private |
Coefficient \(c\).