pub struct GridND<F: SemiflowFloat = f64, const D: usize = 2> {
pub axes: [Grid1D<F>; D],
pub interp: InterpKind,
}Expand description
d-dimensional tensor-product grid with uniform axes.
Each axis is a Grid1D<F> with independent geometry, boundary policy,
and interpolation kind. Dimension D is a const generic parameter.
Values are stored axis-0-fastest:
flat_idx = k_{D-1}·n_{D-2}·…·n₀ + … + k₁·n₀ + k₀.
§Example
use semiflow::{Grid1D, grid_nd::GridND};
let axes = core::array::from_fn(|_| Grid1D::new(-5.0_f64, 5.0, 16).unwrap());
let grid = GridND::<f64, 2>::new(axes).unwrap();
assert_eq!(grid.len(), 256); // 16*16Fields§
§axes: [Grid1D<F>; D]Per-axis grids. axes[0] is the fastest-varying axis.
Each axis contributes its own crate::grid::BoundaryPolicy to
GridFnND::sample. The axes’ individual InterpKinds are NOT
consulted — see GridND::interp.
interp: InterpKindTensor-product interpolation kind used by GridFnND::sample.
Default InterpKind::CubicHermite (ADR-0191). A single grid-level
knob rather than a per-axis one because Grid1D::new already stamps
every axis with SepticHermite, leaving no way to tell a deliberate
choice from an inherited default. CubicHermite removes the accumulated
per-step interpolation variance at 4^D nodes per sample; SepticHermite
would cost 8^D for no gain on that failure mode, and is not implemented
for D > 1.
Implementations§
Source§impl<F: SemiflowFloat, const D: usize> GridND<F, D>
impl<F: SemiflowFloat, const D: usize> GridND<F, D>
Sourcepub fn new(axes: [Grid1D<F>; D]) -> Result<Self, SemiflowError>
pub fn new(axes: [Grid1D<F>; D]) -> Result<Self, SemiflowError>
Construct from an array of D axes.
§Errors
DomainViolationifD == 0.DomainViolationif any axis hasn < 4.
Sourcepub fn with_interp(self, interp: InterpKind) -> Self
pub fn with_interp(self, interp: InterpKind) -> Self
Override the tensor-product interpolation kind (builder, ADR-0191).
Only InterpKind::CubicHermite and InterpKind::Linear are
implemented for D > 1; the others make GridFnND::sample return
SemiflowError::Unsupported. Linear needs the linear-interp
feature, matching the 1-D contract.
Sourcepub fn flat_idx(&self, idx: &[usize; D]) -> usize
pub fn flat_idx(&self, idx: &[usize; D]) -> usize
Convert a multi-index [k₀, k₁, …, k_{D-1}] to a flat index.
Axis 0 is fastest-varying (row-major in axis-0 direction).
§Panics
Panics in debug if kd >= n_d for any d.