Skip to main content

Module adaptive

Module adaptive 

Source
Expand description

Adaptive determinant filtering with certified bounds.

det_direct_with_errbound() returns a closed-form determinant together with the conservative absolute error bound used by the fast filter, computed from one call that evaluates the determinant once and computes its matching bound. It returns None when a D ≤ 4 computation may be affected by gradual underflow, as well as for unsupported D ≥ 5 dimensions. It returns LaError::NonFinite if the determinant or bound computation overflows to NaN or infinity. This method does NOT require the exact feature — it uses pure f64 arithmetic and is available by default. Use det_errbound() when only the bound is needed. The paired API enables custom adaptive-precision logic for geometric predicates:

use la_stack::prelude::*;

let matrix = Matrix::<3>::identity();
let sign = matrix.det_direct_with_errbound()?.and_then(|value| {
    if value.determinant() > value.absolute_error_bound() {
        Some(1)
    } else if -value.determinant() > value.absolute_error_bound() {
        Some(-1)
    } else {
        None // The bound cannot establish a sign.
    }
});
assert_eq!(sign, Some(1));

With the exact feature, Matrix::det_sign_exact() already handles filtering and exact fallback. The custom adaptive example shows positive, singular, and overflowing filter cases. It requires exact.

The error coefficients (ERR_COEFF_2, ERR_COEFF_3, ERR_COEFF_4) are conservative, dimension-specific constants, not caller-tunable tolerances. The mathematical basis documents the bound and states its range preconditions. The constants are explicit crate-root exports for advanced users who want to compose the same bound: use la_stack::{ERR_COEFF_2, ERR_COEFF_3, ERR_COEFF_4};. They intentionally stay out of the common prelude.