[R-sig-dyn-mod] deSolve with compiled code and varying size of parms

Rampal Etienne rampaletienne at gmail.com
Thu Mar 30 11:06:06 CEST 2017


Thanks for these clarifications by Tim and Thomas. I'd like to see the 
UNIONs solution.

But how does one deal with all this in a package? A DLL or .so should be 
stored somewhere in the package, or - if it is compiled at runtime - it 
must be stored somewhere at the user's computer where it can be readily 
found.

I guess odeintr is a bit more flexible in that it does not need to save 
a file somewhere.

RSE

On 30-Mar-17 08:36, Thomas Petzoldt wrote:
> Hi,
>
> Am 30.03.2017 um 00:41 schrieb Tim Keitt:
>> Unlike more
>> integrated solvers, that framework puts more onus on the user to not 
>> supply
>> invalid parameters, or perhaps it would be better to say that the 
>> user has
>> to avoid certain corner cases.
>
> Tim made a good point here. It is not easy to prevent all corner cases 
> that potentially break R, if compiled code is allowed, both in odeintr 
> (based on ODEINT), deSolve (based partly on ODEPACK) and other 
> packages that were built on top of them.
>
> In the meantime, I had a look again in the deSolve sources. The 
> initialisation routine is a little bit tricky to enable communication 
> between the user-dll and deSolve.dll. It would be possible, in 
> principle, to relax the "confusion over the length ..." error message 
> or to enable passing more complex parameter constructions other than 
> double precision vectors, i.e. a complete SEXP that could then be 
> de-constructed by the user.
>
> I assume that the decision about the length check was made with the 
> intent to make the interface easy to use, and to request a minimum of 
> self-check from the user (here, thinking about the parameter length 
> him/herself) -- so I would leave it as is.
>
> Besides this intrinsically fixed match between the C and R vector, 
> there are several methods that can make parameter passing more 
> flexible, i.e. using C vectors directly instead of #define macros, or 
> employ UNIONs between numbered vector arguments and named arguments.
>
> One can then pass a bigger vector with some reserve (e.g. Nmax 100), 
> and then to fill only the parameters that are needed.
>
> A small example is shown below, another example with UNIONs can be 
> posted on request.
>
> Thomas
>
>
>
>
> _______________________________________________
> R-sig-dynamic-models mailing list
> R-sig-dynamic-models at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models


	[[alternative HTML version deleted]]



More information about the R-sig-dynamic-models mailing list