Skip to main content

IntervalMatrix

Struct IntervalMatrix 

Source
pub struct IntervalMatrix<const D: usize> { /* private fields */ }
Expand description

Fixed-size square matrix of outward-rounded Interval entries.

Storage is the inline array [[Interval; D]; D]. Determinants use a division-free Leibniz subset DP through D=7, so zero-containing pivot intervals never require a special case and no heap allocation occurs.

§Examples

use la_stack::prelude::*;

let matrix = IntervalMatrix::<3>::try_from_point_rows([
    [0.0, 1.0, 0.0],
    [1.0, 0.0, 0.0],
    [0.0, 0.0, 1.0],
])?;
assert_eq!(matrix.det_sign()?, IntervalDeterminantSign::Negative);

Implementations§

Source§

impl<const D: usize> IntervalMatrix<D>

Source

pub const fn from_rows(rows: [[Interval; D]; D]) -> Self

Construct an interval matrix from already-validated interval rows.

See det for an example with non-point entries.

Source

pub const fn try_from_point_rows(rows: [[f64; D]; D]) -> Result<Self, LaError>

Lift finite binary64 rows into point intervals.

This preserves the stored binary64 values exactly; it does not recover uncertainty from arithmetic performed before this call. See IntervalMatrix for a determinant-sign example using this constructor.

§Errors

Returns LaError::NonFinite with matrix coordinates for the first NaN or infinity in row-major order.

Source

pub const fn from_matrix(matrix: &Matrix<D>) -> Self

Lift a finite Matrix into point intervals.

Earlier rounded expression construction is not enclosed; use interval operations while constructing derived coefficients when that uncertainty belongs in the proof.

§Examples
use la_stack::prelude::*;

let matrix = Matrix::<2>::try_from_rows([[2.0, 0.0], [0.0, 3.0]])?;
let intervals = IntervalMatrix::from_matrix(&matrix);
assert_eq!(intervals.det()?, Interval::point(6.0)?);
Source

pub const fn zero() -> Self

All-zero interval matrix.

Source

pub const fn identity() -> Self

Identity interval matrix.

Source

pub const fn as_rows(&self) -> &[[Interval; D]; D]

Borrow the row-major interval storage.

Source

pub const fn into_rows(self) -> [[Interval; D]; D]

Consume this matrix and return its row-major interval storage.

Source

pub const fn get(&self, row: usize, column: usize) -> Option<Interval>

Get an interval entry with bounds checking.

Source

pub const fn try_get( &self, row: usize, column: usize, ) -> Result<Interval, LaError>

Get an interval entry while preserving index context on failure.

See set for an example of mutation and checked access.

§Errors

Returns LaError::IndexOutOfBounds when either index is not < D.

Source

pub const fn set( &mut self, row: usize, column: usize, value: Interval, ) -> Result<(), LaError>

Set an interval entry with bounds checking.

Validation is unnecessary for the value because Interval already carries the finite ordered-bound proof. An invalid index leaves the matrix unchanged.

§Examples
use core::assert_matches;
use la_stack::prelude::*;

let mut matrix = IntervalMatrix::<2>::identity();
let range = Interval::try_new(2.0, 3.0)?;
matrix.set(0, 0, range)?;
assert_eq!(matrix.try_get(0, 0)?, range);
let before = matrix;
assert_matches!(
    matrix.set(2, 0, Interval::ZERO),
    Err(LaError::IndexOutOfBounds { row: 2, col: 0, dim: 2, .. })
);
assert_eq!(matrix, before);
§Errors

Returns LaError::IndexOutOfBounds when either index is not < D.

Source

pub const fn det(&self) -> Result<Interval, LaError>

Enclose the determinant with division-free subset dynamic programming.

For each column subset, the DP stores the determinant interval of the leading rows and those columns. This evaluates the Leibniz expansion in D × 2^(D-1) products and additions without choosing or dividing by a pivot. The returned interval therefore encloses every exact-real determinant represented by the input intervals, subject only to an explicit range failure.

The D=0 determinant follows the empty-product convention and is [1, 1].

Use det_sign when only sign evidence is needed.

§Examples
use la_stack::prelude::*;

// Every represented diagonal matrix has a determinant in [8, 15].
let matrix = IntervalMatrix::<2>::from_rows([
    [Interval::try_new(2.0, 3.0)?, Interval::ZERO],
    [Interval::ZERO, Interval::try_new(4.0, 5.0)?],
]);
assert_eq!(matrix.det()?, Interval::try_new(8.0, 15.0)?);
§Errors

Returns LaError::UnsupportedDimension for D>7. Returns LaError::IntervalRangeExhausted with interval-determinant provenance when an exact intermediate has no finite binary64 enclosure; callers can then proceed to an exact or higher-range fallback.

Source

pub const fn det_sign(&self) -> Result<IntervalDeterminantSign, LaError>

Return proof-bearing determinant sign evidence.

An interval strictly on one side of zero proves that sign. Only the singleton interval [0, 0] proves Zero; every other overlap with zero is IntervalDeterminantSign::Inconclusive.

§Examples
use la_stack::prelude::*;

let mut matrix = IntervalMatrix::<2>::identity();
assert_eq!(matrix.det_sign()?, IntervalDeterminantSign::Positive);

matrix.set(0, 0, Interval::try_new(-1.0, 1.0)?)?;
// This range includes nonsingular matrices of both signs; a caller
// needs tighter or exact input before it can decide singularity.
assert_eq!(matrix.det_sign()?, IntervalDeterminantSign::Inconclusive);

matrix.set(0, 0, Interval::ZERO)?;
assert_eq!(matrix.det_sign()?, IntervalDeterminantSign::Zero);
§Errors

Propagates the dimension and arithmetic range failures from det.

Trait Implementations§

Source§

impl<const D: usize> Clone for IntervalMatrix<D>

Source§

fn clone(&self) -> IntervalMatrix<D>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const D: usize> Copy for IntervalMatrix<D>

Source§

impl<const D: usize> Debug for IntervalMatrix<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const D: usize> Default for IntervalMatrix<D>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const D: usize> PartialEq for IntervalMatrix<D>

Source§

fn eq(&self, other: &IntervalMatrix<D>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<const D: usize> StructuralPartialEq for IntervalMatrix<D>

Auto Trait Implementations§

§

impl<const D: usize> Freeze for IntervalMatrix<D>
where [[Interval; D]; D]: Freeze,

§

impl<const D: usize> RefUnwindSafe for IntervalMatrix<D>
where [[Interval; D]; D]: RefUnwindSafe,

§

impl<const D: usize> Send for IntervalMatrix<D>
where [[Interval; D]; D]: Send,

§

impl<const D: usize> Sync for IntervalMatrix<D>
where [[Interval; D]; D]: Sync,

§

impl<const D: usize> Unpin for IntervalMatrix<D>
where [[Interval; D]; D]: Unpin,

§

impl<const D: usize> UnsafeUnpin for IntervalMatrix<D>
where [[Interval; D]; D]: UnsafeUnpin,

§

impl<const D: usize> UnwindSafe for IntervalMatrix<D>
where [[Interval; D]; D]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.