Struct rgsl::types::matrix::MatrixF64
[−]
[src]
pub struct MatrixF64 { /* fields omitted */ }
Methods
impl MatrixF64
[src]
fn new(n1: usize, n2: usize) -> Option<MatrixF64>
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) -> f64
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(&mut self, y: usize, x: usize, value: f64) -> &MatrixF64
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(&mut self, x: f64) -> &MatrixF64
This function sets all the elements of the matrix to the value x.
fn set_zero(&mut self) -> &MatrixF64
This function sets all the elements of the matrix to zero.
fn set_identity(&mut self) -> &MatrixF64
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(&mut self, other: &MatrixF64) -> 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: &mut MatrixF64) -> Value
This function copies the elements of the self matrix into the other matrix. The two matrices must have the same size.
fn swap(&mut self, other: &mut MatrixF64) -> 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<(VectorF64, 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<(VectorF64, Value)>
This function copies the elements of the x-th column of the matrix into the returned vector.
fn set_row(&mut self, y: usize, v: &VectorF64) -> 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(&mut self, x: usize, v: &VectorF64) -> 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(&mut self, y1: usize, y2: usize) -> Value
This function exchanges the y1-th and y2-th rows of the matrix in-place.
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.
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.
fn transpose_memcpy(&self) -> Option<(MatrixF64, 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(&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.
fn add(&mut self, other: &MatrixF64) -> 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(&mut self, other: &MatrixF64) -> 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(&mut self, other: &MatrixF64) -> 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(&mut self, other: &MatrixF64) -> 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(&mut self, x: f64) -> 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(&mut self, x: f64) -> 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) -> f64
This function returns the maximum value in the self matrix.
fn min(&self) -> f64
This function returns the minimum value in the self matrix.
fn minmax(&self, min_out: &mut f64, max_out: &mut f64)
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: &MatrixF64) -> bool
This function returns true if all elements of the two matrix are equal.