Skip to main content

LuMod

Struct LuMod 

Source
pub struct LuMod<'a, T> { /* private fields */ }
Expand description

An updatable square-matrix representation backed by caller-owned factor storage.

The logical dimension never exceeds the capacity. The borrowed buffers contain the factors for the current square matrix and all update and solve operations allocate no heap memory. A represented matrix may be singular or contain non-finite values; solve operations report invalid U diagonals.

Implementations§

Source§

impl<'a, T: Real> LuMod<'a, T>

Source

pub fn from_storage( dimension: usize, capacity: usize, l: &'a mut [T], u: &'a mut [T], ) -> Result<Self, StorageError>

Adopts existing factor storage without changing its contents.

l needs capacity * capacity factor elements followed by capacity solve-work elements. u uses packed upper-triangular storage and needs capacity * (capacity + 1) / 2 elements. Extra elements are ignored.

§Preconditions

Unless dimension is zero, the required prefixes of l and u must already encode factors produced for the same capacity, such as buffers retained from an earlier LuMod. This mathematical condition is not validated.

§Postconditions

The buffer contents are unchanged and the returned value has the given dimension and capacity.

§Errors

Returns StorageError::InvalidDimension when dimension > capacity, StorageError::SizeOverflow when buffer-length arithmetic overflows, or StorageError::InsufficientStorage when either buffer is too short.

Source

pub fn dimension(&self) -> usize

Returns the current matrix dimension.

Source

pub fn capacity(&self) -> usize

Returns the maximum matrix dimension supported by the borrowed storage.

Source

pub fn push( &mut self, row: &[T], column: &[T], diagonal: T, workspace: &mut Workspace<'_, T>, ) -> Result<(), UpdateError>

Appends a last row and column to the represented matrix.

If the current matrix is A, success represents [[A, column], [row, diagonal]] and increases the dimension by one. row and column must each contain the current dimension, and the workspace must contain at least the new dimension. Singular and non-finite values are accepted.

§Errors

Returns UpdateError::CapacityExceeded, UpdateError::LengthMismatch, or UpdateError::InsufficientWorkspace when the corresponding structural requirement is not met. On error, the factors and dimension are unchanged.

Source

pub fn replace_row( &mut self, row: RowIndex, values: &[T], workspace: &mut Workspace<'_, T>, ) -> Result<(), UpdateError>

Replaces one row of the represented matrix.

On success, values becomes the complete row at the zero-based row index. The dimension is unchanged. Singular and non-finite values are accepted.

§Errors

Returns UpdateError::RowOutOfBounds, UpdateError::LengthMismatch, or UpdateError::InsufficientWorkspace. On error, the factors and dimension are unchanged.

Source

pub fn replace_column( &mut self, column: ColumnIndex, values: &[T], workspace: &mut Workspace<'_, T>, ) -> Result<(), UpdateError>

Replaces one column of the represented matrix.

On success, values becomes the complete column at the zero-based column index. The dimension is unchanged. Singular and non-finite values are accepted.

§Errors

Returns UpdateError::ColumnOutOfBounds, UpdateError::LengthMismatch, or UpdateError::InsufficientWorkspace. On error, the factors and dimension are unchanged.

Source

pub fn remove( &mut self, row: RowIndex, column: ColumnIndex, workspace: &mut Workspace<'_, T>, ) -> Result<Removal, UpdateError>

Removes a row and column, reducing the dimension by one.

Before removal, the last row is moved into row and the last column is moved into column when either requested index is not already last. The returned Removal identifies the original last indices that were moved, allowing callers to keep external row and column identities in sync. The workspace must contain at least the current dimension.

§Errors

Returns UpdateError::RowOutOfBounds, UpdateError::ColumnOutOfBounds, or UpdateError::InsufficientWorkspace. On error, the factors and dimension are unchanged.

Source

pub fn solve_in_place(&self, rhs: &mut [T]) -> Result<(), SolveError>

Solves A * x = rhs and overwrites rhs with x.

§Errors

Returns SolveError::LengthMismatch unless rhs.len() == dimension, SolveError::Singular for a zero U-factor diagonal, or SolveError::NonFiniteDiagonal for an infinite or NaN diagonal. On error, rhs is unchanged.

Source

pub fn solve_transpose_in_place(&self, rhs: &mut [T]) -> Result<(), SolveError>

Solves Aᵀ * x = rhs and overwrites rhs with x.

§Errors

Returns SolveError::LengthMismatch unless rhs.len() == dimension, SolveError::Singular for a zero U-factor diagonal, or SolveError::NonFiniteDiagonal for an infinite or NaN diagonal. On error, rhs is unchanged.

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for LuMod<'a, T>

§

impl<'a, T> !Send for LuMod<'a, T>

§

impl<'a, T> !Sync for LuMod<'a, T>

§

impl<'a, T> !UnwindSafe for LuMod<'a, T>

§

impl<'a, T> Freeze for LuMod<'a, T>
where &'a mut [T]: Freeze, &'a [Cell<T>]: Freeze,

§

impl<'a, T> Unpin for LuMod<'a, T>
where &'a mut [T]: Unpin, &'a [Cell<T>]: Unpin,

§

impl<'a, T> UnsafeUnpin for LuMod<'a, T>
where &'a mut [T]: UnsafeUnpin, &'a [Cell<T>]: UnsafeUnpin,

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> 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, 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.