cardinalBasis_lagrange: Cardinal Basis for Lagrange (broken line) interpolation

View source: R/splines1d.R

cardinalBasis_lagrangeR Documentation

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.

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

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)

IRSN/smint documentation built on Dec. 9, 2023, 9:53 p.m.