# Class FirstOrderNonLinearR¶

class FirstOrderNonLinearR : public FirstOrderR

Pointer to function for plug-in for operators related to input and its gradients.

FirstOrder Non Linear Relation.

This is the most generic relation for First Order Dynamical Systems, with:

$\begin{split}y &=& h(X,t,\lambda,Z) \\ R &=& g(X,t,\lambda,Z)\end{split}$

where X, Z, and R corresponds to DynamicalSystem variables. If more than 2 DynamicalSystem are involved in the Interaction, then X = [x1 x2], Z=[z1 z2] R = [r1 r2].

$$y$$ and $$\lambda$$ are specific variables of the Interaction (see this class for more details).

Let us define the following jacobians:

$\begin{split}C &=& \nabla_x h\\ B &=& \nabla_{lambda} g\\ D &=& \nabla_{lambda} h\\ K &=& \nabla_x g.\end{split}$

There are 2 ways to define this relation:

• by using the plugin mechanism of calling C functions

• by using the inheritance mechanism (of C++ or Python) and overloading methods.

For the plugins, the following definitions are mandatory:

• A function to compute $$h$$ with signature

(double time, unsigned x_size, double *x, unsigned size_lambda, double* lambda, double *y, unsigned z_size, double *z)


• A function to compute $$g$$ with signature

(double time, unsigned x_size, double *x, unsigned size_lambda, double* lambda, double *r, unsigned z_size, double *z)


Note that the size of $$y$$ is the same as $$\lambda$$, and the size of $$R$$ is the same as $$X$$. Thus those are not specified in the plugin function signatures.

For the various jacobians, there are two possibilities: If one is constant, the value may directly be set: for instance, if $$C$$ is constant, then one can use setCPtr to fix the value. A word of cautions: whenever a jacobian matrix is fixed using this call, then the corresponding C++ function (and not plugin) is not called anymore. A small example: if $$C$$ is fixed via setCPtr, then computeJachx is never called again.

The other option is to use the plugin mechanism. They all share the same signature:

(double time, unsigned x_size, double *x, unsigned size_lambda, double* lambda, double *mat, unsigned z_size, double *z)

where mat is the pointer to the array of values for each Jacobian. This implies that only dense matrix are supported.

Public Functions

FirstOrderNonLinearR()

basic constructor

virtual ~FirstOrderNonLinearR()

destructor

virtual void checkSize(Interaction &inter)

check sizes of the relation specific operators.

Parameters
• inter: an Interaction using this relation

virtual void computeg(double time, SiconosVector &x, SiconosVector &lambda, SiconosVector &z, SiconosVector &r)

default function to compute $$g$$

Parameters
• time: current time

• x: current state variables

• lambda: current nonsmooth variables

• z: current auxiliary variable

• [out] r: input value

virtual void computeh(double time, SiconosVector &x, SiconosVector &lambda, SiconosVector &z, SiconosVector &y)

default function to compute $$h$$

Parameters
• time: current time

• x: current state variables

• lambda: current nonsmooth variables

• z: current auxiliary variable

• [out] y: output value

virtual void computeJacglambda(double time, SiconosVector &x, SiconosVector &lambda, SiconosVector &z, SimpleMatrix &B)

default function to compute $$B = \nabla_{\lambda}g$$

Parameters
• time: current time

• x: current state variables

• lambda: current nonsmooth variables

• z: current auxiliary variables

• [out] B: jacobian matrix

virtual void computeJach(double time, Interaction &inter)

compute all the H Jacobian

Parameters
• time: the current time

• inter: the interaction using this relation

virtual void computeJachlambda(double time, SiconosVector &x, SiconosVector &lambda, SiconosVector &z, SimpleMatrix &D)

default function to compute $$D = \nabla_{\lambda} h$$

Parameters
• time: current time

• x: current state variables

• lambda: current nonsmooth variables

• z: current auxiliary variables

• [out] D: jacobian matrix

virtual void computeJachx(double time, SiconosVector &x, SiconosVector &lambda, SiconosVector &z, SimpleMatrix &C)

default function to compute $$C = \nabla_x h$$

Parameters
• time: current time

• x: current state variables

• lambda: current nonsmooth variables

• z: current auxiliary variable

• [out] C: jacobian matrix

void initialize(Interaction &inter)

initialize the relation (check sizes, memory allocation …)

Parameters
• inter: the interaction using this relation