Struct com_croftsoft_core::math::matrix::structures::Matrix
source · [−]Expand description
A mathematical matrix structure
Fields
rows: [[f64; C]; R]
Implementations
sourceimpl<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
sourceimpl<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 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
sourceimpl<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>
sourcefn add_assign(&mut self, rhs: &Matrix<R, C>)
fn add_assign(&mut self, rhs: &Matrix<R, C>)
+=
operation. Read moresourceimpl<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>
sourcefn add_assign(&mut self, rhs: &Matrix<R, C>)
fn add_assign(&mut self, rhs: &Matrix<R, C>)
+=
operation. Read moresourceimpl<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>
sourcefn add_assign(&mut self, rhs: Matrix<R, C>)
fn add_assign(&mut self, rhs: Matrix<R, C>)
+=
operation. Read moresourceimpl<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>
sourcefn add_assign(&mut self, rhs: Matrix<R, C>)
fn add_assign(&mut self, rhs: Matrix<R, C>)
+=
operation. Read moresourceimpl<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>
sourcefn add_assign(&mut self, rhs: f64)
fn add_assign(&mut self, rhs: f64)
+=
operation. Read moresourceimpl<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>
sourcefn add_assign(&mut self, rhs: f64)
fn add_assign(&mut self, rhs: f64)
+=
operation. Read moresourceimpl<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>
sourcefn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
/=
operation. Read moresourceimpl<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>
sourcefn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
/=
operation. Read moresourceimpl<'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>
sourceimpl<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>
sourcefn mul_assign(&mut self, rhs: &Matrix<C, C>)
fn mul_assign(&mut self, rhs: &Matrix<C, C>)
*=
operation. Read moresourceimpl<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>
sourcefn mul_assign(&mut self, rhs: &Matrix<C, C>)
fn mul_assign(&mut self, rhs: &Matrix<C, C>)
*=
operation. Read moresourceimpl<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>
sourcefn mul_assign(&mut self, rhs: Matrix<C, C>)
fn mul_assign(&mut self, rhs: Matrix<C, C>)
*=
operation. Read moresourceimpl<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>
sourcefn mul_assign(&mut self, rhs: Matrix<C, C>)
fn mul_assign(&mut self, rhs: Matrix<C, C>)
*=
operation. Read moresourceimpl<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>
sourcefn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
*=
operation. Read moresourceimpl<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>
sourcefn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
*=
operation. Read moresourceimpl<const R: usize, const C: usize> PartialEq<Matrix<R, C>> for Matrix<R, C>
impl<const R: usize, const C: usize> PartialEq<Matrix<R, C>> for Matrix<R, C>
sourceimpl<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>
sourcefn sub_assign(&mut self, rhs: &Matrix<R, C>)
fn sub_assign(&mut self, rhs: &Matrix<R, C>)
-=
operation. Read moresourceimpl<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>
sourcefn sub_assign(&mut self, rhs: &Matrix<R, C>)
fn sub_assign(&mut self, rhs: &Matrix<R, C>)
-=
operation. Read moresourceimpl<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>
sourcefn sub_assign(&mut self, rhs: Matrix<R, C>)
fn sub_assign(&mut self, rhs: Matrix<R, C>)
-=
operation. Read moresourceimpl<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>
sourcefn sub_assign(&mut self, rhs: Matrix<R, C>)
fn sub_assign(&mut self, rhs: Matrix<R, C>)
-=
operation. Read moresourceimpl<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>
sourcefn sub_assign(&mut self, rhs: f64)
fn sub_assign(&mut self, rhs: f64)
-=
operation. Read moresourceimpl<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>
sourcefn sub_assign(&mut self, rhs: f64)
fn sub_assign(&mut self, rhs: f64)
-=
operation. Read more