Description Usage Arguments Details Value Examples

Create an interpolating function from given values. Several interpolation methods are supported.

1 2 3 4 |

`val` |
array or function. Function values on a grid, or the function
itself. If it is the values, the |

`dims` |
integer vector. The number of grid points in each dimension. Not
needed if |

`intervals` |
list of length 2 numeric vectors. The lower and upper bound
in each dimension. Not used if |

`grid` |
list. Each element is a vector of ordered grid-points for a dimension. These need not be Chebyshev-knots, nor evenly spaced. |

`knots` |
matrix. Each column is a point in an M-dimensional space. |

`k` |
numeric. Additional value, used with some methods. |

`method` |
character. The interpolation method to use. |

`...` |
Further arguments to the function, if |

`ipol`

is a wrapper around various interpolation methods in package chebpol.
Which arguments to specify depends on the method. The interpolation methods are described
in `vignette("chebpol",package="chebpol")`

.

The method `"chebyshev"`

needs only the number of Chebyshev knots in
each dimension. This is either the `"dim"`

attribute of the array
`val`

, or the `dims`

argument if `val`

is a function. Also
the intervals can be specified if different from [-1, 1].

The method `"uniform"`

is similar to the `"chebyshev"`

, but
uniformly spaced knots are created. The argument
`intervals`

generally goes with `dims`

when something else than
standard intervals `[-1, 1]`

are used.

The methods `"multilinear"`

, `"fh"`

(Floater-Hormann), `"stalker"`

,
`"hstalker"`

, and
`"general"`

needs the argument `grid`

. These are the methods
which can use arbitrary Cartesian grids.
The stalker spline
is described in `vignette("stalker",package="chebpol")`

. The Floater-Hormann
method (`"fh"`

) also needs the `k`

argument, the degree of the blending
polynomials. It defaults to 4.

The method `"polyharmonic"`

needs the arguments `knots`

and
`k`

. In addition it can take the logical argument `normalize`

for normalizing the knots to the unit hypercube. The default is `NA`

, which
uses normalization if any of the knots are outside the unit hypercube. Also, a logical
`nowarn`

is accepted, it is used to suppress a warning in case the system can't
be solved exactly and a least squares fallback method is used.

The method `"simplexlinear"`

needs the argument `knots`

. It creates a
Delaunay triangulation from the knots, and does linear interpolation in each simplex
by weighting the vertex values with the barycentric coordinates.

If knots are required, but the grid argument is given, knots are constructed as
`t(expand.grid(grid))`

The `"crbf"`

is the multilayer compact radial basis function
interpolation in ALGLIB (http://www.alglib.net/interpolation/fastrbf.php).
It is only available if ALGLIB was available at
compile time. It takes the extra arguments `"rbase"`

, `"layers"`

, and
`"lambda"`

. These are discussed in the ALGLIB documentation.

There are also some usage examples and more in `vignette("chebpol")`

and `vignette('chebusage')`

.

A `function(x, threads=getOption('chebpol.threads'))`

defined on a hypercube, an interpolant
for the given function. The argument `x`

can be a matrix of column
vectors which are evaluated in parallel in a number of threads. The
function yields values for arguments outside the hypercube as well, though
it will typically be a poor approximation. `threads`

is an integer
specifying the number of parallel threads which should be used when
evaluating a matrix of column vectors.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ```
## evenly spaced grid-points
su <- seq(0,1,length.out=10)
## irregularly spaced grid-points
s <- su^3
## create approximation on the irregularly spaced grid
ml1 <- ipol(exp, grid=list(s), method='multilin')
fh1 <- ipol(exp, grid=list(s), method='fh')
## test it, since exp is convex, the linear approximation lies above
## the exp between the grid points
ml1(su) - exp(su)
fh1(su) - exp(su)
## multi dimensional approximation
f <- function(x) 10/(1+25*mean(x^2))
# a 3-dimensional 10x10x10 grid, first and third coordinate are non-uniform
grid <- list(s, su, sort(1-s))
# make multilinear, Floater-Hormann, Chebyshev and polyharmonic spline.
ml2 <- ipol(f, grid=grid, method='multilin')
fh2 <- ipol(f, grid=grid, method='fh')
hst <- ipol(f, grid=grid, method='hstalker')
ch2 <- ipol(f, dims=c(10,10,10), intervals=list(0:1,0:1,0:1), method='cheb')
knots <- matrix(runif(3*1000),3)
ph2 <- ipol(f, knots=knots, k=2, method='poly')
sl2 <- ipol(f, knots=knots, method='simplexlinear')
# my alglib is a bit slow, so stick to 100 knots
if(havealglib()) crb <- ipol(f, knots=knots[,1:100], method='crbf',
rbase=2, layers=5, lambda=0)
# make 7 points in R3 to test them on
m <- matrix(runif(3*7),3)
rbind(true=apply(m,2,f), ml=ml2(m), fh=fh2(m), cheb=ch2(m), poly=ph2(m), sl=sl2(m),hst=hst(m),
crbf=if(havealglib()) crb(m) else NULL )
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.