Learn R Programming

smint (version 0.4.2)

cardinalBasis_ceschino: Cardinal Basis for cubic Ceschino interpolation

Description

Cardinal Basis for cubic Ceschino interpolation.

Usage

cardinalBasis_ceschino(x, xout, cubic = TRUE, deriv = 0)

Arguments

x
Numeric vector of design points.
xout
Numeric vector giving new points.
cubic
Logical. Use cubic interpolation or basic linear?
deriv
Integer or logical. Compute the derivative?

Value

A list with the following elements
x
Numeric vector of abscissas at which the basis is evaluated. This is a copy of xout.
CB
Matrix of the Cardinal Basis function values.
deriv, cubic
Copy of input.
method
Character description of the method involved in the CB determination.

Details

This is a simple and raw interface to alterp Fortran subroutine.

See Also

interp_ceschino for the related interpolation function, cardinalBasis_natSpline and cardinalBasis_lagrange for other Cardinal Basis constructions.

Examples

Run this code
set.seed(123)
n <- 16L; nout <- 300L
x <- sort(runif(n))

## let 'xout' contain n + nout points including nodes
xout <- sort(c(x, runif(nout, min = x[1], max = x[n])))
y <- sin(2 * pi * x)
res  <- cardinalBasis_ceschino(x, xout = xout, deriv = 0)

matplot(res$x, res$CB, type = "n", main = "Cardinal Basis")
abline(v = x, h = 1.0, col = "gray")
points(x = x, y = rep(0, n), pch = 21, col = "black",
       lwd = 2, bg = "white")
matlines(res$x, res$CB, type = "l")

## interpolation error should be fairly small
max(abs(sin(2 * pi * xout) - res$CB \%*\% y))

Run the code above in your browser using DataLab