pub struct MatRef<'a, T: Real = f64> {
rows: usize,
cols: usize,
ld: usize,
data: &'a [T],
}Expand description
A borrowed column-major rows × cols matrix with leading dimension
ld ≥ rows: a_ij = data[i + j·ld] (the LAPACK/R layout; a C-order
NumPy array is the view of its transpose, a rule for xingo-ffi).
data.len() ≥ ld·(cols − 1) + rows when cols > 0.
Fields§
§rows: usize§cols: usize§ld: usize§data: &'a [T]Implementations§
Source§impl<'a, T: Real> MatRef<'a, T>
impl<'a, T: Real> MatRef<'a, T>
Sourcepub fn new(
rows: usize,
cols: usize,
ld: usize,
data: &'a [T],
) -> Result<Self, StatlaError>
pub fn new( rows: usize, cols: usize, ld: usize, data: &'a [T], ) -> Result<Self, StatlaError>
A view of data (checked: ld ≥ rows, length, no usize
overflow; finiteness is not checked here, but by the consumers).
§Errors
Sourcepub fn from_block(b: &'a DenseBlock<T>) -> Self
pub fn from_block(b: &'a DenseBlock<T>) -> Self
The view of a whole block (ld = rows).
A block whose data is shorter than rows · cols (its public
fields are inconsistent) gives a view with no columns: never a
panic.
Sourcepub fn col(&self, j: usize) -> Option<&'a [T]>
pub fn col(&self, j: usize) -> Option<&'a [T]>
Column j (contiguous, length rows); None out of range.
Sourcepub fn cols_range(&self, j0: usize, j1: usize) -> Result<Self, StatlaError>
pub fn cols_range(&self, j0: usize, j1: usize) -> Result<Self, StatlaError>
The columns j0..j1 as a view (no copy).
§Errors
StatlaError::InvalidArgument if the range is not inside.
Sourcepub(crate) fn raw(&self) -> &'a [T]
pub(crate) fn raw(&self) -> &'a [T]
The underlying slice (crate-internal: the operator loops of Chapter
12.0.5 index it with ld; (W1) keeps every index in bounds).
Sourcepub fn to_block(&self) -> DenseBlock<T>
pub fn to_block(&self) -> DenseBlock<T>
An owned copy.
Trait Implementations§
Source§impl<T: Real> AdjointOperator<T> for MatRef<'_, T>
impl<T: Real> AdjointOperator<T> for MatRef<'_, T>
Source§fn apply_t_block(
&mut self,
x: MatRef<'_, T>,
y: MatMut<'_, T>,
) -> Result<(), OperatorError>
fn apply_t_block( &mut self, x: MatRef<'_, T>, y: MatMut<'_, T>, ) -> Result<(), OperatorError>
AdjointOperator::apply_t. Read moreimpl<'a, T: Copy + Real> Copy for MatRef<'a, T>
Source§impl<T: Real> LinearOperator<T> for MatRef<'_, T>
A borrowed dense matrix (zero copy from R/NumPy through xingo-ffi).
impl<T: Real> LinearOperator<T> for MatRef<'_, T>
A borrowed dense matrix (zero copy from R/NumPy through xingo-ffi).
Source§fn apply_block(
&mut self,
x: MatRef<'_, T>,
y: MatMut<'_, T>,
) -> Result<(), OperatorError>
fn apply_block( &mut self, x: MatRef<'_, T>, y: MatMut<'_, T>, ) -> Result<(), OperatorError>
Y ← A X for a block of columns; the default loops over
LinearOperator::apply. Dense and sparse implementations
override it (one pass over A for l columns — the cost that
matters in crate::rsvd()). Read more