Tutorial by Examples

The Lorenz model describes the dynamics of three state variables, X, Y and Z. The model equations are: The initial conditions are: and a, b and c are three parameters with library(deSolve) ## ----------------------------------------------------------------------------- ## Define...
library(deSolve) ## ----------------------------------------------------------------------------- ## Define R-function ## ----------------------------------------------------------------------------- LV <- function(t, y, parms) { with(as.list(c(y, parms)), { dP &l...
library(deSolve) ## ----------------------------------------------------------------------------- ## Define parameters and variables ## ----------------------------------------------------------------------------- eps <- 0.01; M <- 10 k <- M * eps^2/2 L <- 1 L0 <- 0.5 ...
sink("caraxis_C.c") cat(" /* suitable names for parameters and state variables */ #include <R.h> #include <math.h> static double parms[8]; #define eps parms[0] #define m parms[1] #define k parms[2] #define L parms[3] #define L0 parms[4] #define r p...
sink("caraxis_fortran.f") cat(" c---------------------------------------------------------------- c Initialiser for parameter common block c---------------------------------------------------------------- subroutine init_fortran(daeparms) external daeparms ...
When you compiled and loaded the code in the three examples before (ODEs in compiled languages - definition in R, ODEs in compiled languages - definition in C and ODEs in compiled languages - definition in fortran) you are able to run a benchmark test. library(microbenchmark) R <- function(){...

Page 1 of 1