aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-11-03 05:08:25 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2020-11-03 05:08:25 +0100
commit5a986f2064cf0b2fbd94e636cc4fa56d9939ca42 (patch)
tree514eae70fc01dca7e198da475e05221571d382ee
parenta5874ab7fce4616e80be69366ff0685332f47bf1 (diff)
C implementation of the SFO function
Only pays off for large time series with length >> 100
-rw-r--r--NAMESPACE1
-rw-r--r--R/parent_solutions.R6
-rw-r--r--build.log25
-rwxr-xr-xsrc/mkin.sobin0 -> 20920 bytes
-rw-r--r--src/parent_solutions.c25
-rw-r--r--src/parent_solutions.obin0 -> 10176 bytes
6 files changed, 49 insertions, 8 deletions
diff --git a/NAMESPACE b/NAMESPACE
index 9554a0d6..ca5fa4b1 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -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
#'
diff --git a/build.log b/build.log
index d101d06b..f82ccec6 100644
--- a/build.log
+++ b/build.log
@@ -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
new file mode 100755
index 00000000..3d515096
--- /dev/null
+++ b/src/mkin.so
Binary files differ
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
new file mode 100644
index 00000000..9ca88e7d
--- /dev/null
+++ b/src/parent_solutions.o
Binary files differ

Contact - Imprint