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>
impl<'a, T: Scalar> TriangularView<'a, T>
Sourcepub fn new(mat: MatRef<'a, T>, uplo: TriangularKind, diag: DiagonalKind) -> Self
pub fn new(mat: MatRef<'a, T>, uplo: TriangularKind, diag: DiagonalKind) -> Self
Sourcepub fn uplo(&self) -> TriangularKind
pub fn uplo(&self) -> TriangularKind
Returns the triangular kind (upper/lower).
Sourcepub fn diag(&self) -> DiagonalKind
pub fn diag(&self) -> DiagonalKind
Returns the diagonal kind (unit/non-unit).
Sourcepub fn in_triangle(&self, row: usize, col: usize) -> bool
pub fn in_triangle(&self, row: usize, col: usize) -> bool
Returns true if element (row, col) is in the stored triangle.
Sourcepub fn get(&self, row: usize, col: usize) -> Option<&T>
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).
Sourcepub fn row_stride(&self) -> usize
pub fn row_stride(&self) -> usize
Returns the row stride.
Trait Implementations§
Source§impl<'a, T: Clone + Scalar> Clone for TriangularView<'a, T>
impl<'a, T: Clone + Scalar> Clone for TriangularView<'a, T>
Source§fn clone(&self) -> TriangularView<'a, T>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more