Mat

Struct Mat 

Source
pub struct Mat<S>
where S: Scalar,
{ /* private fields */ }
Expand description

Extremely basic matrix type, written as Mat<S>, short for “matrix”.

§Implementation Details

  • The underlying data structure is a Vec<S>.
  • This matrix implementation is row-major; the elements of the matrix are stored row-by-row in a one-dimensional “flat” data structure (in this case a Vec<S>).

§Motivation

Rust does not have a matrix type in the std library, and users of this crate may not want to have dependencies such as nalgebra, ndarray, and/or faer.

Implementations§

Source§

impl<S> Mat<S>
where S: Scalar,

Source

pub fn iter(&self) -> impl Iterator<Item = &S>

Returns an iterator over the elements of the matrix.

§Returns

An iterator that yields references to the elements of the matrix.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut S>

Returns a mutable iterator over the elements of the matrix.

§Returns

An iterator that yields mutable references to the elements of the matrix.

Trait Implementations§

Source§

impl<S> Clone for Mat<S>
where S: Scalar + Clone,

Source§

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

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl<S> Debug for Mat<S>
where S: Scalar + Debug,

Source§

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

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

impl<S: Scalar> Index<(usize, usize)> for Mat<S>

Source§

type Output = S

The returned type after indexing.
Source§

fn index(&self, (row, col): (usize, usize)) -> &Self::Output

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

impl<S: Scalar> IndexMut<(usize, usize)> for Mat<S>

Source§

fn index_mut(&mut self, (row, col): (usize, usize)) -> &mut Self::Output

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

impl<S> IntoIterator for Mat<S>
where S: Scalar,

Source§

type Item = S

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<S>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<S> Matrix<S> for Mat<S>
where S: Scalar,

Source§

type VectorM = Vec<S>

Length-M Vector type implementing the crate::Vector trait that is compatible with this matrix type. An instance of this matrix type with shape (M, N) can be multiplied from the left by an instance of this vector type with length M, resulting in an instance of this vector type with length N (mathematically representing a row vector).
Source§

type VectorN = Vec<S>

Length-N Vector type implementing the crate::Vector trait that is compatible with this matrix type. An instance of this matrix type with shape (M, N) can be multiplied from the right by an instance of this vector type with length N, resulting in an instance of this vector type with length M (mathematically representing a column vector).
Source§

fn is_statically_sized() -> bool

Determine whether or not the matrix is statically-sized. Read more
Source§

fn is_dynamically_sized() -> bool

Determine whether or not the matrix is dynamically-sized. Read more
Source§

fn is_row_major() -> bool

Determine whether or not the matrix is row-major. Read more
Source§

fn is_column_major() -> bool

Determine whether or not the matrix is column-major. Read more
Source§

fn new_with_shape(rows: usize, cols: usize) -> Self

Create a matrix with the specified size, with each element set to 0. Read more
Source§

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

Get the shape of the matrix. Read more
Source§

fn from_row_slice(rows: usize, cols: usize, slice: &[S]) -> Self

Create a matrix from a slice of scalars arranged in row-major order. Read more
Source§

fn from_col_slice(rows: usize, cols: usize, slice: &[S]) -> Self

Create a matrix from a slice of scalars arranged in column-major order. Read more
Source§

fn as_slice<'a>(&'a self) -> Cow<'a, [S]>

Return a slice view of the matrix’s elements. Read more
Source§

fn add(&self, other: &Self) -> Self

Matrix addition (elementwise). Read more
Source§

fn add_assign(&mut self, other: &Self)

In-place matrix addition (elementwise) (self += other). Read more
Source§

fn sub(&self, other: &Self) -> Self

Matrix subtraction (elementwise). Read more
Source§

fn sub_assign(&mut self, other: &Self)

In-place matrix subtraction (elementwise) (self -= other). Read more
Source§

fn mul(&self, scalar: S) -> Self

Matrix-scalar multiplication. Read more
Source§

fn mul_assign(&mut self, scalar: S)

In-place matrix-scalar multiplication (self * scalar or scalar * self). Read more
Source§

fn div(&self, scalar: S) -> Self

Matrix-scalar division. Read more
Source§

fn div_assign(&mut self, scalar: S)

In-place matrix-scalar division (self / scalar). Read more
Source§

fn new_vector_n(&self) -> Self::VectorN

Create a length-N vector that is compatible with this M x N matrix. Read more
Source§

fn new_vector_m(&self) -> Self::VectorM

Create a length-M vector that is compatible with this M x N matrix. Read more
Source§

fn assert_same_shape(&self, other: &Self)

Assert that this matrix and another matrix have the same shape. Read more
Source§

fn as_row_slice<'a>(&'a self) -> Cow<'a, [S]>

Return a slice view of the matrix’s elements in row-major order. Read more
Source§

fn as_col_slice<'a>(&'a self) -> Cow<'a, [S]>

Return a slice view of the matrix’s elements in column-major order. Read more
Source§

impl<S> PartialEq for Mat<S>
where S: Scalar + PartialEq,

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> StructuralPartialEq for Mat<S>
where S: Scalar,

Auto Trait Implementations§

§

impl<S> Freeze for Mat<S>

§

impl<S> RefUnwindSafe for Mat<S>
where S: RefUnwindSafe,

§

impl<S> Send for Mat<S>
where S: Send,

§

impl<S> Sync for Mat<S>
where S: Sync,

§

impl<S> Unpin for Mat<S>
where S: Unpin,

§

impl<S> UnwindSafe for Mat<S>
where S: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

§

impl<T> CloneToUninit for T
where T: Clone,

§

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> DistributionExt for T
where T: ?Sized,

Source§

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

§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

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

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,