wrap.c.sampler: Create an R stub function for a sampler implemented in C

Description Usage Arguments Details Value See Also

View source: R/c-samplers.R

Description

Create an R stub function for a sampler implemented in C.

Usage

1
2
wrap.c.sampler(sampler.symbol, sampler.context,
               name, name.expression=NULL)

Arguments

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 attribute for the sampler function.

name.expression

The name.expression attribute for the sampler function, in plotmath format.

Details

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:

1
2
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.

Value

An R function implementing the interface described in compare.samplers.

See Also

“R/C Glue in SamplerCompare” (vignette)


SamplerCompare documentation built on May 2, 2019, 7:55 a.m.