Skip to main content

MatRef

Struct MatRef 

Source
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>

Source

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

StatlaError::InvalidArgument, StatlaError::Dimension.

Source

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.

Source

pub fn rows(&self) -> usize

Number of rows.

Source

pub fn cols(&self) -> usize

Number of columns.

Source

pub fn ld(&self) -> usize

Leading dimension.

Source

pub fn get(&self, i: usize, j: usize) -> Option<T>

Entry (i, j); None out of range.

Source

pub fn col(&self, j: usize) -> Option<&'a [T]>

Column j (contiguous, length rows); None out of range.

Source

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.

Source

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).

Source

pub fn to_block(&self) -> DenseBlock<T>

An owned copy.

Trait Implementations§

Source§

impl<T: Real> AdjointOperator<T> for MatRef<'_, T>

Source§

fn apply_t(&mut self, x: &[T], y: &mut [T]) -> Result<(), OperatorError>

y ← Aᵀ x (x.len() == nrows(), y.len() == ncols()). Read more
Source§

fn apply_t_block( &mut self, x: MatRef<'_, T>, y: MatMut<'_, T>, ) -> Result<(), OperatorError>

Block version; default loops over AdjointOperator::apply_t. Read more
Source§

impl<'a, T: Clone + Real> Clone for MatRef<'a, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, T: Copy + Real> Copy for MatRef<'a, T>

Source§

impl<'a, T: Debug + Real> Debug for MatRef<'a, T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Real> LinearOperator<T> for MatRef<'_, T>

A borrowed dense matrix (zero copy from R/NumPy through xingo-ffi).

Source§

fn nrows(&self) -> usize

Rows of A (length of y).
Source§

fn ncols(&self) -> usize

Columns of A (length of x).
Source§

fn apply(&mut self, x: &[T], y: &mut [T]) -> Result<(), OperatorError>

y ← A x. Read more
Source§

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

Auto Trait Implementations§

§

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

§

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

§

impl<'a, T> Send for MatRef<'a, T>
where T: Sync,

§

impl<'a, T> Sync for MatRef<'a, T>
where T: Sync,

§

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

§

impl<'a, T> UnsafeUnpin for MatRef<'a, T>

§

impl<'a, T> UnwindSafe for MatRef<'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 = !

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

fn try_from(value: U) -> Result<T, !>

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.