Skip to main content

grow_expansion

Function grow_expansion 

Source
pub fn grow_expansion(
    e: &[f64],
    b: f64,
    h: &mut [f64],
) -> Result<usize, ExpansionError>
Expand description

Grow an expansion by adding a scalar: h = e + b.

e is the input expansion (length elen), b is the scalar, h is the output buffer (must have length >= elen + 1). Returns the number of components written to h (always elen + 1).

Implements Shewchuk’s grow_expansion (§2.4): a single pass that merges b into a non-overlapping, increasing-magnitude expansion using two_sum. The nonzero output components retain that invariant. Zero components are retained to preserve the elen + 1 return contract; remove them before using a last-component sign test.

§Errors

Returns ExpansionError::OutputTooSmall if h.len() < elen + 1.