Skip to main content

Matrix

Struct Matrix 

Source
pub struct Matrix<T> { /* private fields */ }

Implementations§

Source§

impl<T> Matrix<T>

Source

pub fn new(data: impl Into<Vec<T>>) -> Self

Source

pub fn empty() -> Self

Source

pub fn from_rows<I>(rows: I) -> Self
where I: IntoIterator<Item = Vec<T>>,

Source

pub fn rows(&self) -> usize

Source

pub fn cols(&self) -> usize

Source

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

Source

pub fn is_empty(&self) -> bool

Source

pub fn size(&self) -> usize

Source

pub fn clear(&mut self)

Source

pub fn iter(&self) -> impl Iterator<Item = &[T]>

Source

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

Source

pub fn row_mut(&mut self, row: usize) -> &mut [T]

Source

pub fn append_row(&mut self, row_data: Vec<T>)

Source

pub fn reshape(self, new_rows: usize, new_cols: usize) -> Self

Source

pub fn reshape_in_place(&mut self, new_rows: usize, new_cols: usize)

Source§

impl<T: Clone> Matrix<T>

Source

pub fn append_column(&mut self, col_data: Vec<T>)

Source

pub fn reshape_and_fill(&mut self, rows: usize, cols: usize, default_value: T)

Source

pub fn sort_by_indices(&self, indices: &[usize]) -> Self

Source

pub fn split_at_row(&self, row: usize) -> (Self, Self)

Source

pub fn fill(&mut self, value: T)

Source

pub fn transpose(&self) -> Self

Source§

impl<T: Float> Matrix<T>

Source

pub fn standardize(&mut self)

Source

pub fn normalize(&mut self)

Trait Implementations§

Source§

impl<T> AsRef<[T]> for Matrix<T>

Source§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone> Clone for Matrix<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: Debug> Debug for Matrix<T>

Source§

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

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

impl<T: Default> Default for Matrix<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Default + Clone> From<(usize, usize)> for Matrix<T>

Source§

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

Converts to this type from the input type.
Source§

impl<T> From<(usize, usize, Vec<T>)> for Matrix<T>

Source§

fn from((rows, cols, data): (usize, usize, Vec<T>)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vec<T>> for Matrix<T>

Source§

fn from(vec: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Vec<Vec<T>>> for Matrix<T>

Source§

fn from(vec_of_vecs: Vec<Vec<T>>) -> Self

Converts to this type from the input type.
Source§

impl<T> FromIterator<Vec<T>> for Matrix<T>

Source§

fn from_iter<I: IntoIterator<Item = Vec<T>>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T> Index<(usize, usize)> for Matrix<T>

Source§

type Output = T

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<T> Index<[usize; 2]> for Matrix<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: [usize; 2]) -> &Self::Output

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

impl<T> Index<usize> for Matrix<T>

Source§

type Output = [T]

The returned type after indexing.
Source§

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

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

impl<T> IndexMut<(usize, usize)> for Matrix<T>

Source§

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

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

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

Source§

fn index_mut(&mut self, index: [usize; 2]) -> &mut Self::Output

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

impl<T> IndexMut<usize> for Matrix<T>

Source§

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

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

impl<T: PartialEq> PartialEq for Matrix<T>

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

Auto Trait Implementations§

§

impl<T> Freeze for Matrix<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for Matrix<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for Matrix<T>
where Vec<T>: Send,

§

impl<T> Sync for Matrix<T>
where Vec<T>: Sync,

§

impl<T> Unpin for Matrix<T>
where Vec<T>: Unpin,

§

impl<T> UnsafeUnpin for Matrix<T>
where Vec<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Matrix<T>
where Vec<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
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> 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.