[−][src]Struct matmath::matrix::Matrix
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]
T: Clone,
Generates a rows
xcols
matrix where every element is e
pub fn build<F: FnMut(usize, usize) -> T>(
rows: usize,
cols: usize,
builder_fn: F
) -> Self
[src]
rows: usize,
cols: usize,
builder_fn: F
) -> Self
Generates a rows
xcols
matrix where every element is obtained by evaluating builder_fn(row, col)
pub fn identity(rows: usize) -> Self where
T: MatrixElement,
[src]
T: MatrixElement,
Generates a rows
xrows
identity matrix (using MatrixElement::zero()
and MatrixElement::one()
)
pub fn from_vec(rows: usize, cols: usize, data: Vec<T>) -> Option<Self>
[src]
Generates a rows
xcols
matrix with the data specified in data
returns None
if data.len() != rows * cols
impl<T: Clone, '_> Matrix<&'_ T>
[src]
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]
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]
pub fn get_row(&self, row: usize) -> Result<Vec<&T>, IndexOutOfBounds<usize>>
[src]
pub fn get_row_mut(
&mut self,
row: usize
) -> Result<Vec<&mut T>, IndexOutOfBounds<usize>>
[src]
&mut self,
row: usize
) -> Result<Vec<&mut T>, IndexOutOfBounds<usize>>
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]
&mut self,
col: usize
) -> Result<Vec<&mut T>, IndexOutOfBounds<usize>>
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]
T: Add<Output = T> + Sub<Output = T> + MatrixElement + Clone + Mul<Output = T>,
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]
T: Trig<Output = O> + Clone,
O: Neg<Output = O> + Add<Output = O> + Mul<Output = O> + MatrixElement,
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]
T: Clone,
impl<T> From<Matrix<T>> for Vector4<T> where
T: Clone,
[src]
T: Clone,
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(&self) -> 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.
fn add(self, rhs: Matrix<U>) -> Matrix<O>
[src]
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.
fn sub(self, rhs: Matrix<U>) -> Matrix<O>
[src]
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]
T: Mul<U, Output = O> + Clone,
U: Clone,
O: Add<O, Output = O> + MatrixElement,
Matrix Multiplication
type Output = Matrix<O>
The resulting type after applying the *
operator.
fn mul(self, rhs: Matrix<U>) -> Matrix<O>
[src]
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]
T: Mul<U, Output = O> + Clone,
U: Clone,
O: Add<O, Output = O> + MatrixElement,
Matrix-Vector Multiplication
type Output = Vector<O>
The resulting type after applying the *
operator.
fn mul(self, rhs: Vector<U>) -> Vector<O>
[src]
impl<T, O> Neg for Matrix<T> where
T: Neg<Output = O>,
[src]
T: Neg<Output = O>,
type Output = Matrix<O>
The resulting type after applying the -
operator.
fn neg(self) -> Matrix<O>
[src]
impl<T> Index<(usize, usize)> for Matrix<T>
[src]
type Output = T
The returned type after indexing.
fn index(&self, (row, col): (usize, usize)) -> &T
[src]
impl<T> IndexMut<(usize, usize)> for Matrix<T>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
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>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,