Skip to content

Commit

Permalink
Merge pull request #802 from nlmixr2/add-rx-npars-to-api
Browse files Browse the repository at this point in the history
Add getRxNpars to api
  • Loading branch information
mattfidler authored Nov 1, 2024
2 parents bee8051 + a462da7 commit cfd5621
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: rxode2
Version: 3.0.2
Version: 3.0.2.9000
Title: Facilities for Simulating from ODE-Based Models
Authors@R: c(
person("Matthew L.","Fidler", role = c("aut", "cre"), email = "matthew.fidler@gmail.com", comment=c(ORCID="0000-0001-8538-6691")),
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# rxode2 (development version)

- Add `getRxNpars` to api. This allows the development version of
`babelmixr2` to better check what model is loaded and unload/reload
as necessary.

# rxode2 3.0.2

- Bug fix for `api`, the censoring function pointer has been updated
Expand Down
5 changes: 5 additions & 0 deletions inst/include/rxode2ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ extern "C" {
typedef double * (*getOpIndSolve_t)(rx_solving_options* op, rx_solving_options_ind* ind, int idx);
extern getOpIndSolve_t getOpIndSolve;

typedef int (*getRxNpars_t)(rx_solve *rx);
extern getRxNpars_t getRxNpars;

static inline SEXP iniRxodePtrs0(SEXP p) {
if (_rxode2_rxRmvnSEXP_ == NULL) {
_rxode2_rxRmvnSEXP_ = (_rxode2_rxRmvnSEXP_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 0));
Expand Down Expand Up @@ -214,6 +217,7 @@ extern "C" {
getRxNobs = (getRxNobs_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 45));
getRxNobs2 = (getRxNobs2_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 46));
getOpIndSolve = (getOpIndSolve_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 47));
getRxNpars = (getRxNpars_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 48));
}
return R_NilValue;
}
Expand Down Expand Up @@ -267,6 +271,7 @@ extern "C" {
getRxNobs_t getRxNobs = NULL; \
getRxNobs2_t getRxNobs2 = NULL; \
getOpIndSolve_t getOpIndSolve = NULL; \
getRxNpars_t getRxNpars = NULL; \
SEXP iniRxodePtrs(SEXP ptr) { \
return iniRxodePtrs0(ptr); \
} \
Expand Down
7 changes: 5 additions & 2 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,11 @@ SEXP _rxode2_rxode2Ptr(void) {
SEXP rxode2getRxNobs = PROTECT(R_MakeExternalPtrFn((DL_FUNC)&getRxNobs, R_NilValue, R_NilValue)); pro++;
SEXP rxode2getRxNobs2 = PROTECT(R_MakeExternalPtrFn((DL_FUNC)&getRxNobs2, R_NilValue, R_NilValue)); pro++;
SEXP rxode2getOpIndSolve = PROTECT(R_MakeExternalPtrFn((DL_FUNC)&getOpIndSolve, R_NilValue, R_NilValue)); pro++;
SEXP rxode2getRxNpars = PROTECT(R_MakeExternalPtrFn((DL_FUNC)&getRxNpars,
R_NilValue, R_NilValue)); pro++;


#define nVec 48
#define nVec 49

SEXP ret = PROTECT(Rf_allocVector(VECSXP, nVec)); pro++;
SET_VECTOR_ELT(ret, 0, rxode2rxRmvnSEXP);
Expand Down Expand Up @@ -472,6 +474,7 @@ SEXP _rxode2_rxode2Ptr(void) {
SET_VECTOR_ELT(ret, 45, rxode2getRxNobs);
SET_VECTOR_ELT(ret, 46, rxode2getRxNobs2);
SET_VECTOR_ELT(ret, 47, rxode2getOpIndSolve);
SET_VECTOR_ELT(ret, 48, rxode2getRxNpars);

SEXP retN = PROTECT(Rf_allocVector(STRSXP, nVec)); pro++;
SET_STRING_ELT(retN, 0, Rf_mkChar("rxode2rxRmvnSEXP"));
Expand Down Expand Up @@ -522,7 +525,7 @@ SEXP _rxode2_rxode2Ptr(void) {
SET_STRING_ELT(retN, 45, Rf_mkChar("rxode2getRxNobs"));
SET_STRING_ELT(retN, 46, Rf_mkChar("rxode2getRxNobs2"));
SET_STRING_ELT(retN, 47, Rf_mkChar("rxode2getOpIndSolve"));

SET_STRING_ELT(retN, 48, Rf_mkChar("rxode2getRxNpars"));
#undef nVec

// Set the names attribute of the list
Expand Down
4 changes: 4 additions & 0 deletions src/rx2api.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ int getRxNobs(rx_solve *rx) {
int getRxNobs2(rx_solve *rx) {
return rx->nobs2;
}

int getRxNpars(rx_solve *rx) {
return rx->npars;
}
////////////////////////////////////////////////////////////////////////
// Get solve vector for ith solve
////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions src/rx2api.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ extern "C" {
// Get the number of observations excluding evid=2
int getRxNobs2(rx_solve *rx);

// Get the number of parameters loaded
int getRxNpars(rx_solve *rx);

double * getOpIndSolve(rx_solving_options* op, rx_solving_options_ind* ind, int idx);

#if defined(__cplusplus)
Expand Down

0 comments on commit cfd5621

Please sign in to comment.