Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop binary linkage to PreciseSums #768

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
nlmixr2/dparser-R
nlmixr2/lotri
nlmixr2/rxode2ll
nlmixr2/PreciseSums
needs: check

- uses: r-lib/actions/check-r-package@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
nlmixr2/dparser-R
nlmixr2/lotri
nlmixr2/rxode2ll
nlmixr2/PreciseSums
local::.
needs: website

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
nlmixr2/dparser-R
nlmixr2/lotri
nlmixr2/rxode2ll
nlmixr2/PreciseSums
needs: coverage

- name: Test coverage
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Suggests:
lifecycle,
kableExtra
Imports:
PreciseSums (>= 0.3),
PreciseSums (>= 0.7),
Rcpp (>= 0.12.3),
backports,
cli (>= 2.0.0),
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 7 additions & 11 deletions R/rxode-options.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
}
}
.hasUnits <- FALSE
.PreciseSumsVersion <- utils::packageVersion("PreciseSums")

## nocov start
.onLoad <- function(libname, pkgname) {
requireNamespace("data.table", quietly=TRUE)
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
13 changes: 2 additions & 11 deletions src/call_dvode.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
#include "dop853.h"
#define max(a, b) ((a) > (b) ? (a) : (b))
#define STRICT_R_HEADERS
#include <PreciseSums.h>
#include <PreciseSumsPtr.h>
#include "../inst/include/rxode2.h"

iniPreciseSums;
//--------------------------------------------------------------------------

// These are now allocated via R structures in Rcpp.
Expand Down Expand Up @@ -70,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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
Loading