aboutsummaryrefslogtreecommitdiff
path: root/R/mkinmod.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2015-04-18 00:06:38 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2015-04-18 00:06:38 +0200
commita26b44d15c11ebb41083fc2efab0cc91a027b55b (patch)
tree1ab67782b9f0ec70a2409c430b8f57f32e4d5eb5 /R/mkinmod.R
parent07685d190e7da7bdc199f0b6cd0bd372c5264aa5 (diff)
Add a vignette showing the performance of compiled models
Diffstat (limited to 'R/mkinmod.R')
-rw-r--r--R/mkinmod.R9
1 files changed, 6 insertions, 3 deletions
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;")
}
}
# }}}

Contact - Imprint