pub struct Matrix<T: Real> {
pub nrows: usize,
pub ncols: usize,
pub data: Vec<T>,
pub storage: MatrixStorage<T>,
}Expand description
Generic matrix for linear algebra (typically square in current use).
Fields§
§nrows: usize§ncols: usize§data: Vec<T>§storage: MatrixStorage<T>Implementations§
Source§impl<T: Real> Matrix<T>
impl<T: Real> Matrix<T>
Sourcepub fn component_add(self, rhs: T) -> Self
pub fn component_add(self, rhs: T) -> Self
Return a new matrix where each stored entry has rhs added. Off-band for banded becomes dense if rhs != 0.
Source§impl<T: Real> Matrix<T>
impl<T: Real> Matrix<T>
Sourcepub fn banded(n: usize, ml: usize, mu: usize) -> Self
pub fn banded(n: usize, ml: usize, mu: usize) -> Self
Zero banded matrix with the given bandwidths. For entry (i,j) within the band, index maps to data[i - j + mu, j].
Sourcepub fn diagonal(diag: Vec<T>) -> Self
pub fn diagonal(diag: Vec<T>) -> Self
Diagonal matrix from the provided diagonal entries (ml=mu=0).
Sourcepub fn lower_triangular(n: usize) -> Self
pub fn lower_triangular(n: usize) -> Self
Zero lower-triangular matrix (ml = n-1, mu = 0).
Sourcepub fn upper_triangular(n: usize) -> Self
pub fn upper_triangular(n: usize) -> Self
Zero upper-triangular matrix (ml = 0, mu = n-1).
Source§impl<T: Real> Matrix<T>
impl<T: Real> Matrix<T>
Sourcepub fn component_mul(self, rhs: T) -> Self
pub fn component_mul(self, rhs: T) -> Self
Return a new matrix where each stored entry is multiplied by rhs.
Sourcepub fn component_mul_mut(&mut self, rhs: T)
pub fn component_mul_mut(&mut self, rhs: T)
In-place component-wise scalar multiplication: self[i,j] *= rhs for all stored entries.
For Identity, converts to a diagonal banded matrix with rhs on the diagonal.
pub fn mul_state<V: State<T>>(&self, vec: &V) -> V
Trait Implementations§
Source§impl<T: Real> AddAssign for Matrix<T>
impl<T: Real> AddAssign for Matrix<T>
Source§fn add_assign(&mut self, rhs: Matrix<T>)
fn add_assign(&mut self, rhs: Matrix<T>)
Performs the
+= operation. Read moreSource§impl<T: Real> IndexMut<(usize, usize)> for Matrix<T>
2D indexing by (i, j), mutable (where supported).
impl<T: Real> IndexMut<(usize, usize)> for Matrix<T>
2D indexing by (i, j), mutable (where supported).
Auto Trait Implementations§
impl<T> Freeze for Matrix<T>where
T: Freeze,
impl<T> RefUnwindSafe for Matrix<T>where
T: RefUnwindSafe,
impl<T> Send for Matrix<T>
impl<T> Sync for Matrix<T>
impl<T> Unpin for Matrix<T>where
T: Unpin,
impl<T> UnwindSafe for Matrix<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.