6.4 Argument functions

Some built-in nonlinear solvers, such as ode or optim, require a specific function as argument. For instance in the Scilab command ode(x0,t0,t,fydot), fydot is the specific argument function for the ode primitive. This function can be a either Scilab function or an external function written in C or Fortran. In both cases, the argument function must obey a specific syntax. In the following we will consider, as running example, using the ode primitive with a rhs function written in Fortran. The same steps should be followed for all primitives which require a function as argument.

If the argument function is written in C or Fortran, there are two ways to call it:

In this latter case, to add a new function, two files should be updated:

Many exemples are provided in the default directory. More complex examples are also given. For instance it is shown how to use Scilab variables as optional parameters of fydot.