Struct rgsl::types::matrix::MatrixF32
[−]
[src]
pub struct MatrixF32 { // some fields omitted }
Methods
impl MatrixF32
[src]
fn new(n1: usize, n2: usize) -> Option<MatrixF32>
Creates a new MatrixF64 with all elements set to zero
Example with n1 = 2 and n2 = 3 :
XX XX XX
XX XX XX
fn get(&self, y: usize, x: usize) -> f32
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.
fn set(&self, y: usize, x: usize, value: f32) -> &MatrixF32
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.
fn set_all(&self, x: f32) -> &MatrixF32
This function sets all the elements of the matrix to the value x.
fn set_zero(&self) -> &MatrixF32
This function sets all the elements of the matrix to zero.
fn set_identity(&self) -> &MatrixF32
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.
fn copy_from(&self, other: &MatrixF32) -> Value
This function copies the elements of the other matrix into the self matrix. The two matrices must have the same size.
fn copy_to(&self, other: &MatrixF32) -> Value
This function copies the elements of the self matrix into the other matrix. The two matrices must have the same size.
fn swap(&self, other: &MatrixF32) -> Value
This function exchanges the elements of the matrices self and other by copying. The two matrices must have the same size.
fn get_row(&self, y: usize) -> Option<(VectorF32, Value)>
This function copies the elements of the y-th row of the matrix into the returned vector.
fn get_col(&self, x: usize) -> Option<(VectorF32, Value)>
This function copies the elements of the x-th column of the matrix into the returned vector.
fn set_row(&self, y: usize, v: &VectorF32) -> 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.
fn set_col(&self, x: usize, v: &VectorF32) -> 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.
fn swap_rows(&self, y1: usize, y2: usize) -> Value
This function exchanges the y1-th and y2-th rows of the matrix in-place.
fn swap_columns(&self, x1: usize, x2: usize) -> Value
This function exchanges the x1-th and x2-th columns of the matrix in-place.
fn swap_row_col(&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.
fn transpose_memcpy(&self) -> Option<(MatrixF32, Value)>
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.
fn transpose(&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.
fn add(&self, other: &MatrixF32) -> 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.
fn sub(&self, other: &MatrixF32) -> 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.
fn mul_elements(&self, other: &MatrixF32) -> 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.
fn div_elements(&self, other: &MatrixF32) -> 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.
fn scale(&self, x: f32) -> 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.
fn add_constant(&self, x: f32) -> 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.
fn max(&self) -> f32
This function returns the maximum value in the self matrix.
fn min(&self) -> f32
This function returns the minimum value in the self matrix.
fn minmax(&self, min_out: &mut f32, max_out: &mut f32)
This function returns the minimum and maximum values in the self matrix, storing them in min_out and max_out.
fn max_index(&self) -> (usize, usize)
This function returns the indices of the maximum value in the self matrix, storing them in imax and jmax. When there are several equal maximum elements then the first element found is returned, searching in row-major order.
fn min_index(&self) -> (usize, usize)
This function returns the indices of the minimum value in the self matrix, storing them in imin and jmin. When there are several equal minimum elements then the first element found is returned, searching in row-major order.
fn minmax_index(&self) -> (usize, usize, usize, usize)
This function returns the indices of the minimum and maximum values in the self matrix, storing them in (imin,jmin) and (imax,jmax). When there are several equal minimum or maximum elements then the first elements found are returned, searching in row-major order.
fn is_null(&self) -> bool
This function returns true if all the elements of the self matrix are stricly zero.
fn is_pos(&self) -> bool
This function returns true if all the elements of the self matrix are stricly positive.
fn is_neg(&self) -> bool
This function returns true if all the elements of the self matrix are stricly negative.
fn is_non_neg(&self) -> bool
This function returns true if all the elements of the self matrix are stricly non-negative.
fn equal(&self, other: &MatrixF32) -> bool
This function returns true if all elements of the two matrix are equal.