327{
328
331 int *dim;
332 SEXP
Snames, Cnames, Pnames;
333 SEXP pompfun,
cov, ob;
336
337 PROTECT(t = AS_NUMERIC(t));
338 ntimes = LENGTH(t);
339
341 dim = INTEGER(GET_DIM(x));
342 nvars = dim[0]; nrepx = dim[1];
343 if (ntimes != dim[2])
344 err(
"length of 'times' and 3rd dimension of 'x' do not agree.");
345
347 dim = INTEGER(GET_DIM(
params));
348 npars = dim[0]; nrepp = dim[1];
349
350
351 nreps = (nrepp > nrepx) ? nrepp : nrepx;
352 if ((
nreps % nrepp != 0) || (
nreps % nrepx != 0))
353 err(
"2nd dimensions of 'x' and 'params' are incompatible");
354
355 PROTECT(
Snames = GET_ROWNAMES(GET_DIMNAMES(x)));
356 PROTECT(Pnames = GET_ROWNAMES(GET_DIMNAMES(
params)));
358
359
362
363
364 PROTECT(ob = GET_SLOT(object,install("skeleton")));
365 PROTECT(pompfun = GET_SLOT(ob,install("skel.fn")));
367
368
369 PROTECT(
args = GET_SLOT(
object,install(
"userdata")));
370
372
373 int nprotect = 12;
374
376
378
380
384 &covariate_table,REAL(
cov));
385
386 }
387
388 break;
389
391 int *sidx, *pidx, *cidx;
393
394 sidx = INTEGER(GET_SLOT(pompfun,install("stateindex")));
395 pidx = INTEGER(GET_SLOT(pompfun,install("paramindex")));
396 cidx = INTEGER(GET_SLOT(pompfun,install("covarindex")));
397
398 *((
void **) (&ff)) = R_ExternalPtrAddr(
fn);
399
401 REAL(F),REAL(t),REAL(x),REAL(
params),
403 sidx,pidx,cidx,&covariate_table,ff,
args,REAL(
cov));
404
405 }
406
407 break;
408
409 default: {
410
411 double *ft = REAL(F);
413 for (i = 0; i < n; i++, ft++) *ft = R_NaReal;
414 warn(
"'skeleton' unspecified: NAs generated.");
415
416 }
417
418 }
419
420 UNPROTECT(nprotect);
421 return F;
422}
lookup_table_t make_covariate_table(SEXP, int *)
SEXP pomp_fun_handler(SEXP, SEXP, pompfunmode *, SEXP, SEXP, SEXP, SEXP)
SEXP get_covariate_names(SEXP)
void pomp_skeleton(double *f, const double *x, const double *p, const int *stateindex, const int *parindex, const int *covindex, const double *covars, double t)
static R_INLINE SEXP as_state_array(SEXP x)
static R_INLINE SEXP as_matrix(SEXP x)
void eval_skeleton_native(double *f, double *time, double *x, double *p, int nvars, int npars, int ncovars, int ntimes, int nrepx, int nrepp, int nreps, int *sidx, int *pidx, int *cidx, lookup_table_t *covar_table, pomp_skeleton *fun, SEXP args, double *cov)
static R_INLINE SEXP ret_array(int nvars, int nreps, int ntimes, SEXP Snames)
SEXP add_skel_args(SEXP args, SEXP Snames, SEXP Pnames, SEXP Cnames)
void eval_skeleton_R(double *f, double *time, double *x, double *p, SEXP fn, SEXP args, SEXP Snames, int nvars, int npars, int ncovars, int ntimes, int nrepx, int nrepp, int nreps, lookup_table_t *covar_table, double *cov)