Skip to main content

Mat

Struct Mat 

Source
pub struct Mat<T> { /* private fields */ }
Expand description

Column-major dense matrix with infallible indexing.

Implementations§

Source§

impl<T> Mat<T>

Source

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.

Source

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.

Source

pub fn shape(&self) -> &(usize, usize)

Shape as (nrows, ncols).

Source

pub fn dims(&self) -> [usize; 2]

Shape as [nrows, ncols], the form Mat::from_fn takes.

Source

pub fn dim(&self, axis: usize) -> usize

Extent of axis axis (0 = rows, 1 = columns).

Source

pub fn nrows(&self) -> usize

Source

pub fn ncols(&self) -> usize

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn as_slice(&self) -> &[T]

Column-major storage.

Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Mutable column-major storage.

Source

pub fn into_vec(self) -> Vec<T>

Consume into the column-major buffer.

Source

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

Contiguous column j.

Source

pub fn col_mut(&mut self, j: usize) -> &mut [T]

Mutable contiguous column j.

Source

pub fn iter(&self) -> Iter<'_, T> ⓘ

Iterate over elements in column-major order.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T> ⓘ

Iterate mutably over elements in column-major order.

Source

pub fn map<U, F: FnMut(&T) -> U>(&self, f: F) -> Mat<U>

Apply f element-wise.

Source§

impl<T: Clone> Mat<T>

Source

pub fn from_elem(shape: [usize; 2], elem: T) -> Self

Matrix filled with elem.

Source

pub fn transpose(&self) -> Self

Transposed copy.

Source

pub fn leading_cols(&self, ncols: usize) -> Self

Copy of the leading ncols columns.

Source§

impl<T: Clone> Mat<T>

Source

pub fn from_rows(rows: Vec<Vec<T>>) -> Self

Build from a list of rows (row-literal order, column-major storage).

§Panics

Panics if the rows have different lengths.

Source§

impl<T: Clone + Zero> Mat<T>

Source

pub fn zeros(shape: [usize; 2]) -> Self

Zero matrix.

Source§

impl<T: TensorScalar> Mat<T>

Source

pub fn into_typed(self) -> TypedTensor<T, Rank<2>>

Move into a tenferro rank-2 tensor without copying.

Source

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§

Source§

impl<T: Clone> Clone for Mat<T>

Source§

fn clone(&self) -> Mat<T>

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: Debug> Debug for Mat<T>

Source§

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

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

impl<T> Index<&[usize]> for Mat<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, idx: &[usize]) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> Index<[usize; 2]> for Mat<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, idx: [usize; 2]) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<[usize; 2]> for Mat<T>

Source§

fn index_mut(&mut self, idx: [usize; 2]) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T: PartialEq> PartialEq for Mat<T>

Source§

fn eq(&self, other: &Mat<T>) -> bool

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

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

Inequality operator !=. Read more
Source§

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

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

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

§

fn vzip(self) -> V