interpolation: Parallel version of multilinear interpolation generator for...

View source: R/interpolation.R

interpolationR Documentation

Parallel version of multilinear interpolation generator for function approximation

Description

Parallel version of multilinear interpolation generator for function approximation

The primary method is ipol which dispatches to some other method. All the generated interpolants accept as an argument a matrix of column vectors. The generated functions also accept an argument threads=getOption('ipol.threads') to utilize more than one CPU if a matrix of column vectors is evaluated. The option ipol.threads is initialized from the environment variable IPOL_THREADS upon loading of the package. It defaults to 1.

Usage

interpolation(evalfun, grid_list, cores = detectCores(), int = FALSE, ...)

Arguments

evalfun

The objective function to be approximated.

grid_list

A list for grid points (each element of list is a vector represents ticklabels on a dimension). The number of list elements are the dimension of function inputs.

cores

The numbers of cores (threads) of your machine to conduct parallel computing.

int

Logical indicator. int = TRUE interpolant value multiplied by 10^7 then convert to interger to save memory. Original interpolant if int = FALSE.

...

Other inputs for objective functions to be passed through.

Details

The interpolants are ordinary R-objects and can be saved with save() and loaded later with load() or serialized/unserialized with other tools, just like any R-object. However, they contain calls to functions in the package, and while the author will make efforts to ensure that generated interpolants are compatible with future versions of ipol, I can issue no such absolute guarantee.

Value

interpolation returns

  • value: A list of of length p corresponding to each variable. Returns NA for continuous variable; proportion of zeros for binary/truncated variables; the cumulative proportions of zeros and ones (e.g. first value is proportion of zeros, second value is proportion of zeros and ones) for ternary variable.

  • interpolant: An interpolant function generated by chebpol::chebpol for interplation.

See Also

ipol, interpolant

Examples

## Not run: grid_list = list(seq(-0.5, 0.5, by = 0.5), seq(-0.5, 0.5, by = 0.5))
objfun = function(x, y) {x^2 + sqrt(y)}
evalfun = function(X) {objfun(X[1], X[2])}
value = interpolation(evalfun = evalfun, grid_list = grid_list)$value
interpolant = interpolation(evalfun = evalfun, grid_list = grid_list)$interpolant
## End(Not run)

latentcor documentation built on Sept. 6, 2022, 1:06 a.m.