src/numericalnim/rbf

Search:
Group by:
Source   Edit  

Radial basis function interpolation

This module implements RBF interpolation of scattered data in arbitrary dimensions.

Example:

import src/numericalnim/rbf
import arraymancer

let points = [[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]].toTensor
let values = [[0.0], [1.0], [2.0], [3.0]].toTensor

let interp = newRbf(points, values)

let evalPoints = [[0.5, 0.5], [0.314, 0.281]].toTensor
let val = interp.eval(evalPoints)

Types

RbfBaseType[T] = object
  points*: Tensor[float]
  values*: Tensor[T]
  coeffs*: Tensor[float]
  epsilon*: float
  f*: RbfFunc
Source   Edit  
RbfFunc = proc (r: Tensor[float]; epsilon: float): Tensor[float]
Source   Edit  
RbfGrid[T] = object
  indices*: seq[seq[int]]
  values*: Tensor[T]
  points*: Tensor[float]
  gridSize*, gridDim*: int
  gridDelta*: float
Source   Edit  
RbfType[T] = object
  limits*: tuple[upper: Tensor[float], lower: Tensor[float]]
  grid*: RbfGrid[RbfBaseType[T]]
  nValues*: int
Source   Edit  

Procs

proc compactRbfFunc(r: Tensor[float]; epsilon: float): Tensor[float] {.
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc constructMeshedPatches[T](grid: RbfGrid[T]): Tensor[float]
Source   Edit  
proc eval[T](rbf: RbfBaseType[T]; x: Tensor[float]): Tensor[T]
Source   Edit  
proc eval[T](rbf: RbfType[T]; x: Tensor[float]): Tensor[T]
Source   Edit  
proc evalAlt[T](rbf: RbfType[T]; x: Tensor[float]): Tensor[T]
Source   Edit  
proc findAllBetween[T](grid: RbfGrid[T]; x: Tensor[float]; rho1, rho2: float): seq[
    int]
Source   Edit  
proc findAllWithin[T](grid: RbfGrid[T]; x: Tensor[float]; rho: float): seq[int]
Source   Edit  
proc findIndex[T](grid: RbfGrid[T]; point: Tensor[float]): int
Source   Edit  
proc newRbf[T](points: Tensor[float]; values: Tensor[T]; gridSize: int = 0;
               rbfFunc: RbfFunc = compactRbfFunc; epsilon: float = 1): RbfType[T]

Construct a Radial basis function interpolator using Partition of Unity.

Inputs:

  • points: The positions of the data points. Shape: (nPoints, nDims)
  • values: The values at the points. Can be multivalued. Shape: (nPoints, nValues)
  • gridSize: The number of cells along each dimension. Setting it to the default 0 will automatically choose a value based on the number of points.
  • rbfFunc: The RBF function that accepts shape parameter. Default is a C^2 compactly supported function.
  • epsilon: shape parameter. Default 1.

Returns:

  • Interpolant that can be evaluated using interp.eval(points).
Source   Edit  
proc newRbfBase[T](points: Tensor[float]; values: Tensor[T];
                   rbfFunc: RbfFunc = compactRbfFunc; epsilon: float = 1): RbfBaseType[
    T]
Source   Edit  
proc newRbfGrid[T](points: Tensor[float]; values: Tensor[T]; gridSize: int = 0): RbfGrid[
    T]
Source   Edit  
proc scalePoint(x: Tensor[float];
                limits: tuple[upper: Tensor[float], lower: Tensor[float]]): Tensor[
    float] {....raises: [ValueError], tags: [], forbids: [].}
Source   Edit  

Iterators

iterator neighbours[T](grid: RbfGrid[T]; k: int; searchLevels: int = 1): int
Source   Edit  
iterator neighboursExcludingCenter[T](grid: RbfGrid[T]; k: int): int
Source   Edit  

Templates

template compactRbfFuncScalar(r: float; epsilon: float): float
Source   Edit