diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2020-11-03 05:08:25 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2020-11-03 05:08:25 +0100 |
commit | 5a986f2064cf0b2fbd94e636cc4fa56d9939ca42 (patch) | |
tree | 514eae70fc01dca7e198da475e05221571d382ee | |
parent | a5874ab7fce4616e80be69366ff0685332f47bf1 (diff) |
C implementation of the SFO function
Only pays off for large time series with length >> 100
-rw-r--r-- | NAMESPACE | 1 | ||||
-rw-r--r-- | R/parent_solutions.R | 6 | ||||
-rw-r--r-- | build.log | 25 | ||||
-rwxr-xr-x | src/mkin.so | bin | 0 -> 20920 bytes | |||
-rw-r--r-- | src/parent_solutions.c | 25 | ||||
-rw-r--r-- | src/parent_solutions.o | bin | 0 -> 10176 bytes |
6 files changed, 49 insertions, 8 deletions
@@ -123,3 +123,4 @@ importFrom(stats,update) importFrom(stats,var) importFrom(utils,getFromNamespace) importFrom(utils,write.table) +useDynLib(mkin,SFO_solution) diff --git a/R/parent_solutions.R b/R/parent_solutions.R index 04226b73..bbdffc21 100644 --- a/R/parent_solutions.R +++ b/R/parent_solutions.R @@ -22,11 +22,9 @@ #' #' \dontrun{plot(function(x) SFO.solution(x, 100, 3), 0, 2)} #' +#' @useDynLib mkin SFO_solution #' @export -SFO.solution <- function(t, parent_0, k) -{ - parent = parent_0 * exp(-k * t) -} +SFO.solution <- function(t, parent_0, k) .Call(SFO_solution, as.double(t), as.double(parent_0), as.double(k)) #' First-Order Multi-Compartment kinetics #' @@ -1,9 +1,26 @@ * checking for file ‘./DESCRIPTION’ ... OK * preparing ‘mkin’: * checking DESCRIPTION meta-information ... OK +* cleaning src * installing the package to build vignettes -* creating vignettes ... OK -* checking for LF line-endings in source and make files and shell scripts -* checking for empty or unneeded directories -* building ‘mkin_0.9.50.4.tar.gz’ +* creating vignettes ... ERROR +--- re-building ‘FOCUS_D.rmd’ using rmarkdown +Quitting from lines 49-50 (FOCUS_D.rmd) +Error: processing vignette 'FOCUS_D.rmd' failed with diagnostics: +replacement has 21 rows, data has 38 +--- failed re-building ‘FOCUS_D.rmd’ +--- re-building ‘FOCUS_L.rmd’ using rmarkdown +--- finished re-building ‘FOCUS_L.rmd’ + +--- re-building ‘mkin.rmd’ using rmarkdown +--- finished re-building ‘mkin.rmd’ + +--- re-building ‘twa.rmd’ using rmarkdown +--- finished re-building ‘twa.rmd’ + +SUMMARY: processing the following file failed: + ‘FOCUS_D.rmd’ + +Error: Vignette re-building failed. +Execution halted diff --git a/src/mkin.so b/src/mkin.so Binary files differnew file mode 100755 index 00000000..3d515096 --- /dev/null +++ b/src/mkin.so diff --git a/src/parent_solutions.c b/src/parent_solutions.c new file mode 100644 index 00000000..4881d708 --- /dev/null +++ b/src/parent_solutions.c @@ -0,0 +1,25 @@ +#include <R.h> +#include <Rinternals.h> + +SEXP SFO_solution(SEXP t, SEXP parent_0_, SEXP k_) { + + int n = length(t); + + double parent_0 = asReal(parent_0_); + double k = asReal(k_); + + double *pt, *pout; + + SEXP out = PROTECT(allocVector(REALSXP, n)); + + pt = REAL(t); + pout = REAL(out); + + for (int i = 0; i < n; i++) { + pout[i] = parent_0 * exp(- k * pt[i]); + } + + UNPROTECT(1); + + return out; +} diff --git a/src/parent_solutions.o b/src/parent_solutions.o Binary files differnew file mode 100644 index 00000000..9ca88e7d --- /dev/null +++ b/src/parent_solutions.o |