User function interface
In its simplest form, a user function is exactly the same as any other mathematical function: it takes a set of arguments (constants or values of variables) and returns a value as its result. In this form, which is the usual implementation, the function needs no information apart from the values of its arguments. It is possible to create more complicated functions which do use external data in some form: these are discussed at the end of this section.
Xpress NonLinear supports two basic forms of user function. The simple form of function returns a single value, and is treated in essentially the same way as a normal mathematical function. The general form of function returns an array of values and may also perform automatic differentiation.
The main difference between the simple and general form of a user function is in the way the value is returned.
- The simple function calculates and returns one value and is declared as such (for example, double in C).
- The general function calculates an array of values. It can either return the array itself (and is declared as such: double * ), or it can return the results in one of the function arguments, in which case the function itself returns a single (double precision) status value (and is declared as such: double).