From a26b44d15c11ebb41083fc2efab0cc91a027b55b Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 18 Apr 2015 00:06:38 +0200 Subject: Add a vignette showing the performance of compiled models --- R/mkinmod.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'R') diff --git a/R/mkinmod.R b/R/mkinmod.R index 3fff0878..149d2beb 100644 --- a/R/mkinmod.R +++ b/R/mkinmod.R @@ -273,7 +273,7 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL) }#}}} # Create a function compiled from C code if possible #{{{ - if (require(ccSolve)) { + if (requireNamespace("ccSolve", quietly = TRUE)) { diffs.C <- paste(diffs, collapse = ";\n") diffs.C <- paste0(diffs.C, ";") for (i in seq_along(diffs)) { @@ -295,9 +295,12 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL) replacement <- paste0("* y[", i - 1, "]") diffs.C <- gsub(pattern, replacement, diffs.C) } - if (sum(sapply(spec, function(x) x$type %in% c("SFO", "FOMC", "DFOP", "SFORB"))) == length(spec)) { + if (sum(sapply(spec, function(x) x$type %in% + c("SFO", "FOMC", "DFOP", "SFORB"))) == length(spec)) { message("Compiling differential equation model from auto-generated C code...") - model$compiled <- compile.ode(diffs.C, language = "C", parms = parms, declaration = "double time = *t;") + model$compiled <- ccSolve::compile.ode(diffs.C, language = "C", + parms = parms, + declaration = "double time = *t;") } } # }}} -- cgit v1.2.1