Skip to main content

a_to_b_topp2

Function a_to_b_topp2 

Source
pub fn a_to_b_topp2(s: &[f64], a: &[f64]) -> Result<Vec<f64>, CoppError>
Expand description

Compute segment profile b from node profile a.

§Definition

For each segment [s_k, s_{k+1}], this function computes: $b_k = \frac{1}{2}\frac{a_{k+1}-a_k}{s_{k+1}-s_k}$.

§Input contract

  • valid when s.len() >= 2 and a.len() == s.len();
  • s must be finite and strictly increasing;
  • a must contain only finite values.

§Returns

Returns b with b.len() == s.len() - 1.

§Errors

Returns CoppError::InvalidInput when dimensions, monotonicity, or numeric finiteness requirements are violated.

§Contract

  • Output ordering is consistent with segment ordering on s.windows(2).
  • No allocation beyond returned vector and iterator temporaries.