Skip to main content

bounded_transform_len

Function bounded_transform_len 

Source
fn bounded_transform_len(
    a_len: usize,
    b_len: usize,
    base: usize,
) -> Option<usize>
Examples found in repository?
crates/competitive/src/math/min_plus_convolution/mod.rs (line 182)
167fn bounded_requirements_from_extrema<T>(
168    a_len: usize,
169    b_len: usize,
170    (a_min, a_max): (T, T),
171    (b_min, b_max): (T, T),
172) -> Option<BoundedRequirements<T>>
173where
174    T: Signed,
175    T::Unsigned: TryInto<usize>,
176{
177    let a_span = a_max.abs_diff(a_min).try_into().ok()?;
178    let b_span = b_max.abs_diff(b_min).try_into().ok()?;
179    let base = a_span
180        .checked_add(b_span)
181        .and_then(|span| span.checked_add(1))?;
182    let transform_len = bounded_transform_len(a_len, b_len, base)?;
183    Some(BoundedRequirements {
184        a_min,
185        b_min,
186        base,
187        transform_len,
188    })
189}