Cardinal Basis for Lagrange (broken line) interpolation

Share:

Description

Cardinal Basis for Lagrange interpolation.

Usage

1

Arguments

x

Numeric vector of design points.

xout

Numeric vector giving new points.

Details

This is a simple and raw interface to alterp Fortran subroutine. It is a wrapper for cardinalBasis_ceschino function with cubic = FALSE and deriv = 0L.

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.

Note

This function does not allow extrapolation, so an error will result when xout contains element outside of the range of x. The function used here is a spline of degree 1 (order 2).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
set.seed(123)
n <- 16; nout <- 300
x <- sort(runif(n))

##' ## let 'xout' contain n + nout points including nodes
xout <- sort(c(x, runif(nout, min = x[1], max = x[n])))
res  <- cardinalBasis_lagrange(x, xout = xout)

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")

## Lebesgue's function is constant = 1.0: check it
L <- apply(res$CB, 1, function(x) sum(abs(x)))
range(L)