Skip to main content

bilinear_wave

Function bilinear_wave 

Source
pub fn bilinear_wave<V, T, R0, R1, RO>(
    h0: &mut ValueHistory<V, T, R0>,
    h1: &mut ValueHistory<V, T, R1>,
    emit: impl FnMut(V, V, T, RO),
)
where V: Copy + Ord, T: Ord + Clone + Lattice, R0: Semigroup + Multiply<R1, Output = RO> + Clone, R1: Semigroup + Clone,
Expand description

Produces the join of two histories: every pair of edits, diffs multiplied and times joined, visited in time order. Repeatedly steps the history with the earlier un-replayed edit and multiplies it against the other’s buffer, which is consolidated under the meet of its remaining times as the wave advances — so work is bounded by the netted accumulation sizes rather than the raw history lengths.

emit receives every produced (id0, id1, joined time, multiplied diff). Both histories must be pre-loaded (load/load_iter) and are fully drained. For small histories a plain cross product is cheaper; callers should gate on size.