wrap.c.sampler | R Documentation |
Create an R stub function for a sampler implemented in C.
wrap.c.sampler(sampler.symbol, sampler.context,
name, name.expression=NULL)
sampler.symbol |
A one-element character vector containing the symbol of the C sampler function. |
sampler.context |
An arbitrary R object to be passed to the sampler function. |
name |
The |
name.expression |
The |
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.
An R function implementing the interface described in
compare.samplers
.
“R/C Glue in SamplerCompare” (vignette)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.