[][src]Struct matmath::matrix::Matrix

pub struct Matrix<T> { /* fields omitted */ }

A Matrix with generic type items. Can be indexed by mat[(row, col)]

Methods

impl<T> Matrix<T>[src]

pub fn fill(rows: usize, cols: usize, e: T) -> Self where
    T: Clone
[src]

Generates a rowsxcols matrix where every element is e

pub fn build<F: FnMut(usize, usize) -> T>(
    rows: usize,
    cols: usize,
    builder_fn: F
) -> Self
[src]

Generates a rowsxcols matrix where every element is obtained by evaluating builder_fn(row, col)

pub fn identity(rows: usize) -> Self where
    T: MatrixElement
[src]

Generates a rowsxrows identity matrix (using MatrixElement::zero() and MatrixElement::one())

pub fn from_vec(rows: usize, cols: usize, data: Vec<T>) -> Option<Self>[src]

Generates a rowsxcols matrix with the data specified in data

returns None if data.len() != rows * cols

impl<T: Clone, '_> Matrix<&'_ T>[src]

pub fn cloned(&self) -> Matrix<T>[src]

Clones the elements of a Matrix<&T> and returns a Matrix<T>

impl<T> Matrix<T>[src]

pub fn rows(&self) -> usize[src]

returns the number of rows (the 'height') of the matrix

pub fn cols(&self) -> usize[src]

returns the number of columns (the 'width') of the matrix

pub fn dim(&self) -> (usize, usize)[src]

returns the number of rows and the number of columns of the matrix (in that order)

pub fn elements(&self) -> usize[src]

returns the total number of elements in the matrix

pub fn split(self) -> (usize, usize, Vec<T>)[src]

splits the struct up into its parts, that is into (rows, columns, data)

pub fn into_some(self) -> Matrix<Option<T>>[src]

Converts a Matrix<T> to a Matrix<Option<T>> by mapping every element e to Some(e)

pub fn get(&self, row: usize, col: usize) -> IndexResult<&T>[src]

get a reference to the item at (row, col)

Errors

Returns an error if the index is out of bounds

pub fn get_mut(&mut self, row: usize, col: usize) -> IndexResult<&mut T>[src]

get a mutable reference to the item at (row, col)

Errors

Returns an error if the index is out of bounds

pub fn replace(&mut self, row: usize, col: usize, val: T) -> IndexResult<T>[src]

get a the item at (row, col) and replace it with val

This works like {let res = self.get(row, col); self.set(row, col, val); res} but you get ownership of the returned value

Errors

Returns an error if the index is out of bounds

pub fn set(&mut self, row: usize, col: usize, val: T) -> IndexResult<()>[src]

set the item at (row, col) to val

Errors

Returns an error if the index is out of bounds

pub fn get_row(&self, row: usize) -> Result<Vec<&T>, IndexOutOfBounds<usize>>[src]

get an entire row of (references of) items

Errors

Returns an error if the row is out of bounds

pub fn get_row_mut(
    &mut self,
    row: usize
) -> Result<Vec<&mut T>, IndexOutOfBounds<usize>>
[src]

get an entire row of (mutable references of) items

Errors

Returns an error if the row is out of bounds

pub fn get_col(&self, col: usize) -> Result<Vec<&T>, IndexOutOfBounds<usize>>[src]

get an entire column of (references of) items

Errors

Returns an error if the column is out of bounds

pub fn get_col_mut(
    &mut self,
    col: usize
) -> Result<Vec<&mut T>, IndexOutOfBounds<usize>>
[src]

get an entire column of (mutable references of) items

Errors

Returns an error if the column is out of bounds

pub fn map<F: Fn(T) -> U, U>(self, f: F) -> Matrix<U>[src]

Returns a new Matrix that is obtained by applying the given function to each element

pub fn transposed(self) -> Self[src]

Returns the Transpose of this Matrix

pub fn det(self) -> Option<T> where
    T: Add<Output = T> + Sub<Output = T> + MatrixElement + Clone + Mul<Output = T>, 
[src]

Returns the Determinant of this Matrix

pub fn scaled<U: Mul<T, Output = O> + Clone, O>(self, scalar: U) -> Matrix<O>[src]

Multiplies the matrix with a scalar by multiplying each element with the scalar

impl<T> Matrix<Option<T>>[src]

pub fn take(&mut self, row: usize, col: usize) -> IndexResult<Option<T>>[src]

return the value at (row, col), leaving None in its place

impl Matrix<RotmatElement>[src]

pub fn insert_rotation_value<T, O>(self, value: T) -> Matrix<O> where
    T: Trig<Output = O> + Clone,
    O: Neg<Output = O> + Add<Output = O> + Mul<Output = O> + MatrixElement
[src]

Takes a previously generated Rotation Matrix and inserts a specific value into it For f32 and f64, this would be the angle in radians, but for your own type it could be whatever... (it uses the Trig and the MatrixElement traits to get values for sin, -sin, cos, 0 and 1)

Trait Implementations

impl<T> Into<Matrix<T>> for Vector2<T>[src]

A Vector can be cast to a matrix and back

impl<T> Into<Matrix<T>> for Vector3<T>[src]

impl<T> Into<Matrix<T>> for Vector4<T>[src]

impl<T> Into<Matrix<T>> for Vector<T>[src]

A Vector can be cast to a matrix and back

impl<T: Eq> Eq for Matrix<T>[src]

impl<T: PartialEq> PartialEq<Matrix<T>> for Matrix<T>[src]

impl<T> From<Matrix<T>> for Vector2<T>[src]

A Vector can be cast to a matrix and back

impl<T> From<Matrix<T>> for Vector3<T> where
    T: Clone
[src]

impl<T> From<Matrix<T>> for Vector4<T> where
    T: Clone
[src]

impl<T> From<Matrix<T>> for Vector<T>[src]

A Vector can be converted to a matrix and back

impl<T: Clone> Clone for Matrix<T>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: Display> Display for Matrix<T>[src]

impl<T: Debug> Debug for Matrix<T>[src]

impl<T: Add<U, Output = O>, U, O> Add<Matrix<U>> for Matrix<T>[src]

Adds two matrices element by element

type Output = Matrix<O>

The resulting type after applying the + operator.

impl<T: Clone + Sub<U, Output = O>, U, O> Sub<Matrix<U>> for Matrix<T>[src]

Subtracts two matrices element by element

type Output = Matrix<O>

The resulting type after applying the - operator.

impl<T, U, O> Mul<Matrix<U>> for Matrix<T> where
    T: Mul<U, Output = O> + Clone,
    U: Clone,
    O: Add<O, Output = O> + MatrixElement
[src]

Matrix Multiplication

type Output = Matrix<O>

The resulting type after applying the * operator.

impl<T, U, O> Mul<Vector<U>> for Matrix<T> where
    T: Mul<U, Output = O> + Clone,
    U: Clone,
    O: Add<O, Output = O> + MatrixElement
[src]

Matrix-Vector Multiplication

type Output = Vector<O>

The resulting type after applying the * operator.

impl<T, O> Neg for Matrix<T> where
    T: Neg<Output = O>, 
[src]

type Output = Matrix<O>

The resulting type after applying the - operator.

impl<T> Index<(usize, usize)> for Matrix<T>[src]

type Output = T

The returned type after indexing.

impl<T> IndexMut<(usize, usize)> for Matrix<T>[src]

Auto Trait Implementations

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

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

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.