Nonlinear operator¶
The class NonLinearOperator
consists of a collection of a function and its derivatives, including their dependence
on parameters.
Let us assume a function f(x)
and its derivative df(x)
.
Then, a NonLinearOperator
can be constructed as follows:
double x = 13;
auto fvLambda = [&](auto&& x) { return f(x); };
auto dfvLambda = [&](auto&& x) { return df(x); };
auto nonLinOp = Ikarus::NonLinearOperator(linearAlgebraFunctions(fvLambda, dfvLambda), parameter(x));
Note
It is assumed that the second function is the derivative of the first function, the third function is the derivative of the second function (2nd derivative of the first function), and so on.
linearAlgebraFunctions(...)
and parameter(...)
are helper functions. They are necessary to distinguish which argument is a function and which argument is a parameter.
nonLinOp
provides the following features:
void updateAll() // (1)!
void update<n>() // (2)!
auto& value() // (3)!
auto& derivative() // (4)!
auto& secondDerivative() // (5)!
auto& nthDerivative<n>() // (6)!
auto& firstParameter() // (7)!
auto& secondParameter() // (8)!
auto& nthParameter<n>() // (9)!
auto& lastParameter() // (10)!
auto subOperator<n,m,...>() // (11)!
- Evaluates all functions.
- Evaluates the n-th function in
linearAlgebraFunctions(...)
. Counting starts from 0, as always in C++. - Returns the result of the function evaluation.
- Returns the result of the evaluation of the first derivative (if the function for the first derivative is passed to the nonlinear operator during construction).
- Returns the result of the evaluation of the second derivative (if the function for the second derivative is passed to the nonlinear operator during construction).
- Returns the result of the evaluation of the n-th derivative (if the function for the n-th derivative is passed to the nonlinear operator during construction).
- Returns the value of the first parameter.
- Returns the value of the second parameter (if available).
- Returns the value of the n-th parameter (if available).
- Returns the value of the last parameter.
- Creates an
Ikarus::NonLinearOperator
with a subset of the derivatives. For example, let us consider a nonlinear operator with (function, first derivative, second derivative).subOperator<0,1>()
then returns a nonlinear operator with (function, first derivative).