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

Some of the #defines call the abi #773

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
add getOpIndSolve to replace getSolve
  • Loading branch information
mattfidler committed Aug 21, 2024
commit 37105c33944589fb6a07d0376d9b1c41ea7b61ab
5 changes: 5 additions & 0 deletions inst/include/rxode2ptr.h
Original file line number Diff line number Diff line change
@@ -161,6 +161,9 @@ extern "C" {
typedef int (*getRxNobs2_t)(rx_solve *rx);
extern getRxNobs2_t getRxNobs2;

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

static inline SEXP iniRxodePtrs0(SEXP p) {
if (_rxode2_rxRmvnSEXP_ == NULL) {
_rxode2_rxRmvnSEXP_ = (_rxode2_rxRmvnSEXP_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 0));
@@ -210,6 +213,7 @@ extern "C" {
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));
getOpIndSolve = (getOpIndSolve_t) R_ExternalPtrAddrFn(VECTOR_ELT(p, 47));
}
return R_NilValue;
}
@@ -262,6 +266,7 @@ extern "C" {
getRxNall_t getRxNall = NULL; \
getRxNobs_t getRxNobs = NULL; \
getRxNobs2_t getRxNobs2 = NULL; \
getOpIndSolve_t getOpIndSolve = NULL; \
SEXP iniRxodePtrs(SEXP ptr) { \
return iniRxodePtrs0(ptr); \
} \
5 changes: 4 additions & 1 deletion src/init.c
Original file line number Diff line number Diff line change
@@ -422,9 +422,10 @@ SEXP _rxode2_rxode2Ptr(void) {
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++;
SEXP rxode2getOpIndSolve = PROTECT(R_MakeExternalPtrFn((DL_FUNC)&getOpIndSolve, R_NilValue, R_NilValue)); pro++;


#define nVec 47
#define nVec 48

SEXP ret = PROTECT(Rf_allocVector(VECSXP, nVec)); pro++;
SET_VECTOR_ELT(ret, 0, rxode2rxRmvnSEXP);
@@ -474,6 +475,7 @@ SEXP _rxode2_rxode2Ptr(void) {
SET_VECTOR_ELT(ret, 44, rxode2getRxNall);
SET_VECTOR_ELT(ret, 45, rxode2getRxNobs);
SET_VECTOR_ELT(ret, 46, rxode2getRxNobs2);
SET_VECTOR_ELT(ret, 47, rxode2getOpIndSolve);

SEXP retN = PROTECT(Rf_allocVector(STRSXP, nVec)); pro++;
SET_STRING_ELT(retN, 0, Rf_mkChar("rxode2rxRmvnSEXP"));
@@ -523,6 +525,7 @@ SEXP _rxode2_rxode2Ptr(void) {
SET_STRING_ELT(retN, 44, Rf_mkChar("rxode2getRxNall"));
SET_STRING_ELT(retN, 45, Rf_mkChar("rxode2getRxNobs"));
SET_STRING_ELT(retN, 46, Rf_mkChar("rxode2getRxNobs2"));
SET_STRING_ELT(retN, 47, Rf_mkChar("rxode2getOpIndSolve"));

#undef nVec

6 changes: 6 additions & 0 deletions src/rx2api.c
Original file line number Diff line number Diff line change
@@ -156,3 +156,9 @@ int getRxNobs(rx_solve *rx) {
int getRxNobs2(rx_solve *rx) {
return rx->nobs2;
}
////////////////////////////////////////////////////////////////////////
// Get solve vector for ith solve
////////////////////////////////////////////////////////////////////////
double * getOpIndSolve(rx_solving_options* op, rx_solving_options_ind* ind, int idx) {
return ind->solve + (op->neq + op->nlin)*(idx);
}
2 changes: 2 additions & 0 deletions src/rx2api.h
Original file line number Diff line number Diff line change
@@ -120,6 +120,8 @@ extern "C" {
// Get the number of observations excluding evid=2
int getRxNobs2(rx_solve *rx);

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

#if defined(__cplusplus)
}
#endif
Loading