# NOT RUN {
# }
# NOT RUN {
## Right now RxODE is not aware of the function f
## Therefore it cannot translate it to symengine or
## Compile a model with it.
try(RxODE("a=fun(a,b,c)"))
## Note for this approach to work, it cannot interfere with C
## function names or reserved RxODE specical terms. Therefore
## f(x) would not work since f is an alias for bioaviability.
fun <- "
double fun(double a, double b, double c) {
return a*a+b*a+c;
}
" ## C-code for function
rxFun("fun",c("a","b","c"), fun) ## Added function
## Now RxODE knows how to translate this function to symengine
rxToSE("fun(a,b,c)")
## And will take a central difference when calculating derivatives
rxFromSE("Derivative(fun(a,b,c),a)")
## Of course, you could specify the derivative table manually
rxD("fun", list(function(a,b,c){
paste0("2*",a,"+",b);
},
function(a,b,c){
return(a)
},
function(a,b,c){
return("0.0")
} ))
rxFromSE("Derivative(fun(a,b,c),a)")
# You can also remove the functions by `rxRmFun`
rxRmFun("fun")
# }
Run the code above in your browser using DataLab