From 8822acbdbd28fb47936a4841bf45ef0a00ee0ffe Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Tue, 13 Aug 2024 05:38:34 -0500 Subject: [PATCH 1/3] no bin for PreciseSums --- DESCRIPTION | 4 ++-- R/rxode-options.R | 18 +++++++----------- src/call_dvode.c | 3 ++- src/init.c | 2 ++ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5f00d370c..321798050 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -75,7 +75,7 @@ Suggests: lifecycle, kableExtra Imports: - PreciseSums (>= 0.3), + PreciseSums (>= 0.7), Rcpp (>= 0.12.3), backports, cli (>= 2.0.0), @@ -117,7 +117,7 @@ Biarch: true LinkingTo: sitmo, lotri (>= 0.5.0), - PreciseSums (>= 0.3), + PreciseSums (>= 0.7), Rcpp, RcppArmadillo (>= 0.9.300.2.0), BH, diff --git a/R/rxode-options.R b/R/rxode-options.R index b48cb9c01..a9d0bea73 100644 --- a/R/rxode-options.R +++ b/R/rxode-options.R @@ -16,8 +16,6 @@ } } .hasUnits <- FALSE -.PreciseSumsVersion <- utils::packageVersion("PreciseSums") - ## nocov start .onLoad <- function(libname, pkgname) { requireNamespace("data.table", quietly=TRUE) @@ -33,15 +31,6 @@ if (requireNamespace("data.table", quietly = TRUE)) { .s3register("data.table::as.data.table", "rxEt") } - if (!identical(.PreciseSumsVersion, utils::packageVersion("PreciseSums"))) { - stop("rxode2 compiled with PreciseSums '", as.character(.PreciseSumsVersion), - "' but PreciseSums '", as.character(utils::packageVersion("PreciseSums")), - "' is loaded\nRecompile rxode2 with the this version of PreciseSums", - call. = FALSE - ) - } else { - requireNamespace("PreciseSums", quietly=TRUE) - } if (requireNamespace("dplyr", quietly=TRUE)) { .s3register("dplyr::rename", "rxUi") .s3register("dplyr::rename", "function") @@ -76,6 +65,11 @@ .Call(`_iniLotriPtr`, lotri::.lotriPointers()) } +.iniPreciseSumsPtr <- function() { + .Call(`_iniPreciseSumsPtr`, PreciseSums::.preciseSumsPtr()) +} + + .onAttach <- function(libname, pkgname) { ## For some strange reason, mvnfast needs to be loaded before rxode2 to work correctly .Call(`_rxode2_setRstudio`, Sys.getenv("RSTUDIO") == "1") @@ -85,6 +79,8 @@ } # Setup lotri C linkages using function pointers .iniLotriPtrs() + # Setup PreciseSums linkage with function pointers + .iniPreciseSumsPtr() rxTempDir() .ggplot2Fix() v <- utils::packageVersion("rxode2") diff --git a/src/call_dvode.c b/src/call_dvode.c index 138eba097..cd097d875 100644 --- a/src/call_dvode.c +++ b/src/call_dvode.c @@ -9,9 +9,10 @@ #include "dop853.h" #define max(a, b) ((a) > (b) ? (a) : (b)) #define STRICT_R_HEADERS -#include +#include #include "../inst/include/rxode2.h" +iniPreciseSums; //-------------------------------------------------------------------------- // These are now allocated via R structures in Rcpp. diff --git a/src/init.c b/src/init.c index 47474df95..31083b2e0 100644 --- a/src/init.c +++ b/src/init.c @@ -358,9 +358,11 @@ SEXP _rxode2_getClassicEvid(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP _rxode2_rxQs(SEXP); SEXP iniLotriPtr(SEXP ptr); +SEXP iniPreciseSumsPtr(SEXP ptr); void R_init_rxode2(DllInfo *info){ R_CallMethodDef callMethods[] = { + {"_iniPreciseSumsPtr", (DL_FUNC) &iniPreciseSumsPtr, 1}, {"_iniLotriPtr", (DL_FUNC) &iniLotriPtr, 1}, {"_rxode2_rxode2parseSetRstudio", (DL_FUNC) &_rxode2_rxode2parseSetRstudio, 1}, {"_rxode2_rxQs", (DL_FUNC) &_rxode2_rxQs, 1}, From 3a7ecbfd5624c5baa777ff72ff850845b580ee34 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Tue, 13 Aug 2024 05:43:34 -0500 Subject: [PATCH 2/3] Add development PreciseSums --- .github/workflows/R-CMD-check.yaml | 1 + .github/workflows/pkgdown.yaml | 1 + .github/workflows/test-coverage.yaml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 63df9aebf..0416d2aad 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -57,6 +57,7 @@ jobs: nlmixr2/dparser-R nlmixr2/lotri nlmixr2/rxode2ll + nlmixr2/PreciseSums needs: check - uses: r-lib/actions/check-r-package@v2 diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index b2fbf41fb..bb20e57aa 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -44,6 +44,7 @@ jobs: nlmixr2/dparser-R nlmixr2/lotri nlmixr2/rxode2ll + nlmixr2/PreciseSums local::. needs: website diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 2d6ca3672..d1a277594 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -32,6 +32,7 @@ jobs: nlmixr2/dparser-R nlmixr2/lotri nlmixr2/rxode2ll + nlmixr2/PreciseSums needs: coverage - name: Test coverage From b8d588f603994128deb9d6198900328c1f27c1d6 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Tue, 13 Aug 2024 10:15:23 -0500 Subject: [PATCH 3/3] Remove sumV_r --- src/call_dvode.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/call_dvode.c b/src/call_dvode.c index cd097d875..ecb255ca8 100644 --- a/src/call_dvode.c +++ b/src/call_dvode.c @@ -71,16 +71,6 @@ extern double rxode2_sumV(int n, ...){ return s; } -extern double rxode2_sumV_r(double *p, long double *pld, int m, int type, int n, ...){ - va_list valist; - va_start(valist, n); - for (unsigned int i = (unsigned int)n; i--;){ - p[i] = va_arg(valist, double); - } - va_end(valist); - return PreciseSums_sum_r(p, n, pld, m, type); -} - extern double rxode2_prod(double *input, int len){ return PreciseSums_prod(input, len); }