Skip to content

Commit

Permalink
Add getRxNobs2()
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Aug 21, 2024
1 parent 29cd2cb commit 7203813
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions inst/include/rxode2ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ extern "C" {
typedef int (*getRxNobs_t)(rx_solve *rx);
extern getRxNobs_t getRxNobs;

typedef int (*getRxNobs2_t)(rx_solve *rx);
extern getRxNobs2_t getRxNobs2;

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 @@ -206,6 +209,7 @@ extern "C" {
hasRxCens = (hasRxCens_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 43));
getRxNall = (getRxNall_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 44));
getRxNobs = (getRxNobs_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 45));
getRxNobs2 = (getRxNobs2_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 46));
}
return R_NilValue;
}
Expand Down Expand Up @@ -257,6 +261,7 @@ extern "C" {
hasRxCens_t hasRxCens = NULL; \
getRxNall_t getRxNall = NULL; \
getRxNobs_t getRxNobs = NULL; \
getRxNobs2_t getRxNobs2 = NULL; \
SEXP iniRxodePtrs(SEXP ptr) { \
return iniRxodePtrs0(ptr); \
} \
Expand Down
5 changes: 4 additions & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,10 @@ SEXP _rxode2_rxode2Ptr(void) {
SEXP rxode2hasRxCens = PROTECT(R_MakeExternalPtrFn((DL_FUNC)&hasRxCens, R_NilValue, R_NilValue)); pro++;
SEXP rxode2getRxNall = PROTECT(R_MakeExternalPtrFn((DL_FUNC)&getRxNall, R_NilValue, R_NilValue)); pro++;
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++;


#define nVec 46
#define nVec 47

SEXP ret = PROTECT(Rf_allocVector(VECSXP, nVec)); pro++;
SET_VECTOR_ELT(ret, 0, rxode2rxRmvnSEXP);
Expand Down Expand Up @@ -472,6 +473,7 @@ SEXP _rxode2_rxode2Ptr(void) {
SET_VECTOR_ELT(ret, 43, rxode2hasRxCens);
SET_VECTOR_ELT(ret, 44, rxode2getRxNall);
SET_VECTOR_ELT(ret, 45, rxode2getRxNobs);
SET_VECTOR_ELT(ret, 46, rxode2getRxNobs2);

SEXP retN = PROTECT(Rf_allocVector(STRSXP, nVec)); pro++;
SET_STRING_ELT(retN, 0, Rf_mkChar("rxode2rxRmvnSEXP"));
Expand Down Expand Up @@ -520,6 +522,7 @@ SEXP _rxode2_rxode2Ptr(void) {
SET_STRING_ELT(retN, 43, Rf_mkChar("rxode2hasRxCens"));
SET_STRING_ELT(retN, 44, Rf_mkChar("rxode2getRxNall"));
SET_STRING_ELT(retN, 45, Rf_mkChar("rxode2getRxNobs"));
SET_STRING_ELT(retN, 46, Rf_mkChar("rxode2getRxNobs2"));

#undef nVec

Expand Down
4 changes: 4 additions & 0 deletions src/rx2api.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,7 @@ int getRxNall(rx_solve *rx) {
int getRxNobs(rx_solve *rx) {
return rx->nobs;
}

int getRxNobs2(rx_solve *rx) {
return rx->nobs2;
}
3 changes: 3 additions & 0 deletions src/rx2api.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ extern "C" {
// Get the number of observation sin the rxode2 problem
int getRxNobs(rx_solve *rx);

// Get the number of observations excluding evid=2
int getRxNobs2(rx_solve *rx);

#if defined(__cplusplus)
}
#endif
Expand Down

0 comments on commit 7203813

Please sign in to comment.