pub struct Ref<'a, T> { /* private fields */ }Expand description
A Matrix implementation that references its data.
Implementations§
Source§impl<'a, T> Ref<'a, T>
impl<'a, T> Ref<'a, T>
Sourcepub fn try_from_data(
data: &'a [T],
nrows: usize,
ncols: usize,
) -> Result<Self, TryFromError<&'a [T]>>
pub fn try_from_data( data: &'a [T], nrows: usize, ncols: usize, ) -> Result<Self, TryFromError<&'a [T]>>
Try to construct directly from data.
Returns an error if Layout::new fails for nrows and ncols or data.len()
is not equal to nrows * ncols.
Sourcepub fn row_vector(data: &'a [T]) -> Self
pub fn row_vector(data: &'a [T]) -> Self
Construct a row vector directly from data.
Sourcepub fn column_vector(data: &'a [T]) -> Self
pub fn column_vector(data: &'a [T]) -> Self
Construct a column vector directly from data.
Sourcepub fn into_slice(self) -> &'a [T]
pub fn into_slice(self) -> &'a [T]
Return the contents of self as a slice.
Unlike Matrix::as_slice, the returned slices inherits the lifetime of the Ref.
Trait Implementations§
impl<T> Copy for Ref<'_, T>
Source§impl<T> Matrix for Ref<'_, T>
impl<T> Matrix for Ref<'_, T>
Source§fn as_nonnull(&self) -> NonNull<T>
fn as_nonnull(&self) -> NonNull<T>
Return the base pointer for the matrix.
Source§unsafe fn row_unchecked(&self, row: usize) -> &[Self::Element]
unsafe fn row_unchecked(&self, row: usize) -> &[Self::Element]
Returns the requested row without bounds checking. Read more
Source§fn get_row(&self, row: usize) -> Option<&[Self::Element]>
fn get_row(&self, row: usize) -> Option<&[Self::Element]>
Return row
row if row < self.nrows(). Otherwise, return None.Source§fn rows(&self) -> Rows<'_, Self::Element> ⓘ
fn rows(&self) -> Rows<'_, Self::Element> ⓘ
Return a iterator over all rows in the matrix. Read more
Source§unsafe fn element_unchecked(&self, row: usize, col: usize) -> &Self::Element
unsafe fn element_unchecked(&self, row: usize, col: usize) -> &Self::Element
Returns a reference to an element without bounds checking. Read more
Source§fn subview(&self, rows: Range<usize>) -> Option<Ref<'_, Self::Element>>
fn subview(&self, rows: Range<usize>) -> Option<Ref<'_, Self::Element>>
Return a view over the rows in
rows, or None when the range is invalid.Source§fn window_iter(&self, batchsize: NonZeroUsize) -> Windows<'_, Self::Element> ⓘ
fn window_iter(&self, batchsize: NonZeroUsize) -> Windows<'_, Self::Element> ⓘ
Return an iterator that divides the matrix into sub-matrices with (up to)
batchsize rows with self.ncols() columns. Read moreSource§fn to_rowmajor_owned(&self) -> Owned<Self::Element>
fn to_rowmajor_owned(&self) -> Owned<Self::Element>
Return an
Owned with the same shape as self and cloned contents.Source§fn par_rows(&self) -> impl IndexedParallelIterator<Item = &[Self::Element]>
fn par_rows(&self) -> impl IndexedParallelIterator<Item = &[Self::Element]>
Return a parallel iterator over the rows of the matrix.
Source§fn par_window_iter(
&self,
batchsize: usize,
) -> impl IndexedParallelIterator<Item = Ref<'_, Self::Element>>
fn par_window_iter( &self, batchsize: usize, ) -> impl IndexedParallelIterator<Item = Ref<'_, Self::Element>>
Return a parallel iterator that divides the matrix into sub-matrices with (up to)
batchsize rows with self.ncols() columns. Read moreimpl<T> Send for Ref<'_, T>where
T: Sync,
impl<T> Sync for Ref<'_, T>where
T: Sync,
Auto Trait Implementations§
impl<'a, T> Freeze for Ref<'a, T>
impl<'a, T> RefUnwindSafe for Ref<'a, T>
impl<'a, T> Unpin for Ref<'a, T>
impl<'a, T> UnsafeUnpin for Ref<'a, T>
impl<'a, T> UnwindSafe for Ref<'a, T>
Blanket Implementations§
impl<T> AsyncFriendly for T
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more