Function which uses output from `sps_prep`

to evaluate spline on given set of tabulation points

1 |

`spline` |
Output of sps_prep function; list containing values of data points, derivatives on the points, degrees of polynomial, etc. see: |

`x` |
Vector or matrix of x-coordinates of tabulation points. |

`der.x` |
vector of requested derivatives of spline with respect to x. By default will return values of spline. If |

`y` |
Vector or matrix of y-coordinates of tabulation points. For bi-variate case only. |

`der.y` |
For bi-variate case only. Vector of requested derivatives of spline with respect to y. By default will return values of spline. If |

`grid` |
For bi-variate case only. If |

Der.x and der.y need some more attention for bi-variate case. If they are not provided they are both assumed to be 0. If user needs more then 1 derivative then length of `der.x`

and `der.y`

must be equal. For example if `der.x`

= c(0,1,0) and `der.y`

= c(0,0,1) than function will return values of spline, values of partial derivative with respect to x and partial derivative with respect to y, respectively, on each tabulation point in a form of list of vectors or matrices.

If length of `der.x`

= 1 function will return vector or matrix of values, depending on parameter `grid`

. Otherwise if length of `der.x`

is greater than 1, function will return list of vectors or matrices depending on `grid`

.

Szymon Sacher <s1340144@sms.ed.ac.uk> & Andrew Clausen <andrew.clausen@ed.ac.uk>

Excerpts adapted from Fortran code Copyright (C) Paolo Costantini

Costantini, P; Fontanella, F; 'Shape Preserving Bi-variate Interpolation' sSIAM J NUMER. ANAL. Vol. 27, No.2, pp. 488-506, April 1990

`sps_fun`

`sps_prep`

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 | ```
## Univariate example
x <- c( 1, 2, 3, 4, 5, 6)
y <- c(16 ,18, 21, 17, 15, 12)
spline <- sps_prep(x, y, shape = 'monotonicity', smoothness = 2)
plot(seq(1, 6, 0.1), sps_eval(spline, seq(1, 6, 0.1)))
## Bivariate example
fun <- function(x,y) pmax(0, sin(pi*x) * sin(pi*y))
X <- seq(-1, 2, 0.5)
Y <- seq(-1, 1, 0.5)
grid <- mesh(X, Y)
Z <- matrix(fun(grid$x, grid$y), ncol = length(Y))
X_ <- seq(-1, 2, 0.05)
Y_ <- seq(-1, 1, 0.05)
# Prepare spline parameters
spline <- sps_prep(X, Y, Z)
# evaluate spline on grid of tabulation points spanned by X_ and Y_
eval <- sps_eval(spline, x = X_, y = Y_, grid = TRUE)
# Plot resulting data
persp3D(X_, Y_, eval)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.