interpn: N-D Linear interpolation

View source: R/interpn.R

interpnR Documentation

N-D Linear interpolation

Description

Given a n dimensional grid defined by the n vectors x1 ,x2, ..., xn and the associated values v of a function, 'interpn' computes the linear interpolant at the query points xq1, ..., xqn.

Usage

interpn(outmode, v, ...)

Arguments

outmode

: (integer, scalar) method for the extrapolation outside the grid. Possible values are: 0 (using the nearest n-linear patch from the point), 1 (by zero), 2 (by NaN), 3 (by projection), 4 (using periodicity)

v

: (double, vector) function values at each sample point

...

: (double, vectors) xq1, ..., xqn, x1, ..., xn : coordinates of the query points followed by the coordinates of the sample points

Value

(double, vector) interpolated values at the specific query points (xq1, ..., xqn)

Author(s)

Fabrice Zaoui - Copyright EDF 2019

Examples

n1 <- 4  # dimension of x1
n2 <- 7  # dimension of x2
nv <- n1 * n2  # dimension of v
x1 <- as.double(seq(, n1))  # grid
x2 <- as.double(seq(, n2))
v <- double(nv)
# function values
k <- 1
for(i in 1:n2){
   for(j in 1:n1){
      v[k] <- x1[j] * x2[i]
      k <- k + 1
   }
}
# query points
xq1 <- c(1.5, 2.5)
xq2 <- c(3.5, 4.5)
# call 'interpn'
vq <- interpn(outmode=0, v , x1, x2, xq1, xq2)


fzao/interpn documentation built on June 4, 2024, 5:26 a.m.