R: Methods for creating multivariate interpolations on...

chebpol-package {chebpol} | R Documentation

## Methods for creating multivariate interpolations on hypercubes

### Description

The package contains methods for creating multivariate/multidimensional interpolations for real-valued functions on hypercubes. The methods include classical Chebyshev interpolation, multilinear and Floater-Hormann for arbitrary Cartesian product grids, and simplex linear and polyharmonic spline for scattered multi dimensional data.

### Details

The primary method of the package 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('chebpol.threads')` to utilize more than one CPU if a matrix of column vectors is evaluated. The option `chebpol.threads` is initialized from the environment variable `CHEBPOL_THREADS` upon loading of the package. It defaults to `1`.

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 chebpol, I can issue no such absolute guarantee.

### Chebyshev

If we are free to evaluate the function to interpolate in arbitrary points, we can use a Chebyshev interpolation. The classical one is available with `ipol(...,method='chebyshev')`.

### Uniform grids

There are several options if your function must be evaluated in a uniform grid. There is the Floater-Hormann rational interpolation available with `ipol(...,method='fh')`. There is a transformed Chebyshev variant `ipol(..., method='uniform')`.

### Arbitrary grids

For grids which are not uniform, but still Cartesian products of one-dimensional grids, there is the Floater-Hormann interpolation `ipol(...,method='fh')`, and a transformed Chebyshev variant `ipol(...,method='general')`, as well as a multilinear `ipol(...,method='multilinear')`. These methods work on uniform grids as well. There is also a `method='stalker'` which is a shape preserving spline, and a variant `method='hstalker'`. Both are described in a vignette. These splines in one dimension attempts to honour monotonicity and local extrema, in particular the `'hstalker'` is positivity-preserving in the sense that it will preserve maxima and minima.

### Scattered data

For scattered data, not necessarily organised as a Cartesian product grid, there is a simplex linear interpolation available with `ipol(...,method='simplexlinear')`, and a polyharmonic spline with `ipol(...,method='polyharmonic')`.

### Support functions

There are also functions for producing Chebyshev grids (`chebknots`) as well as a function for evaluating a function on a grid (`evalongrid`), and a function for finding the Chebyshev coefficients (`chebcoef`).

### See Also

ipol, interpolant

### Examples

    ## make some function values on a 50x50x50 grid
    dims <- c(x=50,y=50,z=50)
    f <- function(x) sqrt(1+x[1])*exp(x[2])*sin(5*x[3])^2
    value <- evalongrid(f , dims)
    ##fit a Chebyshev approximation to it. Note that the value-array contains the
    ##grid-structure.
    ch <- ipol(value,method='cheb')
    ## To see the full grid, use the chebknots function and expand.grid
    ## Not run:
    head(cbind(expand.grid(chebknots(dims)), value=as.numeric(value),
          appx=as.numeric(evalongrid(ch,dims))))

    ## End(Not run)
    ## Make a Floater-Hormann approximation on a uniform grid as well
    fh <- ipol(f,grid=lapply(dims,function(n) seq(-1,1,length.out=n)),method='fh',k=5)
    ## evaluate in some random points in R3
    m <- matrix(runif(15,-1,1),3)
    rbind(true=apply(m,2,f), cheb=ch(m), fh=fh(m))

[Package chebpol version 2.1-2 Index]