TriangularView

Struct TriangularView 

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

A triangular matrix view over dense storage.

This is a logical view that treats the non-stored triangle as zeros. The underlying storage is a full dense matrix, but operations only access the stored triangle.

§Example

use oxiblas_matrix::{Mat, triangular::{TriangularView, DiagonalKind}};
use oxiblas_matrix::packed::TriangularKind;

let mut m: Mat<f64> = Mat::eye(3);
m[(0, 1)] = 2.0;
m[(0, 2)] = 3.0;
m[(1, 2)] = 4.0;

// Create upper triangular view
let tri = TriangularView::new(m.as_ref(), TriangularKind::Upper, DiagonalKind::NonUnit);

// Access upper triangle
assert_eq!(tri.get(0, 1), Some(&2.0));
// Lower triangle returns zero
assert_eq!(tri.get(1, 0), None);

Implementations§

Source§

impl<'a, T: Scalar> TriangularView<'a, T>

Source

pub fn new(mat: MatRef<'a, T>, uplo: TriangularKind, diag: DiagonalKind) -> Self

Creates a new triangular view over a matrix.

§Panics

Panics if the matrix is not square.

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 (upper/lower).

Source

pub fn diag(&self) -> DiagonalKind

Returns the diagonal kind (unit/non-unit).

Source

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

Returns true if element (row, col) is in the stored triangle.

Source

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

Returns a reference to the element at (row, col).

Returns None if the element is in the non-stored triangle. For unit triangular matrices, diagonal elements return None (they are implicitly one).

Source

pub fn as_inner(&self) -> MatRef<'a, T>

Returns the underlying matrix reference.

Source

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

Returns a pointer to the matrix data.

Source

pub fn row_stride(&self) -> usize

Returns the row stride.

Source

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

Converts to a full dense matrix.

Source

pub fn to_packed(&self) -> PackedMat<T>
where T: Zeroable,

Converts to packed storage.

Trait Implementations§

Source§

impl<'a, T: Clone + Scalar> Clone for TriangularView<'a, T>

Source§

fn clone(&self) -> TriangularView<'a, 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<'a, T: Copy + Scalar> Copy for TriangularView<'a, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for TriangularView<'a, T>

§

impl<'a, T> RefUnwindSafe for TriangularView<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for TriangularView<'a, T>

§

impl<'a, T> Sync for TriangularView<'a, T>

§

impl<'a, T> Unpin for TriangularView<'a, T>

§

impl<'a, T> UnwindSafe for TriangularView<'a, 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.