106 SEXP
Snames, Pnames, Cnames;
112 dim = INTEGER(GET_DIM(
X));
nvars = dim[0]; nrepsx = dim[1];
113 dim = INTEGER(GET_DIM(
params));
npars = dim[0]; nrepsp = dim[1];
115 give_log = *(INTEGER(AS_INTEGER(log)));
118 if (nrepsx != nrepsp && nrepsx % nrepsp != 0 && nrepsp % nrepsx != 0) {
119 err(
"the larger number of replicates is not a multiple of smaller.");
121 nreps = (nrepsx > nrepsp) ? nrepsx : nrepsp;
124 PROTECT(
Snames = GET_ROWNAMES(GET_DIMNAMES(
X)));
125 PROTECT(Pnames = GET_ROWNAMES(GET_DIMNAMES(
params)));
131 PROTECT(cvec = NEW_NUMERIC(
ncovars));
143 double *t = REAL(t0);
144 double *ft = REAL(F);
151 for (
int j = 0; j <
nreps; j++, ft++) {
153 double *xs = REAL(
X)+
nvars*(j%nrepsx);
158 *ft = *REAL(AS_NUMERIC(ans));
162 if (!give_log) *ft = exp(*ft);
173 int *sidx, *pidx, *cidx;
174 double *t = REAL(t0);
175 double *ft = REAL(F);
178 sidx = INTEGER(GET_SLOT(func,install(
"stateindex")));
179 pidx = INTEGER(GET_SLOT(func,install(
"paramindex")));
180 cidx = INTEGER(GET_SLOT(func,install(
"covarindex")));
182 *((
void **) (&ff)) = R_ExternalPtrAddr(
fn);
187 for (
int j = 0; j <
nreps; j++, ft++) {
189 double *xs = REAL(
X)+
nvars*(j%nrepsx);
192 (*ff)(ft,xs,ps,*t,sidx,pidx,cidx,
cov);
194 if (!give_log) *ft = exp(*ft);
203 double *ft = REAL(F);
206 for (j = 0; j <
nreps; j++, ft++) {
210 warn(
"'dinit' unspecified: likelihood undefined.");
lookup_table_t make_covariate_table(SEXP, int *)
SEXP pomp_fun_handler(SEXP, SEXP, pompfunmode *, SEXP, SEXP, SEXP, SEXP)
void table_lookup(lookup_table_t *, double, double *)
SEXP get_covariate_names(SEXP)
static R_INLINE SEXP ret_array(int nreps)
static R_INLINE SEXP eval_call(SEXP fn, SEXP args, double *t0, double *x, int nvar, double *p, int npar, double *c, int ncov)
static R_INLINE SEXP add_args(SEXP args, SEXP Snames, SEXP Pnames, SEXP Cnames)
void pomp_dinit(double *lik, const double *x, const double *p, double t0, const int *stateindex, const int *parindex, const int *covindex, const double *covars)