Struct Matrix

Source
pub struct Matrix<const R: usize, const C: usize> {
    pub rows: [[f64; C]; R],
}
Expand description

A mathematical matrix structure

Fields§

§rows: [[f64; C]; R]

Implementations§

Source§

impl<const R: usize, const C: usize> Matrix<R, C>

Source

pub fn add_matrix_with_matrix(augend: &Self, addend: &Self) -> Self

Adds the arguments and return the sum as a new Matrix

Source

pub fn add_matrix_with_scalar(augend: &Self, addend: f64) -> Self

Adds the arguments and then returns the sum as a new Matrix

Source

pub fn divide_matrix_by_matrix_entrywise( dividend_matrix: &Self, divisor_matrix: &Self, ) -> Self

Divides corresponding entries and returns the quotient as a new Matrix

Source

pub fn divide_matrix_by_scalar(dividend: &Self, divisor: f64) -> Self

Divides each entry by the scalar and then returns a new Matrix

Source

pub fn multiply_matrix_with_matrix<const K: usize>( multiplicand: &Self, multiplier: &Matrix<C, K>, ) -> Matrix<R, K>

Multiplies the arguments and then returns the product as a new Matrix

Source

pub fn multiply_matrix_with_matrix_entrywise( original_matrix: &Self, weighting_matrix: &Self, ) -> Self

Multiplies entries and returns the Hadamard product as a new Matrix

https://en.wikipedia.org/wiki/Hadamard_product_(matrices)

Source

pub fn multiply_matrix_with_scalar(multiplicand: &Self, multiplier: f64) -> Self

Source

pub fn negate_matrix(matrix: &Self) -> Self

Multiplies all entries by -1.0 and then returns the new negated Matrix

Source

pub fn new(value: f64) -> Self

Makes a new Matrix with all entries set to the argument

Source

pub fn subtract_matrix_from_matrix(minuend: &Self, subtrahend: &Self) -> Self

Subtracts the 2nd from the 1st and returns the difference as a new Matrix

Source

pub fn subtract_matrix_from_scalar(minuend: f64, subtrahend: &Self) -> Self

Subtracts the 2nd from the 1st and returns the difference as a new Matrix

Source

pub fn subtract_scalar_from_matrix(minuend: &Self, subtrahend: f64) -> Self

Subtracts the 2nd from the 1st and returns the difference as a new Matrix

Source§

impl<const R: usize> Matrix<R, R>

Source

pub fn identity() -> Self

Makes a square matrix with the diagonal values set to 1.0 and all others 0

Source§

impl Matrix<3, 3>

Source§

impl<const R: usize, const C: usize> Matrix<R, C>

Source

pub fn add_matrix(&mut self, addend: &Self) -> &mut Self

Adds the argument entries to all corresponding entries and returns self

Source

pub fn add_scalar(&mut self, addend: f64) -> &mut Self

Adds the scalar to all entries and then returns a reference to self

Source

pub fn divide_by_matrix_entrywise(&mut self, divisor: &Self) -> &mut Self

Divides corresponding entries and then returns a reference to self

Source

pub fn divide_by_scalar(&mut self, divisor: f64) -> &mut Self

Divides each entry by the argument and then returns a reference to self

Source

pub fn get_entry(&self, indices: Indices) -> f64

Returns the entry at the position given by the indices

Source

pub fn get_row(&self, row_index: usize) -> &[f64; C]

Returns a reference to a row of entries, indexed from zero

Source

pub fn is_square(&self) -> bool

Returns true if the number of rows equals the number of columns

Source

pub fn matches_closely(&self, other: &Self, tolerance: f64) -> bool

Returns false if any difference magnitude is greater than the tolerance.

The tolerance should be a positive number.

Source

pub fn matches_exactly(&self, other: &Self) -> bool

Returns true if the other Matrix has the exact same entries

Source

pub fn multiply_with_matrix(&mut self, multiplier: &Matrix<C, C>) -> &mut Self

Multiplies with a square matrix and then returns a reference to self

Source

pub fn multiply_with_matrix_entrywise( &mut self, weighting_matrix: &Self, ) -> &mut Self

Multiplies corresponding entries and then returns a reference to self

This result is known as the Hadamard Product:
https://en.wikipedia.org/wiki/Hadamard_product_(matrices)

Source

pub fn multiply_with_scalar(&mut self, multiplier: f64) -> &mut Self

Multiplies all entries by the scalar and then returns a reference to self

Source

pub fn negate(&mut self) -> &mut Self

Multiplies all entries by -1.0 and then returns a reference to self

Source

pub fn set_entry(&mut self, indices: Indices, value: f64) -> &mut Self

Sets the entry at the position given by the indices and then returns self

Source

pub fn submatrix<const P: usize, const K: usize>( &self, offset_indices: Indices, ) -> Matrix<P, K>

Returns a new Matrix that is a submatrix of self

Source

pub fn subtract_from_scalar(&mut self, minuend: f64) -> &mut Self

Subtracts all entries from the scalar and then returns a reference to self

Source

pub fn subtract_matrix(&mut self, subtrahend: &Self) -> &mut Self

Subtracts the argument entries from corresponding entries and returns self

Source

pub fn subtract_scalar(&mut self, subtrahend: f64) -> &mut Self

Subtracts the scalar from all entries and then returns a reference to self

Source

pub fn sum_entries(&self) -> f64

Calculates the sum of all of the entries in the Matrix

Source

pub fn transpose(&self) -> Matrix<C, R>

Returns a new Matrix with the rows and columns switched.

Trait Implementations§

Source§

impl<'a, 'b, const R: usize, const C: usize> Add<&'b Matrix<R, C>> for &'a Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b Matrix<R, C>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const R: usize, const C: usize> Add<&Matrix<R, C>> for Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Matrix<R, C>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const R: usize, const C: usize> Add<&Matrix<R, C>> for f64

Source§

type Output = Matrix<R, C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Matrix<R, C>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const R: usize, const C: usize> Add<Matrix<R, C>> for &Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Matrix<R, C>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const R: usize, const C: usize> Add<Matrix<R, C>> for f64

Source§

type Output = Matrix<R, C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Matrix<R, C>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const R: usize, const C: usize> Add<f64> for &Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl<const R: usize, const C: usize> Add<f64> for Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl<const R: usize, const C: usize> Add for Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Matrix<R, C>) -> Self::Output

Performs the + operation. Read more
Source§

impl<const R: usize, const C: usize> AddAssign<&Matrix<R, C>> for &mut Matrix<R, C>

Source§

fn add_assign(&mut self, rhs: &Matrix<R, C>)

Performs the += operation. Read more
Source§

impl<const R: usize, const C: usize> AddAssign<&Matrix<R, C>> for Matrix<R, C>

Source§

fn add_assign(&mut self, rhs: &Matrix<R, C>)

Performs the += operation. Read more
Source§

impl<const R: usize, const C: usize> AddAssign<Matrix<R, C>> for &mut Matrix<R, C>

Source§

fn add_assign(&mut self, rhs: Matrix<R, C>)

Performs the += operation. Read more
Source§

impl<const R: usize, const C: usize> AddAssign<f64> for &mut Matrix<R, C>

Source§

fn add_assign(&mut self, rhs: f64)

Performs the += operation. Read more
Source§

impl<const R: usize, const C: usize> AddAssign<f64> for Matrix<R, C>

Source§

fn add_assign(&mut self, rhs: f64)

Performs the += operation. Read more
Source§

impl<const R: usize, const C: usize> AddAssign for Matrix<R, C>

Source§

fn add_assign(&mut self, rhs: Matrix<R, C>)

Performs the += operation. Read more
Source§

impl<const R: usize, const C: usize> Clone for Matrix<R, C>

Source§

fn clone(&self) -> Matrix<R, C>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const R: usize, const C: usize> Debug for Matrix<R, C>

Source§

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

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

impl<const R: usize, const C: usize> Default for Matrix<R, C>

Source§

fn default() -> Self

Makes a new Matrix of all zero entries

Source§

impl<const R: usize, const C: usize> Div<f64> for &Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl<const R: usize, const C: usize> Div<f64> for Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl<const R: usize, const C: usize> DivAssign<f64> for &mut Matrix<R, C>

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl<const R: usize, const C: usize> DivAssign<f64> for Matrix<R, C>

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl From<AxisAngle> for Matrix<3, 3>

Source§

fn from(axis_angle: AxisAngle) -> Self

Converts to this type from the input type.
Source§

impl From<Matrix<3, 3>> for RotationDegrees

Source§

fn from(rotation_matrix: Matrix<3, 3>) -> Self

Converts to this type from the input type.
Source§

impl From<Matrix<3, 3>> for RotationRadians

Source§

fn from(rotation_matrix: Matrix<3, 3>) -> Self

Converts to this type from the input type.
Source§

impl From<RotationDegrees> for Matrix<3, 3>

Source§

fn from(rotation_degrees: RotationDegrees) -> Self

Converts to this type from the input type.
Source§

impl From<RotationRadians> for Matrix<3, 3>

Source§

fn from(rotation_radians: RotationRadians) -> Self

Converts to this type from the input type.
Source§

impl<'a, 'b, const R: usize, const C: usize, const K: usize> Mul<&'b Matrix<C, K>> for &'a Matrix<R, C>

Source§

type Output = Matrix<R, K>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Matrix<C, K>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const R: usize, const C: usize, const K: usize> Mul<&Matrix<C, K>> for Matrix<R, C>

Source§

type Output = Matrix<R, K>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Matrix<C, K>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const R: usize, const C: usize> Mul<&Matrix<R, C>> for f64

Source§

type Output = Matrix<R, C>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Matrix<R, C>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const R: usize, const C: usize, const K: usize> Mul<Matrix<C, K>> for &Matrix<R, C>

Source§

type Output = Matrix<R, K>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Matrix<C, K>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const R: usize, const C: usize, const K: usize> Mul<Matrix<C, K>> for Matrix<R, C>

Source§

type Output = Matrix<R, K>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Matrix<C, K>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const R: usize, const C: usize> Mul<Matrix<R, C>> for f64

Source§

type Output = Matrix<R, C>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Matrix<R, C>) -> Self::Output

Performs the * operation. Read more
Source§

impl<const R: usize, const C: usize> Mul<f64> for &Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl<const R: usize, const C: usize> Mul<f64> for Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl<const R: usize, const C: usize> MulAssign<&Matrix<C, C>> for &mut Matrix<R, C>

Source§

fn mul_assign(&mut self, rhs: &Matrix<C, C>)

Performs the *= operation. Read more
Source§

impl<const R: usize, const C: usize> MulAssign<&Matrix<C, C>> for Matrix<R, C>

Source§

fn mul_assign(&mut self, rhs: &Matrix<C, C>)

Performs the *= operation. Read more
Source§

impl<const R: usize, const C: usize> MulAssign<Matrix<C, C>> for &mut Matrix<R, C>

Source§

fn mul_assign(&mut self, rhs: Matrix<C, C>)

Performs the *= operation. Read more
Source§

impl<const R: usize, const C: usize> MulAssign<Matrix<C, C>> for Matrix<R, C>

Source§

fn mul_assign(&mut self, rhs: Matrix<C, C>)

Performs the *= operation. Read more
Source§

impl<const R: usize, const C: usize> MulAssign<f64> for &mut Matrix<R, C>

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl<const R: usize, const C: usize> MulAssign<f64> for Matrix<R, C>

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl<const R: usize, const C: usize> Neg for &Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<const R: usize, const C: usize> Neg for Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<const R: usize, const C: usize> PartialEq for Matrix<R, C>

Source§

fn eq(&self, other: &Matrix<R, C>) -> bool

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

const 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<'a, 'b, const R: usize, const C: usize> Sub<&'b Matrix<R, C>> for &'a Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b Matrix<R, C>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const R: usize, const C: usize> Sub<&Matrix<R, C>> for Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Matrix<R, C>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const R: usize, const C: usize> Sub<&Matrix<R, C>> for f64

Source§

type Output = Matrix<R, C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Matrix<R, C>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const R: usize, const C: usize> Sub<Matrix<R, C>> for &Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Matrix<R, C>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const R: usize, const C: usize> Sub<Matrix<R, C>> for f64

Source§

type Output = Matrix<R, C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Matrix<R, C>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const R: usize, const C: usize> Sub<f64> for &Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Self::Output

Performs the - operation. Read more
Source§

impl<const R: usize, const C: usize> Sub<f64> for Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Self::Output

Performs the - operation. Read more
Source§

impl<const R: usize, const C: usize> Sub for Matrix<R, C>

Source§

type Output = Matrix<R, C>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Matrix<R, C>) -> Self::Output

Performs the - operation. Read more
Source§

impl<const R: usize, const C: usize> SubAssign<&Matrix<R, C>> for &mut Matrix<R, C>

Source§

fn sub_assign(&mut self, rhs: &Matrix<R, C>)

Performs the -= operation. Read more
Source§

impl<const R: usize, const C: usize> SubAssign<&Matrix<R, C>> for Matrix<R, C>

Source§

fn sub_assign(&mut self, rhs: &Matrix<R, C>)

Performs the -= operation. Read more
Source§

impl<const R: usize, const C: usize> SubAssign<Matrix<R, C>> for &mut Matrix<R, C>

Source§

fn sub_assign(&mut self, rhs: Matrix<R, C>)

Performs the -= operation. Read more
Source§

impl<const R: usize, const C: usize> SubAssign<f64> for &mut Matrix<R, C>

Source§

fn sub_assign(&mut self, rhs: f64)

Performs the -= operation. Read more
Source§

impl<const R: usize, const C: usize> SubAssign<f64> for Matrix<R, C>

Source§

fn sub_assign(&mut self, rhs: f64)

Performs the -= operation. Read more
Source§

impl<const R: usize, const C: usize> SubAssign for Matrix<R, C>

Source§

fn sub_assign(&mut self, rhs: Matrix<R, C>)

Performs the -= operation. Read more
Source§

impl<const R: usize, const C: usize> StructuralPartialEq for Matrix<R, C>

Auto Trait Implementations§

§

impl<const R: usize, const C: usize> Freeze for Matrix<R, C>

§

impl<const R: usize, const C: usize> RefUnwindSafe for Matrix<R, C>

§

impl<const R: usize, const C: usize> Send for Matrix<R, C>

§

impl<const R: usize, const C: usize> Sync for Matrix<R, C>

§

impl<const R: usize, const C: usize> Unpin for Matrix<R, C>

§

impl<const R: usize, const C: usize> UnwindSafe for Matrix<R, C>

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