TriangularMat

Struct TriangularMat 

Source
pub struct TriangularMat<T: Scalar> { /* private fields */ }
Expand description

Triangular matrix using packed storage.

This is a wrapper around PackedMat that provides triangular matrix semantics with efficient packed storage.

Implementations§

Source§

impl<T: Scalar> TriangularMat<T>

Source

pub fn zeros(n: usize, uplo: TriangularKind, diag: DiagonalKind) -> Self
where T: Zeroable,

Creates a new triangular matrix filled with zeros.

Source

pub fn unit_zeros(n: usize, uplo: TriangularKind) -> Self
where T: Zeroable,

Creates a unit triangular matrix (identity-like).

The diagonal is implicitly one and not stored.

Source

pub fn from_packed(packed: PackedMat<T>, diag: DiagonalKind) -> Self

Creates from a packed matrix.

Source

pub fn from_dense( mat: &MatRef<'_, T>, uplo: TriangularKind, diag: DiagonalKind, ) -> Self
where T: Zeroable,

Creates from a dense matrix view.

Source

pub fn dim(&self) -> usize

Returns the matrix dimension.

Source

pub fn shape(&self) -> (usize, usize)

Returns the shape (n, n).

Source

pub fn uplo(&self) -> TriangularKind

Returns the triangular kind.

Source

pub fn diag(&self) -> DiagonalKind

Returns the diagonal kind.

Source

pub fn len(&self) -> usize

Returns the packed storage length.

Source

pub fn is_empty(&self) -> bool

Returns true if empty.

Source

pub fn in_triangle(&self, row: usize, col: usize) -> bool

Returns true if element is in the stored triangle.

Source

pub fn get(&self, row: usize, col: usize) -> Option<&T>

Returns a reference to element.

For unit triangular matrices, returns None for diagonal elements.

Source

pub fn get_mut(&mut self, row: usize, col: usize) -> Option<&mut T>

Returns a mutable reference to element.

Source

pub fn set(&mut self, row: usize, col: usize, value: T)

Sets an element.

§Panics

Panics if setting diagonal on unit triangular matrix.

Source

pub fn as_ptr(&self) -> *const T

Returns a pointer to the packed data.

Source

pub fn as_mut_ptr(&mut self) -> *mut T

Returns a mutable pointer to the packed data.

Source

pub fn as_slice(&self) -> &[T]

Returns the packed data as a slice.

Source

pub fn as_slice_mut(&mut self) -> &mut [T]

Returns the packed data as a mutable slice.

Source

pub fn as_packed(&self) -> &PackedMat<T>

Returns a reference to the underlying packed matrix.

Source

pub fn as_packed_mut(&mut self) -> &mut PackedMat<T>

Returns a mutable reference to the underlying packed matrix.

Source

pub fn to_dense(&self) -> Mat<T>
where T: Zeroable,

Converts to a full dense matrix.

Source

pub fn diagonal(&self) -> Vec<T>

Returns the diagonal elements.

For unit triangular matrices, returns a vector of ones.

Source

pub fn set_diagonal(&mut self, diag: &[T])

Sets the diagonal elements.

§Panics

Panics for unit triangular matrices.

Source

pub fn fill(&mut self, value: T)

Fills the stored triangle with a value.

Source

pub fn scale(&mut self, alpha: T)

Scales the stored triangle by a scalar.

Source

pub fn transpose(&self) -> Self
where T: Zeroable,

Returns the transpose (flips upper/lower).

Trait Implementations§

Source§

impl<T: Clone + Scalar> Clone for TriangularMat<T>

Source§

fn clone(&self) -> TriangularMat<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Scalar + Debug> Debug for TriangularMat<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TriangularMat<T>

§

impl<T> RefUnwindSafe for TriangularMat<T>
where T: RefUnwindSafe,

§

impl<T> Send for TriangularMat<T>

§

impl<T> Sync for TriangularMat<T>

§

impl<T> Unpin for TriangularMat<T>

§

impl<T> UnwindSafe for TriangularMat<T>
where T: RefUnwindSafe,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.