pub struct MatrixU32 { /* private fields */ }
Implementations
sourceimpl MatrixU32
impl MatrixU32
sourcepub fn new(n1: usize, n2: usize) -> Option<MatrixU32>
pub fn new(n1: usize, n2: usize) -> Option<MatrixU32>
Creates a new MatrixU32 with all elements set to zero
sourcepub fn get(&self, y: usize, x: usize) -> u32
pub fn get(&self, y: usize, x: usize) -> u32
This function returns the (i,j)-th element of the matrix. If y or x lie outside the allowed range of 0 to n1-1 and 0 to n2-1 then the error handler is invoked and 0 is returned.
sourcepub fn set(&mut self, y: usize, x: usize, value: u32) -> &MatrixU32
pub fn set(&mut self, y: usize, x: usize, value: u32) -> &MatrixU32
This function sets the value of the (i,j)-th element of the matrix to value. If y or x lies outside the allowed range of 0 to n1-1 and 0 to n2-1 then the error handler is invoked.
sourcepub fn set_all(&mut self, x: u32) -> &MatrixU32
pub fn set_all(&mut self, x: u32) -> &MatrixU32
This function sets all the elements of the matrix to the value x.
sourcepub fn set_zero(&mut self) -> &MatrixU32
pub fn set_zero(&mut self) -> &MatrixU32
This function sets all the elements of the matrix to zero.
sourcepub fn set_identity(&mut self) -> &MatrixU32
pub fn set_identity(&mut self) -> &MatrixU32
This function sets the elements of the matrix to the corresponding elements of the identity matrix, m(i,j) = \delta(i,j), i.e. a unit diagonal with all off-diagonal elements zero. This applies to both square and rectangular matrices.
sourcepub fn copy_from(&mut self, other: &MatrixU32) -> Value
pub fn copy_from(&mut self, other: &MatrixU32) -> Value
This function copies the elements of the other matrix into the self matrix. The two matrices must have the same size.
sourcepub fn copy_to(&self, other: &mut MatrixU32) -> Value
pub fn copy_to(&self, other: &mut MatrixU32) -> Value
This function copies the elements of the self matrix into the other matrix. The two matrices must have the same size.
sourcepub fn swap(&mut self, other: &mut MatrixU32) -> Value
pub fn swap(&mut self, other: &mut MatrixU32) -> Value
This function exchanges the elements of the matrices self and other by copying. The two matrices must have the same size.
sourcepub fn get_row(&self, y: usize) -> Option<(Value, VectorU32)>
pub fn get_row(&self, y: usize) -> Option<(Value, VectorU32)>
This function copies the elements of the y-th row of the matrix into the returned vector.
sourcepub fn get_col(&self, x: usize) -> Option<(Value, VectorU32)>
pub fn get_col(&self, x: usize) -> Option<(Value, VectorU32)>
This function copies the elements of the x-th column of the matrix into the returned vector.
sourcepub fn set_row(&mut self, y: usize, v: &VectorU32) -> Value
pub fn set_row(&mut self, y: usize, v: &VectorU32) -> Value
This function copies the elements of the vector v into the y-th row of the matrix. The length of the vector must be the same as the length of the row.
sourcepub fn set_col(&mut self, x: usize, v: &VectorU32) -> Value
pub fn set_col(&mut self, x: usize, v: &VectorU32) -> Value
This function copies the elements of the vector v into the x-th column of the matrix. The length of the vector must be the same as the length of the column.
sourcepub fn swap_rows(&mut self, y1: usize, y2: usize) -> Value
pub fn swap_rows(&mut self, y1: usize, y2: usize) -> Value
This function exchanges the y1-th and y2-th rows of the matrix in-place.
sourcepub fn swap_columns(&mut self, x1: usize, x2: usize) -> Value
pub fn swap_columns(&mut self, x1: usize, x2: usize) -> Value
This function exchanges the x1-th and x2-th columns of the matrix in-place.
sourcepub fn swap_row_col(&mut self, i: usize, j: usize) -> Value
pub fn swap_row_col(&mut self, i: usize, j: usize) -> Value
This function exchanges the i-th row and j-th column of the matrix in-place. The matrix must be square for this operation to be possible.
sourcepub fn transpose_memcpy(&self) -> Option<(Value, MatrixU32)>
pub fn transpose_memcpy(&self) -> Option<(Value, MatrixU32)>
This function returns the transpose of the matrix by copying the elements into it. This function works for all matrices provided that the dimensions of the matrix dest match the transposed dimensions of the matrix.
sourcepub fn transpose(&mut self) -> Value
pub fn transpose(&mut self) -> Value
This function replaces the matrix m by its transpose by copying the elements of the matrix in-place. The matrix must be square for this operation to be possible.
sourcepub fn add(&mut self, other: &MatrixU32) -> Value
pub fn add(&mut self, other: &MatrixU32) -> Value
This function adds the elements of the other matrix to the elements of the self matrix. The result self(i,j) <- self(i,j) + other(i,j) is stored in self and other remains unchanged. The two matrices must have the same dimensions.
sourcepub fn sub(&mut self, other: &MatrixU32) -> Value
pub fn sub(&mut self, other: &MatrixU32) -> Value
This function subtracts the elements of the other matrix from the elements of the self matrix. The result self(i,j) <- self(i,j) - other(i,j) is stored in self and other remains unchanged. The two matrices must have the same dimensions.
sourcepub fn mul_elements(&mut self, other: &MatrixU32) -> Value
pub fn mul_elements(&mut self, other: &MatrixU32) -> Value
This function multiplies the elements of the self matrix by the elements of the other matrix. The result self(i,j) <- self(i,j) * other(i,j) is stored in self and other remains unchanged. The two matrices must have the same dimensions.
sourcepub fn div_elements(&mut self, other: &MatrixU32) -> Value
pub fn div_elements(&mut self, other: &MatrixU32) -> Value
This function divides the elements of the self matrix by the elements of the other matrix. The result self(i,j) <- self(i,j) / other(i,j) is stored in self and other remains unchanged. The two matrices must have the same dimensions.
sourcepub fn scale(&mut self, x: u32) -> Value
pub fn scale(&mut self, x: u32) -> Value
This function multiplies the elements of the self matrix by the constant factor x. The result self(i,j) <- x self(i,j) is stored in self.
sourcepub fn add_constant(&mut self, x: u32) -> Value
pub fn add_constant(&mut self, x: u32) -> Value
This function adds the constant value x to the elements of the self matrix. The result self(i,j) <- self(i,j) + x is stored in self.
pub fn add_diagonal(&mut self, x: u32) -> Value
sourcepub fn minmax(&self) -> (u32, u32)
pub fn minmax(&self) -> (u32, u32)
This function returns the minimum and maximum values in the self matrix.
sourcepub fn max_index(&self) -> (usize, usize)
pub fn max_index(&self) -> (usize, usize)
This function returns the indices of the maximum value in the self matrix. When there are several equal maximum elements then the first element found is returned, searching in row-major order.
sourcepub fn min_index(&self) -> (usize, usize)
pub fn min_index(&self) -> (usize, usize)
This function returns the indices of the minimum value in the self matrix. When there are several equal minimum elements then the first element found is returned, searching in row major order.
sourcepub fn minmax_index(&self) -> (usize, usize, usize, usize)
pub fn minmax_index(&self) -> (usize, usize, usize, usize)
This function returns the indices of the minimum and maximum values in the self matrix. When there are several equal minimum or maximum elements then the first elements found are returned, searching in row-major order.
sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
This function returns true if all the elements of the self matrix are stricly zero.
sourcepub fn is_pos(&self) -> bool
pub fn is_pos(&self) -> bool
This function returns true if all the elements of the self matrix are stricly positive.
sourcepub fn is_neg(&self) -> bool
pub fn is_neg(&self) -> bool
This function returns true if all the elements of the self matrix are stricly negative.
sourcepub fn is_non_neg(&self) -> bool
pub fn is_non_neg(&self) -> bool
This function returns true if all the elements of the self matrix are stricly non-negative.
sourcepub fn equal(&self, other: &MatrixU32) -> bool
pub fn equal(&self, other: &MatrixU32) -> bool
This function returns true if all elements of the two matrix are equal.
pub fn row<F: FnOnce(Option<VectorU32View<'_>>)>(&mut self, i: usize, f: F)
pub fn column<F: FnOnce(Option<VectorU32View<'_>>)>(&mut self, j: usize, f: F)
pub fn diagonal<F: FnOnce(Option<VectorU32View<'_>>)>(&mut self, f: F)
pub fn subdiagonal<F: FnOnce(Option<VectorU32View<'_>>)>(
&mut self,
k: usize,
f: F
)
pub fn superdiagonal<F: FnOnce(Option<VectorU32View<'_>>)>(
&mut self,
k: usize,
f: F
)
pub fn subrow<F: FnOnce(Option<VectorU32View<'_>>)>(
&mut self,
i: usize,
offset: usize,
n: usize,
f: F
)
pub fn subcolumn<F: FnOnce(Option<VectorU32View<'_>>)>(
&mut self,
i: usize,
offset: usize,
n: usize,
f: F
)
pub fn submatrix<'a>(
&'a mut self,
k1: usize,
k2: usize,
n1: usize,
n2: usize
) -> MatrixU32View<'a>
pub fn size1(&self) -> usize
pub fn size2(&self) -> usize
pub fn clone(&self) -> Option<Self>
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for MatrixU32
impl !Send for MatrixU32
impl !Sync for MatrixU32
impl Unpin for MatrixU32
impl UnwindSafe for MatrixU32
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more