Create an R stub function for a sampler implemented in C.
wrap.c.sampler(sampler.symbol, sampler.context,
name, name.expression=NULL)
An R function implementing the interface described in
compare.samplers
.
A one-element character vector containing the symbol of the C sampler function.
An arbitrary R object to be passed to the sampler function.
The name
attribute for the sampler function.
The name.expression
attribute for
the sampler function, in plotmath
format.
This function is intended to allow
compare.samplers
to be able to invoke sampler
functions written in C. It wraps a C sampler function in an
R function implementing the standard sampler interface.
The function named by sampler.symbol
is expected to have
the function prototype:
sampler(SEXP sampler_context, dist_t *ds, double *x0,
int sample_size, double tuning, double *X_out);
This is defined as a type sampler_t
in SamplerCompare.h
.
The parameter sampler_context
is the same as the R object
sampler.context
passed to wrap.c.sampler
. ds
describes the distribution to be sampled. x0
, sample_size
,
and tuning
are as described in compare.samplers
and
should be considered read-only. X_out
is a column-major
matrix to be filled in with the generated sample; it has dimension
ds->ndim * sample_size
.
The vignette “R/C Glue in SamplerCompare” covers this interface in greater detail.
“R/C Glue in SamplerCompare” (vignette)