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>
impl<const R: usize, const C: usize> Matrix<R, C>
Sourcepub fn add_matrix_with_matrix(augend: &Self, addend: &Self) -> Self
pub fn add_matrix_with_matrix(augend: &Self, addend: &Self) -> Self
Adds the arguments and return the sum as a new Matrix
Sourcepub fn add_matrix_with_scalar(augend: &Self, addend: f64) -> Self
pub fn add_matrix_with_scalar(augend: &Self, addend: f64) -> Self
Adds the arguments and then returns the sum as a new Matrix
Sourcepub fn divide_matrix_by_matrix_entrywise(
dividend_matrix: &Self,
divisor_matrix: &Self,
) -> Self
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
Sourcepub fn divide_matrix_by_scalar(dividend: &Self, divisor: f64) -> Self
pub fn divide_matrix_by_scalar(dividend: &Self, divisor: f64) -> Self
Divides each entry by the scalar and then returns a new Matrix
Sourcepub fn multiply_matrix_with_matrix<const K: usize>(
multiplicand: &Self,
multiplier: &Matrix<C, K>,
) -> Matrix<R, K>
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
Sourcepub fn multiply_matrix_with_matrix_entrywise(
original_matrix: &Self,
weighting_matrix: &Self,
) -> Self
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
pub fn multiply_matrix_with_scalar(multiplicand: &Self, multiplier: f64) -> Self
Sourcepub fn negate_matrix(matrix: &Self) -> Self
pub fn negate_matrix(matrix: &Self) -> Self
Multiplies all entries by -1.0 and then returns the new negated Matrix
Sourcepub fn subtract_matrix_from_matrix(minuend: &Self, subtrahend: &Self) -> Self
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
Sourcepub fn subtract_matrix_from_scalar(minuend: f64, subtrahend: &Self) -> Self
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
Sourcepub fn subtract_scalar_from_matrix(minuend: &Self, subtrahend: f64) -> Self
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 Matrix<3, 3>
impl Matrix<3, 3>
pub fn to_rotation_matrix_x_from_degrees(degrees: Degrees) -> Self
pub fn to_rotation_matrix_x_from_radians(radians: Radians) -> Self
pub fn to_rotation_matrix_y_from_degrees(degrees: Degrees) -> Self
pub fn to_rotation_matrix_y_from_radians(radians: Radians) -> Self
pub fn to_rotation_matrix_z_from_degrees(degrees: Degrees) -> Self
pub fn to_rotation_matrix_z_from_radians(radians: Radians) -> Self
Source§impl<const R: usize, const C: usize> Matrix<R, C>
impl<const R: usize, const C: usize> Matrix<R, C>
Sourcepub fn add_matrix(&mut self, addend: &Self) -> &mut Self
pub fn add_matrix(&mut self, addend: &Self) -> &mut Self
Adds the argument entries to all corresponding entries and returns self
Sourcepub fn add_scalar(&mut self, addend: f64) -> &mut Self
pub fn add_scalar(&mut self, addend: f64) -> &mut Self
Adds the scalar to all entries and then returns a reference to self
Sourcepub fn divide_by_matrix_entrywise(&mut self, divisor: &Self) -> &mut Self
pub fn divide_by_matrix_entrywise(&mut self, divisor: &Self) -> &mut Self
Divides corresponding entries and then returns a reference to self
Sourcepub fn divide_by_scalar(&mut self, divisor: f64) -> &mut Self
pub fn divide_by_scalar(&mut self, divisor: f64) -> &mut Self
Divides each entry by the argument and then returns a reference to self
Sourcepub fn get_entry(&self, indices: Indices) -> f64
pub fn get_entry(&self, indices: Indices) -> f64
Returns the entry at the position given by the indices
Sourcepub fn get_row(&self, row_index: usize) -> &[f64; C]
pub fn get_row(&self, row_index: usize) -> &[f64; C]
Returns a reference to a row of entries, indexed from zero
Sourcepub fn is_square(&self) -> bool
pub fn is_square(&self) -> bool
Returns true if the number of rows equals the number of columns
Sourcepub fn matches_closely(&self, other: &Self, tolerance: f64) -> bool
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.
Sourcepub fn matches_exactly(&self, other: &Self) -> bool
pub fn matches_exactly(&self, other: &Self) -> bool
Returns true if the other Matrix has the exact same entries
Sourcepub fn multiply_with_matrix(&mut self, multiplier: &Matrix<C, C>) -> &mut Self
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
Sourcepub fn multiply_with_matrix_entrywise(
&mut self,
weighting_matrix: &Self,
) -> &mut Self
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)
Sourcepub fn multiply_with_scalar(&mut self, multiplier: f64) -> &mut Self
pub fn multiply_with_scalar(&mut self, multiplier: f64) -> &mut Self
Multiplies all entries by the scalar and then returns a reference to self
Sourcepub fn negate(&mut self) -> &mut Self
pub fn negate(&mut self) -> &mut Self
Multiplies all entries by -1.0 and then returns a reference to self
Sourcepub fn set_entry(&mut self, indices: Indices, value: f64) -> &mut Self
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
Sourcepub fn submatrix<const P: usize, const K: usize>(
&self,
offset_indices: Indices,
) -> Matrix<P, K>
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
Sourcepub fn subtract_from_scalar(&mut self, minuend: f64) -> &mut Self
pub fn subtract_from_scalar(&mut self, minuend: f64) -> &mut Self
Subtracts all entries from the scalar and then returns a reference to self
Sourcepub fn subtract_matrix(&mut self, subtrahend: &Self) -> &mut Self
pub fn subtract_matrix(&mut self, subtrahend: &Self) -> &mut Self
Subtracts the argument entries from corresponding entries and returns self
Sourcepub fn subtract_scalar(&mut self, subtrahend: f64) -> &mut Self
pub fn subtract_scalar(&mut self, subtrahend: f64) -> &mut Self
Subtracts the scalar from all entries and then returns a reference to self
Sourcepub fn sum_entries(&self) -> f64
pub fn sum_entries(&self) -> f64
Calculates the sum of all of the entries in the Matrix
Trait Implementations§
Source§impl<const R: usize, const C: usize> AddAssign<&Matrix<R, C>> for &mut Matrix<R, C>
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>)
fn add_assign(&mut self, rhs: &Matrix<R, C>)
+=
operation. Read moreSource§impl<const R: usize, const C: usize> AddAssign<&Matrix<R, C>> for Matrix<R, C>
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>)
fn add_assign(&mut self, rhs: &Matrix<R, C>)
+=
operation. Read moreSource§impl<const R: usize, const C: usize> AddAssign<Matrix<R, C>> for &mut Matrix<R, C>
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>)
fn add_assign(&mut self, rhs: Matrix<R, C>)
+=
operation. Read moreSource§impl<const R: usize, const C: usize> AddAssign<f64> for &mut Matrix<R, C>
impl<const R: usize, const C: usize> AddAssign<f64> for &mut Matrix<R, C>
Source§fn add_assign(&mut self, rhs: f64)
fn add_assign(&mut self, rhs: f64)
+=
operation. Read moreSource§impl<const R: usize, const C: usize> AddAssign<f64> for Matrix<R, C>
impl<const R: usize, const C: usize> AddAssign<f64> for Matrix<R, C>
Source§fn add_assign(&mut self, rhs: f64)
fn add_assign(&mut self, rhs: f64)
+=
operation. Read moreSource§impl<const R: usize, const C: usize> AddAssign for Matrix<R, C>
impl<const R: usize, const C: usize> AddAssign for Matrix<R, C>
Source§fn add_assign(&mut self, rhs: Matrix<R, C>)
fn add_assign(&mut self, rhs: Matrix<R, C>)
+=
operation. Read moreSource§impl<const R: usize, const C: usize> DivAssign<f64> for &mut Matrix<R, C>
impl<const R: usize, const C: usize> DivAssign<f64> for &mut Matrix<R, C>
Source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
/=
operation. Read moreSource§impl<const R: usize, const C: usize> DivAssign<f64> for Matrix<R, C>
impl<const R: usize, const C: usize> DivAssign<f64> for Matrix<R, C>
Source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
/=
operation. Read moreSource§impl From<Matrix<3, 3>> for RotationDegrees
impl From<Matrix<3, 3>> for RotationDegrees
Source§impl From<Matrix<3, 3>> for RotationRadians
impl From<Matrix<3, 3>> for RotationRadians
Source§impl From<RotationDegrees> for Matrix<3, 3>
impl From<RotationDegrees> for Matrix<3, 3>
Source§fn from(rotation_degrees: RotationDegrees) -> Self
fn from(rotation_degrees: RotationDegrees) -> Self
Source§impl From<RotationRadians> for Matrix<3, 3>
impl From<RotationRadians> for Matrix<3, 3>
Source§fn from(rotation_radians: RotationRadians) -> Self
fn from(rotation_radians: RotationRadians) -> Self
Source§impl<'a, 'b, const R: usize, const C: usize, const K: usize> Mul<&'b Matrix<C, K>> for &'a Matrix<R, C>
impl<'a, 'b, const R: usize, const C: usize, const K: usize> Mul<&'b Matrix<C, K>> for &'a Matrix<R, C>
Source§impl<const R: usize, const C: usize> MulAssign<&Matrix<C, C>> for &mut Matrix<R, C>
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>)
fn mul_assign(&mut self, rhs: &Matrix<C, C>)
*=
operation. Read moreSource§impl<const R: usize, const C: usize> MulAssign<&Matrix<C, C>> for Matrix<R, C>
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>)
fn mul_assign(&mut self, rhs: &Matrix<C, C>)
*=
operation. Read moreSource§impl<const R: usize, const C: usize> MulAssign<Matrix<C, C>> for &mut Matrix<R, C>
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>)
fn mul_assign(&mut self, rhs: Matrix<C, C>)
*=
operation. Read moreSource§impl<const R: usize, const C: usize> MulAssign<Matrix<C, C>> for Matrix<R, C>
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>)
fn mul_assign(&mut self, rhs: Matrix<C, C>)
*=
operation. Read moreSource§impl<const R: usize, const C: usize> MulAssign<f64> for &mut Matrix<R, C>
impl<const R: usize, const C: usize> MulAssign<f64> for &mut Matrix<R, C>
Source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
*=
operation. Read moreSource§impl<const R: usize, const C: usize> MulAssign<f64> for Matrix<R, C>
impl<const R: usize, const C: usize> MulAssign<f64> for Matrix<R, C>
Source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
*=
operation. Read moreSource§impl<const R: usize, const C: usize> SubAssign<&Matrix<R, C>> for &mut Matrix<R, C>
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>)
fn sub_assign(&mut self, rhs: &Matrix<R, C>)
-=
operation. Read moreSource§impl<const R: usize, const C: usize> SubAssign<&Matrix<R, C>> for Matrix<R, C>
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>)
fn sub_assign(&mut self, rhs: &Matrix<R, C>)
-=
operation. Read moreSource§impl<const R: usize, const C: usize> SubAssign<Matrix<R, C>> for &mut Matrix<R, C>
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>)
fn sub_assign(&mut self, rhs: Matrix<R, C>)
-=
operation. Read moreSource§impl<const R: usize, const C: usize> SubAssign<f64> for &mut Matrix<R, C>
impl<const R: usize, const C: usize> SubAssign<f64> for &mut Matrix<R, C>
Source§fn sub_assign(&mut self, rhs: f64)
fn sub_assign(&mut self, rhs: f64)
-=
operation. Read moreSource§impl<const R: usize, const C: usize> SubAssign<f64> for Matrix<R, C>
impl<const R: usize, const C: usize> SubAssign<f64> for Matrix<R, C>
Source§fn sub_assign(&mut self, rhs: f64)
fn sub_assign(&mut self, rhs: f64)
-=
operation. Read moreSource§impl<const R: usize, const C: usize> SubAssign for Matrix<R, C>
impl<const R: usize, const C: usize> SubAssign for Matrix<R, C>
Source§fn sub_assign(&mut self, rhs: Matrix<R, C>)
fn sub_assign(&mut self, rhs: Matrix<R, C>)
-=
operation. Read more