Skip to main content

Ref

Struct Ref 

Source
pub struct Ref<'a, T> { /* private fields */ }
Expand description

A Matrix implementation that references its data.

Implementations§

Source§

impl<'a, T> Ref<'a, T>

Source

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.

Source

pub fn row_vector(data: &'a [T]) -> Self

Construct a row vector directly from data.

Source

pub fn column_vector(data: &'a [T]) -> Self

Construct a column vector directly from data.

Source

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§

Source§

impl<T> Clone for Ref<'_, 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<T> Copy for Ref<'_, T>

Source§

impl<'a, T: Debug> Debug for Ref<'a, T>

Source§

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

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

impl<'a, T> From<Ref<'a, T>> for Strided<'a, T>

Source§

fn from(matrix: Ref<'a, T>) -> Self

Converts to this type from the input type.
Source§

impl<T> Matrix for Ref<'_, T>

Source§

type Element = T

The type of the element stored in the matrix.
Source§

fn as_nonnull(&self) -> NonNull<T>

Return the base pointer for the matrix.
Source§

fn layout(&self) -> Layout<T>

Return the Layout for the matrix.
Source§

fn nrows(&self) -> usize

Return the number of rows in the matrix.
Source§

fn ncols(&self) -> usize

Return the number of columns in the matrix.
Source§

unsafe fn row_unchecked(&self, row: usize) -> &[Self::Element]

Returns the requested row without bounds checking. Read more
Source§

fn as_ptr(&self) -> *const Self::Element

Return a pointer to the base of the matrix.
Source§

fn as_slice(&self) -> &[Self::Element]

Return the underlying data as a slice.
Source§

fn row(&self, row: usize) -> &[Self::Element]

Return row row as a slice. Read more
Source§

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

Return a iterator over all rows in the matrix. Read more
Source§

unsafe fn element_unchecked(&self, row: usize, col: usize) -> &Self::Element

Returns a reference to an element without bounds checking. Read more
Source§

fn get_element(&self, row: usize, col: usize) -> Option<&Self::Element>

Return the value at the specified row and col. Read more
Source§

fn element(&self, row: usize, col: usize) -> &Self::Element

Return the value at the specified row and col. Read more
Source§

fn as_view(&self) -> Ref<'_, Self::Element>

Return a view over the matrix.
Source§

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

Return an iterator that divides the matrix into sub-matrices with (up to) batchsize rows with self.ncols() columns. Read more
Source§

fn to_rowmajor_owned(&self) -> Owned<Self::Element>
where Self::Element: Clone,

Return an Owned with the same shape as self and cloned contents.
Source§

fn try_map<F, R>(&self, f: F) -> Result<Owned<R>, LayoutError>
where F: FnMut(&Self::Element) -> R,

Create a new Matrix by applying the closure f to each element. Read more
Source§

fn map<F, R>(&self, f: F) -> Owned<R>
where F: FnMut(&Self::Element) -> R,

Create a new Matrix by applying the closure f to each element. Read more
Source§

fn transpose(&self) -> Owned<Self::Element>
where Self::Element: Clone,

Transpose the elements in self.
Source§

fn par_rows(&self) -> impl IndexedParallelIterator<Item = &[Self::Element]>
where Self::Element: Sync,

Return a parallel iterator over the rows of the matrix.
Source§

fn par_window_iter( &self, batchsize: usize, ) -> impl IndexedParallelIterator<Item = Ref<'_, Self::Element>>
where Self::Element: Sync,

Return a parallel iterator that divides the matrix into sub-matrices with (up to) batchsize rows with self.ncols() columns. Read more
Source§

impl<T> PartialEq for Ref<'_, T>
where T: PartialEq,

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a, T> Reborrow<'a> for Ref<'_, T>

Source§

type Target = Ref<'a, T>

Source§

fn reborrow(&'a self) -> Self::Target

Borrow self into a generalized reference type and reborrow
Source§

impl<T> Send for Ref<'_, T>
where T: Sync,

Source§

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>
where NonNull<T>: Unpin, Layout<T>: Unpin, PhantomData<&'a [T]>: Unpin,

§

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

§

impl<'a, T> UnwindSafe for Ref<'a, T>

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> AsyncFriendly for T
where T: Send + Sync + 'static,

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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V