12 SEXP
args, SEXP
Snames, SEXP Pnames, SEXP Cnames
18 PROTECT(
args = VectorToPairList(
args));
21 for (v = LENGTH(Cnames)-1; v >= 0; v--) {
26 SET_TAG(
args,installChar(STRING_ELT(Cnames,v)));
30 for (v = LENGTH(Pnames)-1; v >= 0; v--) {
35 SET_TAG(
args,installChar(STRING_ELT(Pnames,v)));
39 for (v = LENGTH(
Snames)-1; v >= 0; v--) {
44 SET_TAG(
args,installChar(STRING_ELT(
Snames,v)));
52 SET_TAG(
args,install(
"t0"));
68 SEXP var =
args, ans, ob;
71 *(REAL(CAR(var))) = *t0; var = CDR(var);
72 for (v = 0; v < nvar; v++, x++) {
73 *(REAL(CAR(var))) = *x; var = CDR(var);
75 for (v = 0; v < npar; v++, p++, var=CDR(var)) *(REAL(CAR(var))) = *p;
76 for (v = 0; v < ncov; v++, c++, var=CDR(var)) *(REAL(CAR(var))) = *c;
78 PROTECT(ob = LCONS(
fn,
args));
79 PROTECT(ans = eval(ob,CLOENV(
fn)));
89 const char *dimnm[1] = {
".id"};
99 SEXP func, SEXP
X, SEXP t0, SEXP
params, SEXP covar,
100 SEXP log, SEXP
args, SEXP gnsi
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.");
222 SEXP
object, SEXP t0, SEXP x, SEXP
params, SEXP log, SEXP gnsi
225 PROTECT(t0=AS_NUMERIC(t0));
229 PROTECT(
fn = GET_SLOT(
object,install(
"dinit")));
231 PROTECT(
args = GET_SLOT(
object,install(
"userdata")));
232 PROTECT(covar = GET_SLOT(
object,install(
"covar")));
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)
SEXP do_dinit(SEXP object, SEXP t0, SEXP x, SEXP params, SEXP log, SEXP gnsi)
static SEXP init_density(SEXP func, SEXP X, SEXP t0, SEXP params, SEXP covar, SEXP log, SEXP args, SEXP gnsi)
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)
static R_INLINE void fixdimnames(SEXP x, const char **names, int n)
static R_INLINE SEXP makearray(int rank, const int *dim)
static R_INLINE SEXP as_matrix(SEXP x)