pub struct Mat<T> { /* private fields */ }Expand description
Column-major dense matrix with infallible indexing.
Implementations§
Source§impl<T> Mat<T>
impl<T> Mat<T>
Sourcepub fn from_vec_col_major(shape: [usize; 2], data: Vec<T>) -> Self
pub fn from_vec_col_major(shape: [usize; 2], data: Vec<T>) -> Self
Wrap a column-major buffer.
§Panics
Panics if data.len() != nrows * ncols; callers construct the buffer
with the matching size.
Sourcepub fn from_fn<F: FnMut(&[usize]) -> T>(shape: [usize; 2], f: F) -> Self
pub fn from_fn<F: FnMut(&[usize]) -> T>(shape: [usize; 2], f: F) -> Self
Build a matrix by evaluating f(&[i, j]) for every element.
Sourcepub fn dims(&self) -> [usize; 2]
pub fn dims(&self) -> [usize; 2]
Shape as [nrows, ncols], the form Mat::from_fn takes.
pub fn nrows(&self) -> usize
pub fn ncols(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Mutable column-major storage.
Source§impl<T: TensorScalar> Mat<T>
impl<T: TensorScalar> Mat<T>
Sourcepub fn into_typed(self) -> TypedTensor<T, Rank<2>>
pub fn into_typed(self) -> TypedTensor<T, Rank<2>>
Move into a tenferro rank-2 tensor without copying.
Sourcepub fn from_typed(t: &TypedTensor<T, Rank<2>>) -> Result<Self, Error>
pub fn from_typed(t: &TypedTensor<T, Rank<2>>) -> Result<Self, Error>
Copy a host-resident tenferro matrix.
§Errors
Returns an error when the tensor is not host-resident compact column-major storage.
Trait Implementations§
impl<T: PartialEq> StructuralPartialEq for Mat<T>
Auto Trait Implementations§
impl<T> Freeze for Mat<T>
impl<T> RefUnwindSafe for Mat<T>where
T: RefUnwindSafe,
impl<T> Send for Mat<T>where
T: Send,
impl<T> Sync for Mat<T>where
T: Sync,
impl<T> Unpin for Mat<T>where
T: Unpin,
impl<T> UnsafeUnpin for Mat<T>
impl<T> UnwindSafe for Mat<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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
impl<T, U> Imply<T> for U
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