From f69c265aaa7ffa30ec9da5564eff3a4b4337d2b8 Mon Sep 17 00:00:00 2001 From: Matthew Fidler Date: Fri, 1 Nov 2024 13:49:06 -0500 Subject: [PATCH] Add getRxNpars to api --- inst/include/rxode2ptr.h | 5 +++++ src/init.c | 4 +++- src/rx2api.c | 4 ++++ src/rx2api.h | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/inst/include/rxode2ptr.h b/inst/include/rxode2ptr.h index 6821db274..b5b478c57 100644 --- a/inst/include/rxode2ptr.h +++ b/inst/include/rxode2ptr.h @@ -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)); @@ -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; } @@ -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); \ } \ diff --git a/src/init.c b/src/init.c index c73dc2c3f..13982a808 100644 --- a/src/init.c +++ b/src/init.c @@ -421,7 +421,7 @@ SEXP _rxode2_rxode2Ptr(void) { SEXP rxode2getOpIndSolve = PROTECT(R_MakeExternalPtrFn((DL_FUNC)&getOpIndSolve, 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); @@ -472,6 +472,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, getRxNpars); SEXP retN = PROTECT(Rf_allocVector(STRSXP, nVec)); pro++; SET_STRING_ELT(retN, 0, Rf_mkChar("rxode2rxRmvnSEXP")); @@ -522,6 +523,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_VECTOR_ELT(retN, 48, Rf_mkChar("rxode2getRxNpars")); #undef nVec diff --git a/src/rx2api.c b/src/rx2api.c index c59d3f778..f16ec7636 100644 --- a/src/rx2api.c +++ b/src/rx2api.c @@ -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 //////////////////////////////////////////////////////////////////////// diff --git a/src/rx2api.h b/src/rx2api.h index 4c131cf90..c95208532 100644 --- a/src/rx2api.h +++ b/src/rx2api.h @@ -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)