diff --git a/inst/include/ergm_MHproposal.h b/inst/include/ergm_MHproposal.h index 20bdba63..db3bd54d 100644 --- a/inst/include/ergm_MHproposal.h +++ b/inst/include/ergm_MHproposal.h @@ -65,8 +65,10 @@ typedef struct MHProposalstruct { Vertex *togglehead; double logratio; int status; - double *inputs; /* may be used if needed, ignored if not. */ - int *iinputs; /* may be used if needed, ignored if not. */ + int ninputs; + double *inputs; + int niinputs; + int *iinputs; void *storage; void **aux_storage; unsigned int n_aux; @@ -79,8 +81,11 @@ MHProposal *MHProposalInitialize(SEXP pR, Network *nwp, void **aux_storage); void MHProposalDestroy(MHProposal *MHp, Network *nwp); /* Helper macros */ +#define MH_N_DINPUTS MHp->ninputs #define MH_DINPUTS MHp->inputs +#define MH_N_INPUTS MH_N_DINPUTS #define MH_INPUTS MH_DINPUTS +#define MH_N_IINPUTS MHp->niinputs #define MH_IINPUTS MHp->iinputs #define Mtail (MHp->toggletail) diff --git a/inst/include/ergm_wtMHproposal.h b/inst/include/ergm_wtMHproposal.h index 604e8380..d5f4e750 100644 --- a/inst/include/ergm_wtMHproposal.h +++ b/inst/include/ergm_wtMHproposal.h @@ -66,8 +66,10 @@ typedef struct WtMHProposalstruct { double *toggleweight; double logratio; int status; - double *inputs; /* may be used if needed, ignored if not. */ - int *iinputs; /* may be used if needed, ignored if not. */ + int ninputs; + double *inputs; + int niinputs; + int *iinputs; void *storage; void **aux_storage; unsigned int n_aux; @@ -79,8 +81,11 @@ WtMHProposal *WtMHProposalInitialize(SEXP pR, WtNetwork *nwp, void **aux_storage void WtMHProposalDestroy(WtMHProposal *MH, WtNetwork *nwp); /* Helper macros */ +#define MH_N_DINPUTS MHp->ninputs #define MH_DINPUTS MHp->inputs +#define MH_N_INPUTS MH_N_DINPUTS #define MH_INPUTS MH_DINPUTS +#define MH_N_IINPUTS MHp->niinputs #define MH_IINPUTS MHp->iinputs #define Mtail (MHp->toggletail) diff --git a/src/MHproposal.c b/src/MHproposal.c index a81506d6..e576638d 100644 --- a/src/MHproposal.c +++ b/src/MHproposal.c @@ -62,9 +62,11 @@ MHProposal *MHProposalInitialize(SEXP pR, Network *nwp, void **aux_storage){ MHp->x_func=(void (*)(unsigned int, void *, MHProposal*, Network*)) R_FindSymbol(fn,sn,NULL); SEXP tmp = getListElement(pR, "inputs"); - MHp->inputs=length(tmp) ? REAL(tmp) : NULL; + MHp->ninputs = length(tmp); + MHp->inputs = MHp->ninputs ? REAL(tmp) : NULL; tmp = getListElement(pR, "iinputs"); - MHp->iinputs=length(tmp) ? INTEGER(tmp) : NULL; + MHp->niinputs = length(tmp); + MHp->iinputs = MHp->niinputs ? INTEGER(tmp) : NULL; /*Clean up by freeing sn and fn*/ R_Free(fn); diff --git a/src/wtMHproposal.c b/src/wtMHproposal.c index b2d95f8d..9dcbe5aa 100644 --- a/src/wtMHproposal.c +++ b/src/wtMHproposal.c @@ -61,9 +61,11 @@ WtMHProposal *WtMHProposalInitialize(SEXP pR, WtNetwork *nwp, void **aux_storage MHp->x_func=(void (*)(unsigned int, void *, WtMHProposal*, WtNetwork*)) R_FindSymbol(fn,sn,NULL); SEXP tmp = getListElement(pR, "inputs"); - MHp->inputs=length(tmp) ? REAL(tmp) : NULL; + MHp->ninputs = length(tmp); + MHp->inputs = MHp->ninputs ? REAL(tmp) : NULL; tmp = getListElement(pR, "iinputs"); - MHp->iinputs=length(tmp) ? INTEGER(tmp) : NULL; + MHp->niinputs = length(tmp); + MHp->iinputs = MHp->niinputs ? INTEGER(tmp) : NULL; /*Clean up by freeing sn and fn*/ R_Free(fn);