Type Definition nalgebra::base::MatrixMN [−][src]
pub type MatrixMN<N, R, C> = Matrix<N, R, C, Owned<N, R, C>>;
Expand description
A statically sized column-major matrix with R
rows and C
columns.
Because this is an alias, not all its methods are listed here. See the Matrix
type too.
Implementations
Generic constructors
This set of matrix and vector construction functions are all generic with-regard to the matrix dimensions. They all expect to be given the dimension as inputs.
These functions should only be used when working on dimension-generic code.
Creates a new uninitialized matrix. If the matrix has a compile-time dimension, this panics
if nrows != R::to_usize()
or ncols != C::to_usize()
.
Creates a matrix with all its elements set to elem
.
Creates a matrix with all its elements set to elem
.
Same as from_element_generic
.
Creates a matrix with all its elements set to 0.
pub fn from_iterator_generic<I>(nrows: R, ncols: C, iter: I) -> Self where
I: IntoIterator<Item = N>,
pub fn from_iterator_generic<I>(nrows: R, ncols: C, iter: I) -> Self where
I: IntoIterator<Item = N>,
Creates a matrix with all its elements filled by an iterator.
Creates a matrix with its elements filled with the components provided by a slice in row-major order.
The order of elements in the slice must follow the usual mathematic writing, i.e., row-by-row.
Creates a matrix with its elements filled with the components provided by a slice. The components must have the same layout as the matrix data storage (i.e. column-major).
Creates a matrix filled with the results of a function applied to each of its component coordinates.
Creates a new identity matrix.
If the matrix is not square, the largest square submatrix starting at index (0, 0)
is set
to the identity matrix. All other entries are set to zero.
Creates a new matrix with its diagonal filled with copies of elt
.
If the matrix is not square, the largest square submatrix starting at index (0, 0)
is set
to the identity matrix. All other entries are set to zero.
Creates a new matrix that may be rectangular. The first elts.len()
diagonal elements are
filled with the content of elts
. Others are set to 0.
Panics if elts.len()
is larger than the minimum among nrows
and ncols
.
Builds a new matrix from its rows.
Panics if not enough rows are provided (for statically-sized matrices), or if all rows do not have the same dimensions.
Example
let m = Matrix3::from_rows(&[ RowVector3::new(1.0, 2.0, 3.0), RowVector3::new(4.0, 5.0, 6.0), RowVector3::new(7.0, 8.0, 9.0) ]); assert!(m.m11 == 1.0 && m.m12 == 2.0 && m.m13 == 3.0 && m.m21 == 4.0 && m.m22 == 5.0 && m.m23 == 6.0 && m.m31 == 7.0 && m.m32 == 8.0 && m.m33 == 9.0);
Builds a new matrix from its columns.
Panics if not enough columns are provided (for statically-sized matrices), or if all columns do not have the same dimensions.
Example
let m = Matrix3::from_columns(&[ Vector3::new(1.0, 2.0, 3.0), Vector3::new(4.0, 5.0, 6.0), Vector3::new(7.0, 8.0, 9.0) ]); assert!(m.m11 == 1.0 && m.m12 == 4.0 && m.m13 == 7.0 && m.m21 == 2.0 && m.m22 == 5.0 && m.m23 == 8.0 && m.m31 == 3.0 && m.m32 == 6.0 && m.m33 == 9.0);
Creates a matrix backed by a given Vec
.
The output matrix is filled column-by-column.
Example
let vec = vec![0, 1, 2, 3, 4, 5]; let vec_ptr = vec.as_ptr(); let matrix = Matrix::from_vec_generic(Dynamic::new(vec.len()), U1, vec); let matrix_storage_ptr = matrix.data.as_vec().as_ptr(); // `matrix` is backed by exactly the same `Vec` as it was constructed from. assert_eq!(matrix_storage_ptr, vec_ptr);
Creates a new uninitialized matrix or vector.
Creates a matrix or vector with all its elements set to elem
.
Example
let v = Vector3::from_element(2.0); // The additional argument represents the vector dimension. let dv = DVector::from_element(3, 2.0); let m = Matrix2x3::from_element(2.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_element(2, 3, 2.0); assert!(v.x == 2.0 && v.y == 2.0 && v.z == 2.0); assert!(dv[0] == 2.0 && dv[1] == 2.0 && dv[2] == 2.0); assert!(m.m11 == 2.0 && m.m12 == 2.0 && m.m13 == 2.0 && m.m21 == 2.0 && m.m22 == 2.0 && m.m23 == 2.0); assert!(dm[(0, 0)] == 2.0 && dm[(0, 1)] == 2.0 && dm[(0, 2)] == 2.0 && dm[(1, 0)] == 2.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 2.0);
Creates a matrix or vector with all its elements set to elem
.
Same as .from_element
.
Example
let v = Vector3::repeat(2.0); // The additional argument represents the vector dimension. let dv = DVector::repeat(3, 2.0); let m = Matrix2x3::repeat(2.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::repeat(2, 3, 2.0); assert!(v.x == 2.0 && v.y == 2.0 && v.z == 2.0); assert!(dv[0] == 2.0 && dv[1] == 2.0 && dv[2] == 2.0); assert!(m.m11 == 2.0 && m.m12 == 2.0 && m.m13 == 2.0 && m.m21 == 2.0 && m.m22 == 2.0 && m.m23 == 2.0); assert!(dm[(0, 0)] == 2.0 && dm[(0, 1)] == 2.0 && dm[(0, 2)] == 2.0 && dm[(1, 0)] == 2.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 2.0);
Creates a matrix or vector with all its elements set to 0
.
Example
let v = Vector3::<f32>::zeros(); // The argument represents the vector dimension. let dv = DVector::<f32>::zeros(3); let m = Matrix2x3::<f32>::zeros(); // The two arguments represent the matrix dimensions. let dm = DMatrix::<f32>::zeros(2, 3); assert!(v.x == 0.0 && v.y == 0.0 && v.z == 0.0); assert!(dv[0] == 0.0 && dv[1] == 0.0 && dv[2] == 0.0); assert!(m.m11 == 0.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 0.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 0.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 0.0 && dm[(1, 2)] == 0.0);
Creates a matrix or vector with all its elements filled by an iterator.
The output matrix is filled column-by-column.
Example
let v = Vector3::from_iterator((0..3).into_iter()); // The additional argument represents the vector dimension. let dv = DVector::from_iterator(3, (0..3).into_iter()); let m = Matrix2x3::from_iterator((0..6).into_iter()); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_iterator(2, 3, (0..6).into_iter()); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix or vector filled with the results of a function applied to each of its component coordinates.
Example
let v = Vector3::from_fn(|i, _| i); // The additional argument represents the vector dimension. let dv = DVector::from_fn(3, |i, _| i); let m = Matrix2x3::from_fn(|i, j| i * 3 + j); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_fn(2, 3, |i, j| i * 3 + j); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 1 && m.m13 == 2 && m.m21 == 3 && m.m22 == 4 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 1 && dm[(0, 2)] == 2 && dm[(1, 0)] == 3 && dm[(1, 1)] == 4 && dm[(1, 2)] == 5);
Creates an identity matrix. If the matrix is not square, the largest square submatrix (starting at the first row and column) is set to the identity while all other entries are set to zero.
Example
let m = Matrix2x3::<f32>::identity(); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::<f32>::identity(2, 3); assert!(m.m11 == 1.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 1.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 1.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 1.0 && dm[(1, 2)] == 0.0);
Creates a matrix filled with its diagonal filled with elt
and all other
components set to zero.
Example
let m = Matrix2x3::from_diagonal_element(5.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_diagonal_element(2, 3, 5.0); assert!(m.m11 == 5.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 5.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 5.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 5.0 && dm[(1, 2)] == 0.0);
Creates a new matrix that may be rectangular. The first elts.len()
diagonal
elements are filled with the content of elts
. Others are set to 0.
Panics if elts.len()
is larger than the minimum among nrows
and ncols
.
Example
let m = Matrix3::from_partial_diagonal(&[1.0, 2.0]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_partial_diagonal(3, 3, &[1.0, 2.0]); assert!(m.m11 == 1.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 2.0 && m.m23 == 0.0 && m.m31 == 0.0 && m.m32 == 0.0 && m.m33 == 0.0); assert!(dm[(0, 0)] == 1.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 0.0 && dm[(2, 0)] == 0.0 && dm[(2, 1)] == 0.0 && dm[(2, 2)] == 0.0);
Creates a new uninitialized matrix or vector.
Creates a matrix or vector with all its elements set to elem
.
Example
let v = Vector3::from_element(2.0); // The additional argument represents the vector dimension. let dv = DVector::from_element(3, 2.0); let m = Matrix2x3::from_element(2.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_element(2, 3, 2.0); assert!(v.x == 2.0 && v.y == 2.0 && v.z == 2.0); assert!(dv[0] == 2.0 && dv[1] == 2.0 && dv[2] == 2.0); assert!(m.m11 == 2.0 && m.m12 == 2.0 && m.m13 == 2.0 && m.m21 == 2.0 && m.m22 == 2.0 && m.m23 == 2.0); assert!(dm[(0, 0)] == 2.0 && dm[(0, 1)] == 2.0 && dm[(0, 2)] == 2.0 && dm[(1, 0)] == 2.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 2.0);
Creates a matrix or vector with all its elements set to elem
.
Same as .from_element
.
Example
let v = Vector3::repeat(2.0); // The additional argument represents the vector dimension. let dv = DVector::repeat(3, 2.0); let m = Matrix2x3::repeat(2.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::repeat(2, 3, 2.0); assert!(v.x == 2.0 && v.y == 2.0 && v.z == 2.0); assert!(dv[0] == 2.0 && dv[1] == 2.0 && dv[2] == 2.0); assert!(m.m11 == 2.0 && m.m12 == 2.0 && m.m13 == 2.0 && m.m21 == 2.0 && m.m22 == 2.0 && m.m23 == 2.0); assert!(dm[(0, 0)] == 2.0 && dm[(0, 1)] == 2.0 && dm[(0, 2)] == 2.0 && dm[(1, 0)] == 2.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 2.0);
Creates a matrix or vector with all its elements set to 0
.
Example
let v = Vector3::<f32>::zeros(); // The argument represents the vector dimension. let dv = DVector::<f32>::zeros(3); let m = Matrix2x3::<f32>::zeros(); // The two arguments represent the matrix dimensions. let dm = DMatrix::<f32>::zeros(2, 3); assert!(v.x == 0.0 && v.y == 0.0 && v.z == 0.0); assert!(dv[0] == 0.0 && dv[1] == 0.0 && dv[2] == 0.0); assert!(m.m11 == 0.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 0.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 0.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 0.0 && dm[(1, 2)] == 0.0);
Creates a matrix or vector with all its elements filled by an iterator.
The output matrix is filled column-by-column.
Example
let v = Vector3::from_iterator((0..3).into_iter()); // The additional argument represents the vector dimension. let dv = DVector::from_iterator(3, (0..3).into_iter()); let m = Matrix2x3::from_iterator((0..6).into_iter()); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_iterator(2, 3, (0..6).into_iter()); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix or vector filled with the results of a function applied to each of its component coordinates.
Example
let v = Vector3::from_fn(|i, _| i); // The additional argument represents the vector dimension. let dv = DVector::from_fn(3, |i, _| i); let m = Matrix2x3::from_fn(|i, j| i * 3 + j); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_fn(2, 3, |i, j| i * 3 + j); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 1 && m.m13 == 2 && m.m21 == 3 && m.m22 == 4 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 1 && dm[(0, 2)] == 2 && dm[(1, 0)] == 3 && dm[(1, 1)] == 4 && dm[(1, 2)] == 5);
Creates an identity matrix. If the matrix is not square, the largest square submatrix (starting at the first row and column) is set to the identity while all other entries are set to zero.
Example
let m = Matrix2x3::<f32>::identity(); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::<f32>::identity(2, 3); assert!(m.m11 == 1.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 1.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 1.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 1.0 && dm[(1, 2)] == 0.0);
Creates a matrix filled with its diagonal filled with elt
and all other
components set to zero.
Example
let m = Matrix2x3::from_diagonal_element(5.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_diagonal_element(2, 3, 5.0); assert!(m.m11 == 5.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 5.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 5.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 5.0 && dm[(1, 2)] == 0.0);
Creates a new matrix that may be rectangular. The first elts.len()
diagonal
elements are filled with the content of elts
. Others are set to 0.
Panics if elts.len()
is larger than the minimum among nrows
and ncols
.
Example
let m = Matrix3::from_partial_diagonal(&[1.0, 2.0]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_partial_diagonal(3, 3, &[1.0, 2.0]); assert!(m.m11 == 1.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 2.0 && m.m23 == 0.0 && m.m31 == 0.0 && m.m32 == 0.0 && m.m33 == 0.0); assert!(dm[(0, 0)] == 1.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 0.0 && dm[(2, 0)] == 0.0 && dm[(2, 1)] == 0.0 && dm[(2, 2)] == 0.0);
Creates a new uninitialized matrix or vector.
Creates a matrix or vector with all its elements set to elem
.
Example
let v = Vector3::from_element(2.0); // The additional argument represents the vector dimension. let dv = DVector::from_element(3, 2.0); let m = Matrix2x3::from_element(2.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_element(2, 3, 2.0); assert!(v.x == 2.0 && v.y == 2.0 && v.z == 2.0); assert!(dv[0] == 2.0 && dv[1] == 2.0 && dv[2] == 2.0); assert!(m.m11 == 2.0 && m.m12 == 2.0 && m.m13 == 2.0 && m.m21 == 2.0 && m.m22 == 2.0 && m.m23 == 2.0); assert!(dm[(0, 0)] == 2.0 && dm[(0, 1)] == 2.0 && dm[(0, 2)] == 2.0 && dm[(1, 0)] == 2.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 2.0);
Creates a matrix or vector with all its elements set to elem
.
Same as .from_element
.
Example
let v = Vector3::repeat(2.0); // The additional argument represents the vector dimension. let dv = DVector::repeat(3, 2.0); let m = Matrix2x3::repeat(2.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::repeat(2, 3, 2.0); assert!(v.x == 2.0 && v.y == 2.0 && v.z == 2.0); assert!(dv[0] == 2.0 && dv[1] == 2.0 && dv[2] == 2.0); assert!(m.m11 == 2.0 && m.m12 == 2.0 && m.m13 == 2.0 && m.m21 == 2.0 && m.m22 == 2.0 && m.m23 == 2.0); assert!(dm[(0, 0)] == 2.0 && dm[(0, 1)] == 2.0 && dm[(0, 2)] == 2.0 && dm[(1, 0)] == 2.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 2.0);
Creates a matrix or vector with all its elements set to 0
.
Example
let v = Vector3::<f32>::zeros(); // The argument represents the vector dimension. let dv = DVector::<f32>::zeros(3); let m = Matrix2x3::<f32>::zeros(); // The two arguments represent the matrix dimensions. let dm = DMatrix::<f32>::zeros(2, 3); assert!(v.x == 0.0 && v.y == 0.0 && v.z == 0.0); assert!(dv[0] == 0.0 && dv[1] == 0.0 && dv[2] == 0.0); assert!(m.m11 == 0.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 0.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 0.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 0.0 && dm[(1, 2)] == 0.0);
Creates a matrix or vector with all its elements filled by an iterator.
The output matrix is filled column-by-column.
Example
let v = Vector3::from_iterator((0..3).into_iter()); // The additional argument represents the vector dimension. let dv = DVector::from_iterator(3, (0..3).into_iter()); let m = Matrix2x3::from_iterator((0..6).into_iter()); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_iterator(2, 3, (0..6).into_iter()); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix or vector filled with the results of a function applied to each of its component coordinates.
Example
let v = Vector3::from_fn(|i, _| i); // The additional argument represents the vector dimension. let dv = DVector::from_fn(3, |i, _| i); let m = Matrix2x3::from_fn(|i, j| i * 3 + j); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_fn(2, 3, |i, j| i * 3 + j); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 1 && m.m13 == 2 && m.m21 == 3 && m.m22 == 4 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 1 && dm[(0, 2)] == 2 && dm[(1, 0)] == 3 && dm[(1, 1)] == 4 && dm[(1, 2)] == 5);
Creates an identity matrix. If the matrix is not square, the largest square submatrix (starting at the first row and column) is set to the identity while all other entries are set to zero.
Example
let m = Matrix2x3::<f32>::identity(); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::<f32>::identity(2, 3); assert!(m.m11 == 1.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 1.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 1.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 1.0 && dm[(1, 2)] == 0.0);
Creates a matrix filled with its diagonal filled with elt
and all other
components set to zero.
Example
let m = Matrix2x3::from_diagonal_element(5.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_diagonal_element(2, 3, 5.0); assert!(m.m11 == 5.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 5.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 5.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 5.0 && dm[(1, 2)] == 0.0);
Creates a new matrix that may be rectangular. The first elts.len()
diagonal
elements are filled with the content of elts
. Others are set to 0.
Panics if elts.len()
is larger than the minimum among nrows
and ncols
.
Example
let m = Matrix3::from_partial_diagonal(&[1.0, 2.0]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_partial_diagonal(3, 3, &[1.0, 2.0]); assert!(m.m11 == 1.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 2.0 && m.m23 == 0.0 && m.m31 == 0.0 && m.m32 == 0.0 && m.m33 == 0.0); assert!(dm[(0, 0)] == 1.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 0.0 && dm[(2, 0)] == 0.0 && dm[(2, 1)] == 0.0 && dm[(2, 2)] == 0.0);
Creates a new uninitialized matrix or vector.
Creates a matrix or vector with all its elements set to elem
.
Example
let v = Vector3::from_element(2.0); // The additional argument represents the vector dimension. let dv = DVector::from_element(3, 2.0); let m = Matrix2x3::from_element(2.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_element(2, 3, 2.0); assert!(v.x == 2.0 && v.y == 2.0 && v.z == 2.0); assert!(dv[0] == 2.0 && dv[1] == 2.0 && dv[2] == 2.0); assert!(m.m11 == 2.0 && m.m12 == 2.0 && m.m13 == 2.0 && m.m21 == 2.0 && m.m22 == 2.0 && m.m23 == 2.0); assert!(dm[(0, 0)] == 2.0 && dm[(0, 1)] == 2.0 && dm[(0, 2)] == 2.0 && dm[(1, 0)] == 2.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 2.0);
Creates a matrix or vector with all its elements set to elem
.
Same as .from_element
.
Example
let v = Vector3::repeat(2.0); // The additional argument represents the vector dimension. let dv = DVector::repeat(3, 2.0); let m = Matrix2x3::repeat(2.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::repeat(2, 3, 2.0); assert!(v.x == 2.0 && v.y == 2.0 && v.z == 2.0); assert!(dv[0] == 2.0 && dv[1] == 2.0 && dv[2] == 2.0); assert!(m.m11 == 2.0 && m.m12 == 2.0 && m.m13 == 2.0 && m.m21 == 2.0 && m.m22 == 2.0 && m.m23 == 2.0); assert!(dm[(0, 0)] == 2.0 && dm[(0, 1)] == 2.0 && dm[(0, 2)] == 2.0 && dm[(1, 0)] == 2.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 2.0);
Creates a matrix or vector with all its elements set to 0
.
Example
let v = Vector3::<f32>::zeros(); // The argument represents the vector dimension. let dv = DVector::<f32>::zeros(3); let m = Matrix2x3::<f32>::zeros(); // The two arguments represent the matrix dimensions. let dm = DMatrix::<f32>::zeros(2, 3); assert!(v.x == 0.0 && v.y == 0.0 && v.z == 0.0); assert!(dv[0] == 0.0 && dv[1] == 0.0 && dv[2] == 0.0); assert!(m.m11 == 0.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 0.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 0.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 0.0 && dm[(1, 2)] == 0.0);
pub fn from_iterator<I>(nrows: usize, ncols: usize, iter: I) -> Self where
I: IntoIterator<Item = N>,
pub fn from_iterator<I>(nrows: usize, ncols: usize, iter: I) -> Self where
I: IntoIterator<Item = N>,
Creates a matrix or vector with all its elements filled by an iterator.
The output matrix is filled column-by-column.
Example
let v = Vector3::from_iterator((0..3).into_iter()); // The additional argument represents the vector dimension. let dv = DVector::from_iterator(3, (0..3).into_iter()); let m = Matrix2x3::from_iterator((0..6).into_iter()); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_iterator(2, 3, (0..6).into_iter()); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix or vector filled with the results of a function applied to each of its component coordinates.
Example
let v = Vector3::from_fn(|i, _| i); // The additional argument represents the vector dimension. let dv = DVector::from_fn(3, |i, _| i); let m = Matrix2x3::from_fn(|i, j| i * 3 + j); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_fn(2, 3, |i, j| i * 3 + j); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 1 && m.m13 == 2 && m.m21 == 3 && m.m22 == 4 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 1 && dm[(0, 2)] == 2 && dm[(1, 0)] == 3 && dm[(1, 1)] == 4 && dm[(1, 2)] == 5);
Creates an identity matrix. If the matrix is not square, the largest square submatrix (starting at the first row and column) is set to the identity while all other entries are set to zero.
Example
let m = Matrix2x3::<f32>::identity(); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::<f32>::identity(2, 3); assert!(m.m11 == 1.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 1.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 1.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 1.0 && dm[(1, 2)] == 0.0);
Creates a matrix filled with its diagonal filled with elt
and all other
components set to zero.
Example
let m = Matrix2x3::from_diagonal_element(5.0); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_diagonal_element(2, 3, 5.0); assert!(m.m11 == 5.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 5.0 && m.m23 == 0.0); assert!(dm[(0, 0)] == 5.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 5.0 && dm[(1, 2)] == 0.0);
Creates a new matrix that may be rectangular. The first elts.len()
diagonal
elements are filled with the content of elts
. Others are set to 0.
Panics if elts.len()
is larger than the minimum among nrows
and ncols
.
Example
let m = Matrix3::from_partial_diagonal(&[1.0, 2.0]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_partial_diagonal(3, 3, &[1.0, 2.0]); assert!(m.m11 == 1.0 && m.m12 == 0.0 && m.m13 == 0.0 && m.m21 == 0.0 && m.m22 == 2.0 && m.m23 == 0.0 && m.m31 == 0.0 && m.m32 == 0.0 && m.m33 == 0.0); assert!(dm[(0, 0)] == 1.0 && dm[(0, 1)] == 0.0 && dm[(0, 2)] == 0.0 && dm[(1, 0)] == 0.0 && dm[(1, 1)] == 2.0 && dm[(1, 2)] == 0.0 && dm[(2, 0)] == 0.0 && dm[(2, 1)] == 0.0 && dm[(2, 2)] == 0.0);
Creates a matrix with its elements filled with the components provided by a slice in row-major order.
The order of elements in the slice must follow the usual mathematic writing, i.e., row-by-row.
Example
let v = Vector3::from_row_slice(&[0, 1, 2]); // The additional argument represents the vector dimension. let dv = DVector::from_row_slice(&[0, 1, 2]); let m = Matrix2x3::from_row_slice(&[0, 1, 2, 3, 4, 5]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_row_slice(2, 3, &[0, 1, 2, 3, 4, 5]); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 1 && m.m13 == 2 && m.m21 == 3 && m.m22 == 4 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 1 && dm[(0, 2)] == 2 && dm[(1, 0)] == 3 && dm[(1, 1)] == 4 && dm[(1, 2)] == 5);
Creates a matrix with its elements filled with the components provided by a slice in column-major order.
Example
let v = Vector3::from_column_slice(&[0, 1, 2]); // The additional argument represents the vector dimension. let dv = DVector::from_column_slice(&[0, 1, 2]); let m = Matrix2x3::from_column_slice(&[0, 1, 2, 3, 4, 5]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_column_slice(2, 3, &[0, 1, 2, 3, 4, 5]); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix backed by a given Vec
.
The output matrix is filled column-by-column.
Example
let m = Matrix2x3::from_vec(vec![0, 1, 2, 3, 4, 5]); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_vec(2, 3, vec![0, 1, 2, 3, 4, 5]); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix with its elements filled with the components provided by a slice in row-major order.
The order of elements in the slice must follow the usual mathematic writing, i.e., row-by-row.
Example
let v = Vector3::from_row_slice(&[0, 1, 2]); // The additional argument represents the vector dimension. let dv = DVector::from_row_slice(&[0, 1, 2]); let m = Matrix2x3::from_row_slice(&[0, 1, 2, 3, 4, 5]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_row_slice(2, 3, &[0, 1, 2, 3, 4, 5]); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 1 && m.m13 == 2 && m.m21 == 3 && m.m22 == 4 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 1 && dm[(0, 2)] == 2 && dm[(1, 0)] == 3 && dm[(1, 1)] == 4 && dm[(1, 2)] == 5);
Creates a matrix with its elements filled with the components provided by a slice in column-major order.
Example
let v = Vector3::from_column_slice(&[0, 1, 2]); // The additional argument represents the vector dimension. let dv = DVector::from_column_slice(&[0, 1, 2]); let m = Matrix2x3::from_column_slice(&[0, 1, 2, 3, 4, 5]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_column_slice(2, 3, &[0, 1, 2, 3, 4, 5]); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix backed by a given Vec
.
The output matrix is filled column-by-column.
Example
let m = Matrix2x3::from_vec(vec![0, 1, 2, 3, 4, 5]); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_vec(2, 3, vec![0, 1, 2, 3, 4, 5]); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix with its elements filled with the components provided by a slice in row-major order.
The order of elements in the slice must follow the usual mathematic writing, i.e., row-by-row.
Example
let v = Vector3::from_row_slice(&[0, 1, 2]); // The additional argument represents the vector dimension. let dv = DVector::from_row_slice(&[0, 1, 2]); let m = Matrix2x3::from_row_slice(&[0, 1, 2, 3, 4, 5]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_row_slice(2, 3, &[0, 1, 2, 3, 4, 5]); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 1 && m.m13 == 2 && m.m21 == 3 && m.m22 == 4 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 1 && dm[(0, 2)] == 2 && dm[(1, 0)] == 3 && dm[(1, 1)] == 4 && dm[(1, 2)] == 5);
Creates a matrix with its elements filled with the components provided by a slice in column-major order.
Example
let v = Vector3::from_column_slice(&[0, 1, 2]); // The additional argument represents the vector dimension. let dv = DVector::from_column_slice(&[0, 1, 2]); let m = Matrix2x3::from_column_slice(&[0, 1, 2, 3, 4, 5]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_column_slice(2, 3, &[0, 1, 2, 3, 4, 5]); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix backed by a given Vec
.
The output matrix is filled column-by-column.
Example
let m = Matrix2x3::from_vec(vec![0, 1, 2, 3, 4, 5]); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_vec(2, 3, vec![0, 1, 2, 3, 4, 5]); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix with its elements filled with the components provided by a slice in row-major order.
The order of elements in the slice must follow the usual mathematic writing, i.e., row-by-row.
Example
let v = Vector3::from_row_slice(&[0, 1, 2]); // The additional argument represents the vector dimension. let dv = DVector::from_row_slice(&[0, 1, 2]); let m = Matrix2x3::from_row_slice(&[0, 1, 2, 3, 4, 5]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_row_slice(2, 3, &[0, 1, 2, 3, 4, 5]); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 1 && m.m13 == 2 && m.m21 == 3 && m.m22 == 4 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 1 && dm[(0, 2)] == 2 && dm[(1, 0)] == 3 && dm[(1, 1)] == 4 && dm[(1, 2)] == 5);
Creates a matrix with its elements filled with the components provided by a slice in column-major order.
Example
let v = Vector3::from_column_slice(&[0, 1, 2]); // The additional argument represents the vector dimension. let dv = DVector::from_column_slice(&[0, 1, 2]); let m = Matrix2x3::from_column_slice(&[0, 1, 2, 3, 4, 5]); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_column_slice(2, 3, &[0, 1, 2, 3, 4, 5]); assert!(v.x == 0 && v.y == 1 && v.z == 2); assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
Creates a matrix backed by a given Vec
.
The output matrix is filled column-by-column.
Example
let m = Matrix2x3::from_vec(vec![0, 1, 2, 3, 4, 5]); assert!(m.m11 == 0 && m.m12 == 2 && m.m13 == 4 && m.m21 == 1 && m.m22 == 3 && m.m23 == 5); // The two additional arguments represent the matrix dimensions. let dm = DMatrix::from_vec(2, 3, vec![0, 1, 2, 3, 4, 5]); assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 2 && dm[(0, 2)] == 4 && dm[(1, 0)] == 1 && dm[(1, 1)] == 3 && dm[(1, 2)] == 5);
pub fn new(
m11: N,
m12: N,
m13: N,
m14: N,
m15: N,
m16: N,
m21: N,
m22: N,
m23: N,
m24: N,
m25: N,
m26: N,
m31: N,
m32: N,
m33: N,
m34: N,
m35: N,
m36: N,
m41: N,
m42: N,
m43: N,
m44: N,
m45: N,
m46: N,
m51: N,
m52: N,
m53: N,
m54: N,
m55: N,
m56: N,
m61: N,
m62: N,
m63: N,
m64: N,
m65: N,
m66: N
) -> Self
pub fn new(
m11: N,
m12: N,
m13: N,
m14: N,
m15: N,
m16: N,
m21: N,
m22: N,
m23: N,
m24: N,
m25: N,
m26: N,
m31: N,
m32: N,
m33: N,
m34: N,
m35: N,
m36: N,
m41: N,
m42: N,
m43: N,
m44: N,
m45: N,
m46: N,
m51: N,
m52: N,
m53: N,
m54: N,
m55: N,
m56: N,
m61: N,
m62: N,
m63: N,
m64: N,
m65: N,
m66: N
) -> Self
Initializes this matrix from its components.
Initializes this matrix from its components.
Initializes this matrix from its components.
pub fn resize_vertically_mut(&mut self, new_nrows: usize, val: N) where
DefaultAllocator: Reallocator<N, Dynamic, C, Dynamic, C>,
pub fn resize_vertically_mut(&mut self, new_nrows: usize, val: N) where
DefaultAllocator: Reallocator<N, Dynamic, C, Dynamic, C>,
Changes the number of rows of this matrix in-place.
The values are copied such that self[(i, j)] == result[(i, j)]
. If the result has more
rows than self
, then the extra rows are filled with val
.
Defined only for owned matrices with a dynamic number of rows (for example, DVector
).
pub fn resize_horizontally_mut(&mut self, new_ncols: usize, val: N) where
DefaultAllocator: Reallocator<N, R, Dynamic, R, Dynamic>,
pub fn resize_horizontally_mut(&mut self, new_ncols: usize, val: N) where
DefaultAllocator: Reallocator<N, R, Dynamic, R, Dynamic>,
Changes the number of column of this matrix in-place.
The values are copied such that self[(i, j)] == result[(i, j)]
. If the result has more
columns than self
, then the extra columns are filled with val
.
Defined only for owned matrices with a dynamic number of columns (for example, DVector
).
Trait Implementations
Performs the /=
operation. Read more
Performs the /=
operation. Read more
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[Matrix<<N as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<N as SimdValue>::Element, R, C>>::Buffer>; 16]> for MatrixMN<N, R, C> where
N: From<[<N as SimdValue>::Element; 16]>,
N::Element: Scalar + SimdValue,
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[Matrix<<N as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<N as SimdValue>::Element, R, C>>::Buffer>; 16]> for MatrixMN<N, R, C> where
N: From<[<N as SimdValue>::Element; 16]>,
N::Element: Scalar + SimdValue,
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[Matrix<<N as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<N as SimdValue>::Element, R, C>>::Buffer>; 2]> for MatrixMN<N, R, C> where
N: From<[<N as SimdValue>::Element; 2]>,
N::Element: Scalar + SimdValue,
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[Matrix<<N as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<N as SimdValue>::Element, R, C>>::Buffer>; 2]> for MatrixMN<N, R, C> where
N: From<[<N as SimdValue>::Element; 2]>,
N::Element: Scalar + SimdValue,
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[Matrix<<N as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<N as SimdValue>::Element, R, C>>::Buffer>; 4]> for MatrixMN<N, R, C> where
N: From<[<N as SimdValue>::Element; 4]>,
N::Element: Scalar + SimdValue,
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[Matrix<<N as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<N as SimdValue>::Element, R, C>>::Buffer>; 4]> for MatrixMN<N, R, C> where
N: From<[<N as SimdValue>::Element; 4]>,
N::Element: Scalar + SimdValue,
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[Matrix<<N as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<N as SimdValue>::Element, R, C>>::Buffer>; 8]> for MatrixMN<N, R, C> where
N: From<[<N as SimdValue>::Element; 8]>,
N::Element: Scalar + SimdValue,
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[Matrix<<N as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<N as SimdValue>::Element, R, C>>::Buffer>; 8]> for MatrixMN<N, R, C> where
N: From<[<N as SimdValue>::Element; 8]>,
N::Element: Scalar + SimdValue,
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
Performs the *=
operation. Read more
Performs the *=
operation. Read more
impl<N: SimdComplexField, R: Dim, C: Dim> Normed for MatrixMN<N, R, C> where
DefaultAllocator: Allocator<N, R, C>,
impl<N: SimdComplexField, R: Dim, C: Dim> Normed for MatrixMN<N, R, C> where
DefaultAllocator: Allocator<N, R, C>,
type Norm = N::SimdRealField
type Norm = N::SimdRealField
The type of the norm.
Computes the norm.
Computes the squared norm.
Divides self
by n.
impl<N1, N2, R1, C1, R2, C2> SubsetOf<Matrix<N2, R2, C2, <DefaultAllocator as Allocator<N2, R2, C2>>::Buffer>> for MatrixMN<N1, R1, C1> where
R1: Dim,
C1: Dim,
R2: Dim,
C2: Dim,
N1: Scalar,
N2: Scalar + SupersetOf<N1>,
DefaultAllocator: Allocator<N2, R2, C2> + Allocator<N1, R1, C1> + SameShapeAllocator<N1, R1, C1, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2> + SameNumberOfColumns<C1, C2>,
impl<N1, N2, R1, C1, R2, C2> SubsetOf<Matrix<N2, R2, C2, <DefaultAllocator as Allocator<N2, R2, C2>>::Buffer>> for MatrixMN<N1, R1, C1> where
R1: Dim,
C1: Dim,
R2: Dim,
C2: Dim,
N1: Scalar,
N2: Scalar + SupersetOf<N1>,
DefaultAllocator: Allocator<N2, R2, C2> + Allocator<N1, R1, C1> + SameShapeAllocator<N1, R1, C1, R2, C2>,
ShapeConstraint: SameNumberOfRows<R1, R2> + SameNumberOfColumns<C1, C2>,
The inclusion map: converts self
to the equivalent element of its superset.
Checks if element
is actually part of the subset Self
(and can be converted to it).
Use with care! Same as self.to_superset
but without any property checks. Always succeeds.
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
Example
assert_eq!(vec![DVector::repeat(3, 1.0f64), DVector::repeat(3, 1.0f64), DVector::repeat(3, 1.0f64)].into_iter().sum::<DVector<f64>>(), DVector::repeat(3, 1.0f64) + DVector::repeat(3, 1.0f64) + DVector::repeat(3, 1.0f64));
Panics
Panics if the iterator is empty:
iter::empty::<DMatrix<f64>>().sum::<DMatrix<f64>>(); // panics!