Learn R Programming

smint (version 0.4.2)

cardinalBasis_lagrange: Cardinal Basis for Lagrange (broken line) interpolation

Description

Cardinal Basis for Lagrange interpolation.

Usage

cardinalBasis_lagrange(x, xout)

Arguments

x
Numeric vector of design points.
xout
Numeric vector giving new points.

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.

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab