pub struct StencilTable {
pub offsets: Vec<u32>,
pub indices: Vec<u32>,
pub weights: Vec<f32>,
}Expand description
A sparse linear map from input points to output points.
Each output point is a weighted sum of a few input points — its stencil.
Apply it to any Interpolatable data with interpolate().
Stored compressed (CSR): output i’s source indices and weights are the
slices indices[offsets[i]..offsets[i + 1]] and the matching weights.
Fields§
§offsets: Vec<u32>CSR row offsets. Length = output_count + 1.
indices: Vec<u32>Source indices (into the input buffer), flat.
weights: Vec<f32>Source weights (parallel to indices).
Implementations§
Source§impl StencilTable
impl StencilTable
Sourcepub fn output_count(&self) -> usize
pub fn output_count(&self) -> usize
Number of output points this table produces.
Sourcepub fn interpolate<T: Interpolatable>(&self, input: &[T]) -> Vec<T>
pub fn interpolate<T: Interpolatable>(&self, input: &[T]) -> Vec<T>
Apply stencils to an input buffer, producing one output value per stencil.
Sourcepub fn interpolate_rows<T: Interpolatable>(
&self,
input: &[T],
rows: &[u32],
output: &mut [T],
)
pub fn interpolate_rows<T: Interpolatable>( &self, input: &[T], rows: &[u32], output: &mut [T], )
Apply stencils for only rows, scattering each result into
output[row] and leaving every other entry untouched.
The CPU analogue of an indexed (sparse) dispatch: pair with
affected_outputs to
re-evaluate only the outputs a control-point edit changed, splicing them
into the previous output buffer. Bit-identical to
interpolate on the recomputed rows.
output must have at least output_count entries
and every index in rows must be < output_count.
Sourcepub fn compose(&self, other: &StencilTable) -> Self
pub fn compose(&self, other: &StencilTable) -> Self
Compose two stencil tables: self maps A→B, other maps B→C.
The result maps A→C by substituting B’s stencils into C’s.
Trait Implementations§
Source§impl Clone for StencilTable
impl Clone for StencilTable
Source§fn clone(&self) -> StencilTable
fn clone(&self) -> StencilTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StencilTable
impl Debug for StencilTable
Source§impl<'de> Deserialize<'de> for StencilTable
impl<'de> Deserialize<'de> for StencilTable
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'a> From<&'a StencilTable> for InverseStencilMap
impl<'a> From<&'a StencilTable> for InverseStencilMap
Source§fn from(table: &'a StencilTable) -> Self
fn from(table: &'a StencilTable) -> Self
Build the inverse (transpose) of table in a single pass over its
entries.
Source§impl PartialEq for StencilTable
impl PartialEq for StencilTable
Source§fn eq(&self, other: &StencilTable) -> bool
fn eq(&self, other: &StencilTable) -> bool
self and other values to be equal, and is used by ==.