Boundary Conditions (ND)
In ND, boundary conditions are specified per-axis via Tuples. A single BC value is broadcast to all axes.
- Constant / Linear: No BC needed
- Quadratic: One BC per axis (
Left(...)orRight(...)) - Cubic: Paired BCs per axis (
NaturalBC(),PeriodicBC(),BCPair(...), etc.)
For BC type details, see the 1D Boundary Conditions.
Example Data
using FastInterpolations
x = range(1, 10, length = 10)
y = range(0, 2pi, length = 5)
z = [0, 1, 3, 5, 10]
data2d = [cos(xi)*sin(yi) for xi in x, yi in y] # Real 2D data
data3d = [cos(xi)*sin(yi)+ zi*1im for xi in x, yi in y, zi in z] # Complex 3D dataBroadcast vs Per-Axis
# Broadcast: same BC on all axes
itp = cubic_interp((x, y, z), data3d; bc=NaturalBC())
# Equivalent to: bc=(NaturalBC(), NaturalBC(), NaturalBC())CubicInterpolantND{Float64, ComplexF64, 3}
├─ Grids: 3D, 10×5×5 points
│ ├─ x₁: Range ∈ [1, 10]
│ ├─ x₂: Range ∈ [0, 6.28]
│ └─ x₃: Vector ∈ [0, 10]
├─ Extrap: :none (all axes)
├─ Search: Binary (all axes)
└─ BC: Natural (S''=0 at ends) (all axes)# Per-axis: different BC per axis
itp = cubic_interp((x, y, z), data3d;
bc=(NaturalBC(), PeriodicBC(), CubicFit()))CubicInterpolantND{Float64, ComplexF64, 3}
├─ Grids: 3D, 10×5×5 points
│ ├─ x₁: Range ∈ [1, 10]
│ ├─ x₂: Range ∈ [0, 6.28]
│ └─ x₃: Vector ∈ [0, 10]
├─ Extrap: (:none, :wrap, :none)
├─ Search: Binary (all axes)
└─ BC:
├─ x₁: Natural (S''=0 at ends)
├─ x₂: Periodic
└─ x₃: CubicFit | CubicFitCubic ND
All 1D cubic BCs are available per-axis:
# Natural in x, periodic in y
bc = (NaturalBC(), PeriodicBC())
itp = cubic_interp((x, y), data2d; bc=bc)CubicInterpolantND{Float64, 2}
├─ Grids: 2D, 10×5 points
│ ├─ x₁: Range ∈ [1, 10]
│ └─ x₂: Range ∈ [0, 6.28]
├─ Extrap: (:none, :wrap)
└─ BC:
├─ x₁: Natural (S''=0 at ends)
└─ x₂: Periodic# Custom: known slope at x-left, auto-fit in y
bc = (BCPair(Deriv1(0.0), CubicFit()), CubicFit())
itp = cubic_interp((x, y), data2d; bc=bc)CubicInterpolantND{Float64, 2}
├─ Grids: 2D, 10×5 points
│ ├─ x₁: Range ∈ [1, 10]
│ └─ x₂: Range ∈ [0, 6.28]
├─ Extrap: :none (all axes)
└─ BC:
├─ x₁: Deriv1(0.0) | CubicFit
└─ x₂: CubicFit | CubicFitQuadratic ND
Quadratic BCs use Left(...) / Right(...) wrappers per-axis:
# Broadcast: same BC on all axes
itp = quadratic_interp((x, y), data2d; bc=Left(QuadraticFit()))
# Per-axis
itp = quadratic_interp((x, y), data2d;
bc=(Left(QuadraticFit()), Right(Deriv1(0.0))))QuadraticInterpolantND{Float64, 2}
├─ Grids: 2D, 10×5 points
│ ├─ x₁: Range ∈ [1, 10]
│ └─ x₂: Range ∈ [0, 6.28]
├─ Extrap: :none (all axes)
└─ BC:
├─ x₁: Left(QuadraticFit)
└─ x₂: Right(Deriv1(0.0))| BC | Description |
|---|---|
Left(QuadraticFit()) | 3-point auto-fit at left (default) |
Right(Deriv1(v)) | Known slope at right |
MinCurvFit() | Minimize total curvature |
See Also
- 1D Boundary Conditions — Full BC type reference
- Overview — ND API introduction