Expand description
A statically sized column-major matrix with R
rows and C
columns.
Implementations§
source§impl<N: Scalar, R: Dim, C: Dim> MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
impl<N: Scalar, R: Dim, C: Dim> MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
sourcepub unsafe fn new_uninitialized_generic(nrows: R, ncols: C) -> Self
pub unsafe fn new_uninitialized_generic(nrows: R, ncols: C) -> Self
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()
.
sourcepub fn from_element_generic(nrows: R, ncols: C, elem: N) -> Self
pub fn from_element_generic(nrows: R, ncols: C, elem: N) -> Self
Creates a matrix with all its elements set to elem
.
sourcepub fn repeat_generic(nrows: R, ncols: C, elem: N) -> Self
pub fn repeat_generic(nrows: R, ncols: C, elem: N) -> Self
Creates a matrix with all its elements set to elem
.
Same as from_element_generic
.
sourcepub fn zeros_generic(nrows: R, ncols: C) -> Selfwhere
N: Zero,
pub fn zeros_generic(nrows: R, ncols: C) -> Selfwhere
N: Zero,
Creates a matrix with all its elements set to 0.
sourcepub fn from_iterator_generic<I>(nrows: R, ncols: C, iter: I) -> Selfwhere
I: IntoIterator<Item = N>,
pub fn from_iterator_generic<I>(nrows: R, ncols: C, iter: I) -> Selfwhere
I: IntoIterator<Item = N>,
Creates a matrix with all its elements filled by an iterator.
sourcepub fn from_row_slice_generic(nrows: R, ncols: C, slice: &[N]) -> Self
pub fn from_row_slice_generic(nrows: R, ncols: C, slice: &[N]) -> Self
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.
sourcepub fn from_column_slice_generic(nrows: R, ncols: C, slice: &[N]) -> Self
pub fn from_column_slice_generic(nrows: R, ncols: C, slice: &[N]) -> Self
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).
sourcepub fn from_fn_generic<F>(nrows: R, ncols: C, f: F) -> Selfwhere
F: FnMut(usize, usize) -> N,
pub fn from_fn_generic<F>(nrows: R, ncols: C, f: F) -> Selfwhere
F: FnMut(usize, usize) -> N,
Creates a matrix filled with the results of a function applied to each of its component coordinates.
sourcepub fn identity_generic(nrows: R, ncols: C) -> Selfwhere
N: Zero + One,
pub fn identity_generic(nrows: R, ncols: C) -> Selfwhere
N: Zero + One,
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.
sourcepub fn from_diagonal_element_generic(nrows: R, ncols: C, elt: N) -> Selfwhere
N: Zero + One,
pub fn from_diagonal_element_generic(nrows: R, ncols: C, elt: N) -> Selfwhere
N: Zero + One,
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.
sourcepub fn from_partial_diagonal_generic(nrows: R, ncols: C, elts: &[N]) -> Selfwhere
N: Zero,
pub fn from_partial_diagonal_generic(nrows: R, ncols: C, elts: &[N]) -> Selfwhere
N: 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
.
sourcepub fn from_rows<SB>(rows: &[Matrix<N, U1, C, SB>]) -> Selfwhere
SB: Storage<N, U1, C>,
pub fn from_rows<SB>(rows: &[Matrix<N, U1, C, SB>]) -> Selfwhere
SB: Storage<N, U1, C>,
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);
sourcepub fn from_columns<SB>(columns: &[Vector<N, R, SB>]) -> Selfwhere
SB: Storage<N, R>,
pub fn from_columns<SB>(columns: &[Vector<N, R, SB>]) -> Selfwhere
SB: Storage<N, R>,
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);
sourcepub fn new_random_generic(nrows: R, ncols: C) -> Selfwhere
Standard: Distribution<N>,
pub fn new_random_generic(nrows: R, ncols: C) -> Selfwhere
Standard: Distribution<N>,
Creates a matrix filled with random values.
sourcepub fn from_distribution_generic<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
nrows: R,
ncols: C,
distribution: &Distr,
rng: &mut G
) -> Self
pub fn from_distribution_generic<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
nrows: R,
ncols: C,
distribution: &Distr,
rng: &mut G
) -> Self
Creates a matrix filled with random values from the given distribution.
sourcepub fn from_vec_generic(nrows: R, ncols: C, data: Vec<N>) -> Self
pub fn from_vec_generic(nrows: R, ncols: C, data: Vec<N>) -> Self
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_ptr();
// `matrix` is backed by exactly the same `Vec` as it was constructed from.
assert_eq!(matrix_storage_ptr, vec_ptr);
source§impl<N: Scalar, R: DimName, C: DimName> MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
impl<N: Scalar, R: DimName, C: DimName> MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
sourcepub unsafe fn new_uninitialized() -> Self
pub unsafe fn new_uninitialized() -> Self
Creates a new uninitialized matrix or vector.
sourcepub fn from_element(elem: N) -> Self
pub fn from_element(elem: N) -> Self
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);
sourcepub fn repeat(elem: N) -> Self
pub fn repeat(elem: N) -> Self
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);
sourcepub fn zeros() -> Selfwhere
N: Zero,
pub fn zeros() -> Selfwhere
N: Zero,
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);
sourcepub fn from_iterator<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = N>,
pub fn from_iterator<I>(iter: I) -> Selfwhere
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);
sourcepub fn from_row_slice(slice: &[N]) -> Self
pub fn from_row_slice(slice: &[N]) -> Self
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(3, &[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);
sourcepub fn from_column_slice(slice: &[N]) -> Self
pub fn from_column_slice(slice: &[N]) -> Self
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(3, &[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);
sourcepub fn from_fn<F>(f: F) -> Selfwhere
F: FnMut(usize, usize) -> N,
pub fn from_fn<F>(f: F) -> Selfwhere
F: FnMut(usize, usize) -> N,
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);
sourcepub fn identity() -> Selfwhere
N: Zero + One,
pub fn identity() -> Selfwhere
N: Zero + One,
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);
sourcepub fn from_diagonal_element(elt: N) -> Selfwhere
N: Zero + One,
pub fn from_diagonal_element(elt: N) -> Selfwhere
N: Zero + One,
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);
sourcepub fn from_partial_diagonal(elts: &[N]) -> Selfwhere
N: Zero,
pub fn from_partial_diagonal(elts: &[N]) -> Selfwhere
N: 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
.
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);
sourcepub fn from_distribution<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
distribution: &Distr,
rng: &mut G
) -> Self
pub fn from_distribution<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
distribution: &Distr,
rng: &mut G
) -> Self
Creates a matrix or vector filled with random values from the given distribution.
sourcepub fn from_vec(data: Vec<N>) -> Self
pub fn from_vec(data: Vec<N>) -> Self
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);
source§impl<N: Scalar, R: DimName, C: DimName> MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
Standard: Distribution<N>,
impl<N: Scalar, R: DimName, C: DimName> MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
Standard: Distribution<N>,
sourcepub fn new_random() -> Self
pub fn new_random() -> Self
Creates a matrix filled with random values.
source§impl<N: Scalar, R: DimName> MatrixMN<N, R, Dynamic>where
DefaultAllocator: Allocator<N, R, Dynamic>,
impl<N: Scalar, R: DimName> MatrixMN<N, R, Dynamic>where
DefaultAllocator: Allocator<N, R, Dynamic>,
sourcepub unsafe fn new_uninitialized(ncols: usize) -> Self
pub unsafe fn new_uninitialized(ncols: usize) -> Self
Creates a new uninitialized matrix or vector.
sourcepub fn from_element(ncols: usize, elem: N) -> Self
pub fn from_element(ncols: usize, elem: N) -> Self
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);
sourcepub fn repeat(ncols: usize, elem: N) -> Self
pub fn repeat(ncols: usize, elem: N) -> Self
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);
sourcepub fn zeros(ncols: usize) -> Selfwhere
N: Zero,
pub fn zeros(ncols: usize) -> Selfwhere
N: Zero,
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);
sourcepub fn from_iterator<I>(ncols: usize, iter: I) -> Selfwhere
I: IntoIterator<Item = N>,
pub fn from_iterator<I>(ncols: usize, iter: I) -> Selfwhere
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);
sourcepub fn from_row_slice(ncols: usize, slice: &[N]) -> Self
pub fn from_row_slice(ncols: usize, slice: &[N]) -> Self
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(3, &[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);
sourcepub fn from_column_slice(ncols: usize, slice: &[N]) -> Self
pub fn from_column_slice(ncols: usize, slice: &[N]) -> Self
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(3, &[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);
sourcepub fn from_fn<F>(ncols: usize, f: F) -> Selfwhere
F: FnMut(usize, usize) -> N,
pub fn from_fn<F>(ncols: usize, f: F) -> Selfwhere
F: FnMut(usize, usize) -> N,
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);
sourcepub fn identity(ncols: usize) -> Selfwhere
N: Zero + One,
pub fn identity(ncols: usize) -> Selfwhere
N: Zero + One,
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);
sourcepub fn from_diagonal_element(ncols: usize, elt: N) -> Selfwhere
N: Zero + One,
pub fn from_diagonal_element(ncols: usize, elt: N) -> Selfwhere
N: Zero + One,
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);
sourcepub fn from_partial_diagonal(ncols: usize, elts: &[N]) -> Selfwhere
N: Zero,
pub fn from_partial_diagonal(ncols: usize, elts: &[N]) -> Selfwhere
N: 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
.
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);
sourcepub fn from_distribution<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
ncols: usize,
distribution: &Distr,
rng: &mut G
) -> Self
pub fn from_distribution<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
ncols: usize,
distribution: &Distr,
rng: &mut G
) -> Self
Creates a matrix or vector filled with random values from the given distribution.
sourcepub fn from_vec(ncols: usize, data: Vec<N>) -> Self
pub fn from_vec(ncols: usize, data: Vec<N>) -> Self
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);
source§impl<N: Scalar, R: DimName> MatrixMN<N, R, Dynamic>where
DefaultAllocator: Allocator<N, R, Dynamic>,
Standard: Distribution<N>,
impl<N: Scalar, R: DimName> MatrixMN<N, R, Dynamic>where
DefaultAllocator: Allocator<N, R, Dynamic>,
Standard: Distribution<N>,
sourcepub fn new_random(ncols: usize) -> Self
pub fn new_random(ncols: usize) -> Self
Creates a matrix filled with random values.
source§impl<N: Scalar, C: DimName> MatrixMN<N, Dynamic, C>where
DefaultAllocator: Allocator<N, Dynamic, C>,
impl<N: Scalar, C: DimName> MatrixMN<N, Dynamic, C>where
DefaultAllocator: Allocator<N, Dynamic, C>,
sourcepub unsafe fn new_uninitialized(nrows: usize) -> Self
pub unsafe fn new_uninitialized(nrows: usize) -> Self
Creates a new uninitialized matrix or vector.
sourcepub fn from_element(nrows: usize, elem: N) -> Self
pub fn from_element(nrows: usize, elem: N) -> Self
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);
sourcepub fn repeat(nrows: usize, elem: N) -> Self
pub fn repeat(nrows: usize, elem: N) -> Self
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);
sourcepub fn zeros(nrows: usize) -> Selfwhere
N: Zero,
pub fn zeros(nrows: usize) -> Selfwhere
N: Zero,
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);
sourcepub fn from_iterator<I>(nrows: usize, iter: I) -> Selfwhere
I: IntoIterator<Item = N>,
pub fn from_iterator<I>(nrows: usize, iter: I) -> Selfwhere
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);
sourcepub fn from_row_slice(nrows: usize, slice: &[N]) -> Self
pub fn from_row_slice(nrows: usize, slice: &[N]) -> Self
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(3, &[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);
sourcepub fn from_column_slice(nrows: usize, slice: &[N]) -> Self
pub fn from_column_slice(nrows: usize, slice: &[N]) -> Self
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(3, &[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);
sourcepub fn from_fn<F>(nrows: usize, f: F) -> Selfwhere
F: FnMut(usize, usize) -> N,
pub fn from_fn<F>(nrows: usize, f: F) -> Selfwhere
F: FnMut(usize, usize) -> N,
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);
sourcepub fn identity(nrows: usize) -> Selfwhere
N: Zero + One,
pub fn identity(nrows: usize) -> Selfwhere
N: Zero + One,
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);
sourcepub fn from_diagonal_element(nrows: usize, elt: N) -> Selfwhere
N: Zero + One,
pub fn from_diagonal_element(nrows: usize, elt: N) -> Selfwhere
N: Zero + One,
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);
sourcepub fn from_partial_diagonal(nrows: usize, elts: &[N]) -> Selfwhere
N: Zero,
pub fn from_partial_diagonal(nrows: usize, elts: &[N]) -> Selfwhere
N: 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
.
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);
sourcepub fn from_distribution<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
nrows: usize,
distribution: &Distr,
rng: &mut G
) -> Self
pub fn from_distribution<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
nrows: usize,
distribution: &Distr,
rng: &mut G
) -> Self
Creates a matrix or vector filled with random values from the given distribution.
sourcepub fn from_vec(nrows: usize, data: Vec<N>) -> Self
pub fn from_vec(nrows: usize, data: Vec<N>) -> Self
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);
source§impl<N: Scalar, C: DimName> MatrixMN<N, Dynamic, C>where
DefaultAllocator: Allocator<N, Dynamic, C>,
Standard: Distribution<N>,
impl<N: Scalar, C: DimName> MatrixMN<N, Dynamic, C>where
DefaultAllocator: Allocator<N, Dynamic, C>,
Standard: Distribution<N>,
sourcepub fn new_random(nrows: usize) -> Self
pub fn new_random(nrows: usize) -> Self
Creates a matrix filled with random values.
source§impl<N: Scalar> MatrixMN<N, Dynamic, Dynamic>where
DefaultAllocator: Allocator<N, Dynamic, Dynamic>,
impl<N: Scalar> MatrixMN<N, Dynamic, Dynamic>where
DefaultAllocator: Allocator<N, Dynamic, Dynamic>,
sourcepub unsafe fn new_uninitialized(nrows: usize, ncols: usize) -> Self
pub unsafe fn new_uninitialized(nrows: usize, ncols: usize) -> Self
Creates a new uninitialized matrix or vector.
sourcepub fn from_element(nrows: usize, ncols: usize, elem: N) -> Self
pub fn from_element(nrows: usize, ncols: usize, elem: N) -> Self
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);
sourcepub fn repeat(nrows: usize, ncols: usize, elem: N) -> Self
pub fn repeat(nrows: usize, ncols: usize, elem: N) -> Self
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);
sourcepub fn zeros(nrows: usize, ncols: usize) -> Selfwhere
N: Zero,
pub fn zeros(nrows: usize, ncols: usize) -> Selfwhere
N: Zero,
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);
sourcepub fn from_iterator<I>(nrows: usize, ncols: usize, iter: I) -> Selfwhere
I: IntoIterator<Item = N>,
pub fn from_iterator<I>(nrows: usize, ncols: usize, iter: I) -> Selfwhere
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);
sourcepub fn from_row_slice(nrows: usize, ncols: usize, slice: &[N]) -> Self
pub fn from_row_slice(nrows: usize, ncols: usize, slice: &[N]) -> Self
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(3, &[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);
sourcepub fn from_column_slice(nrows: usize, ncols: usize, slice: &[N]) -> Self
pub fn from_column_slice(nrows: usize, ncols: usize, slice: &[N]) -> Self
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(3, &[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);
sourcepub fn from_fn<F>(nrows: usize, ncols: usize, f: F) -> Selfwhere
F: FnMut(usize, usize) -> N,
pub fn from_fn<F>(nrows: usize, ncols: usize, f: F) -> Selfwhere
F: FnMut(usize, usize) -> N,
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);
sourcepub fn identity(nrows: usize, ncols: usize) -> Selfwhere
N: Zero + One,
pub fn identity(nrows: usize, ncols: usize) -> Selfwhere
N: Zero + One,
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);
sourcepub fn from_diagonal_element(nrows: usize, ncols: usize, elt: N) -> Selfwhere
N: Zero + One,
pub fn from_diagonal_element(nrows: usize, ncols: usize, elt: N) -> Selfwhere
N: Zero + One,
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);
sourcepub fn from_partial_diagonal(nrows: usize, ncols: usize, elts: &[N]) -> Selfwhere
N: Zero,
pub fn from_partial_diagonal(nrows: usize, ncols: usize, elts: &[N]) -> Selfwhere
N: 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
.
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);
sourcepub fn from_distribution<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
nrows: usize,
ncols: usize,
distribution: &Distr,
rng: &mut G
) -> Self
pub fn from_distribution<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
nrows: usize,
ncols: usize,
distribution: &Distr,
rng: &mut G
) -> Self
Creates a matrix or vector filled with random values from the given distribution.
sourcepub fn from_vec(nrows: usize, ncols: usize, data: Vec<N>) -> Self
pub fn from_vec(nrows: usize, ncols: usize, data: Vec<N>) -> Self
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);
source§impl<N: Scalar> MatrixMN<N, Dynamic, Dynamic>where
DefaultAllocator: Allocator<N, Dynamic, Dynamic>,
Standard: Distribution<N>,
impl<N: Scalar> MatrixMN<N, Dynamic, Dynamic>where
DefaultAllocator: Allocator<N, Dynamic, Dynamic>,
Standard: Distribution<N>,
sourcepub fn new_random(nrows: usize, ncols: usize) -> Self
pub fn new_random(nrows: usize, ncols: usize) -> Self
Creates a matrix filled with random values.
source§impl<N> MatrixMN<N, U6, U6>where
N: Scalar,
DefaultAllocator: Allocator<N, U6, U6>,
impl<N> MatrixMN<N, U6, U6>where
N: Scalar,
DefaultAllocator: Allocator<N, U6, U6>,
sourcepub 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.
source§impl<N> MatrixMN<N, U5, U6>where
N: Scalar,
DefaultAllocator: Allocator<N, U5, U6>,
impl<N> MatrixMN<N, U5, U6>where
N: Scalar,
DefaultAllocator: Allocator<N, U5, U6>,
sourcepub 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
) -> 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
) -> Self
Initializes this matrix from its components.
source§impl<N> MatrixMN<N, U6, U5>where
N: Scalar,
DefaultAllocator: Allocator<N, U6, U5>,
impl<N> MatrixMN<N, U6, U5>where
N: Scalar,
DefaultAllocator: Allocator<N, U6, U5>,
sourcepub fn new(
m11: N,
m12: N,
m13: N,
m14: N,
m15: N,
m21: N,
m22: N,
m23: N,
m24: N,
m25: N,
m31: N,
m32: N,
m33: N,
m34: N,
m35: N,
m41: N,
m42: N,
m43: N,
m44: N,
m45: N,
m51: N,
m52: N,
m53: N,
m54: N,
m55: N,
m61: N,
m62: N,
m63: N,
m64: N,
m65: N
) -> Self
pub fn new(
m11: N,
m12: N,
m13: N,
m14: N,
m15: N,
m21: N,
m22: N,
m23: N,
m24: N,
m25: N,
m31: N,
m32: N,
m33: N,
m34: N,
m35: N,
m41: N,
m42: N,
m43: N,
m44: N,
m45: N,
m51: N,
m52: N,
m53: N,
m54: N,
m55: N,
m61: N,
m62: N,
m63: N,
m64: N,
m65: N
) -> Self
Initializes this matrix from its components.
Trait Implementations§
source§impl<N, R: DimName, C: DimName> AbstractMagma<Additive> for MatrixMN<N, R, C>where
N: Scalar + ClosedAdd,
DefaultAllocator: Allocator<N, R, C>,
impl<N, R: DimName, C: DimName> AbstractMagma<Additive> for MatrixMN<N, R, C>where
N: Scalar + ClosedAdd,
DefaultAllocator: Allocator<N, R, C>,
source§impl<N, R: DimName, C: DimName> AbstractModule<Additive, Additive, Multiplicative> for MatrixMN<N, R, C>where
N: Scalar + RingCommutative,
DefaultAllocator: Allocator<N, R, C>,
impl<N, R: DimName, C: DimName> AbstractModule<Additive, Additive, Multiplicative> for MatrixMN<N, R, C>where
N: Scalar + RingCommutative,
DefaultAllocator: Allocator<N, R, C>,
§type AbstractRing = N
type AbstractRing = N
source§fn multiply_by(&self, n: N) -> Self
fn multiply_by(&self, n: N) -> Self
source§impl<N, R: DimName, C: DimName> Bounded for MatrixMN<N, R, C>where
N: Scalar + Bounded,
DefaultAllocator: Allocator<N, R, C>,
impl<N, R: DimName, C: DimName> Bounded for MatrixMN<N, R, C>where
N: Scalar + Bounded,
DefaultAllocator: Allocator<N, R, C>,
source§impl<'b, N, R1: DimName, C1: DimName> DivAssign<&'b Rotation<N, C1>> for MatrixMN<N, R1, C1>where
N: Scalar + Zero + One + ClosedAdd + ClosedMul,
DefaultAllocator: Allocator<N, R1, C1> + Allocator<N, C1, C1>,
impl<'b, N, R1: DimName, C1: DimName> DivAssign<&'b Rotation<N, C1>> for MatrixMN<N, R1, C1>where
N: Scalar + Zero + One + ClosedAdd + ClosedMul,
DefaultAllocator: Allocator<N, R1, C1> + Allocator<N, C1, C1>,
source§fn div_assign(&mut self, right: &'b Rotation<N, C1>)
fn div_assign(&mut self, right: &'b Rotation<N, C1>)
/=
operation. Read moresource§impl<N, R1: DimName, C1: DimName> DivAssign<Rotation<N, C1>> for MatrixMN<N, R1, C1>where
N: Scalar + Zero + One + ClosedAdd + ClosedMul,
DefaultAllocator: Allocator<N, R1, C1> + Allocator<N, C1, C1>,
impl<N, R1: DimName, C1: DimName> DivAssign<Rotation<N, C1>> for MatrixMN<N, R1, C1>where
N: Scalar + Zero + One + ClosedAdd + ClosedMul,
DefaultAllocator: Allocator<N, R1, C1> + Allocator<N, C1, C1>,
source§fn div_assign(&mut self, right: Rotation<N, C1>)
fn div_assign(&mut self, right: Rotation<N, C1>)
/=
operation. Read moresource§impl<N: Real, R: DimName, C: DimName> FiniteDimInnerSpace for MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
impl<N: Real, R: DimName, C: DimName> FiniteDimInnerSpace for MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
source§fn orthonormalize(vs: &mut [MatrixMN<N, R, C>]) -> usize
fn orthonormalize(vs: &mut [MatrixMN<N, R, C>]) -> usize
source§impl<N, R: DimName, C: DimName> FiniteDimVectorSpace for MatrixMN<N, R, C>where
N: Scalar + Field,
DefaultAllocator: Allocator<N, R, C>,
impl<N, R: DimName, C: DimName> FiniteDimVectorSpace for MatrixMN<N, R, C>where
N: Scalar + Field,
DefaultAllocator: Allocator<N, R, C>,
source§fn canonical_basis_element(i: usize) -> Self
fn canonical_basis_element(i: usize) -> Self
source§unsafe fn component_unchecked(&self, i: usize) -> &N
unsafe fn component_unchecked(&self, i: usize) -> &N
&self[i]
but without bound-checking.source§unsafe fn component_unchecked_mut(&mut self, i: usize) -> &mut N
unsafe fn component_unchecked_mut(&mut self, i: usize) -> &mut N
&mut self[i]
but without bound-checking.source§impl<N: Scalar> From<[[N; 2]; 2]> for MatrixMN<N, U2, U2>where
DefaultAllocator: Allocator<N, U2, U2>,
impl<N: Scalar> From<[[N; 2]; 2]> for MatrixMN<N, U2, U2>where
DefaultAllocator: Allocator<N, U2, U2>,
source§impl<N: Scalar> From<[[N; 2]; 3]> for MatrixMN<N, U2, U3>where
DefaultAllocator: Allocator<N, U2, U3>,
impl<N: Scalar> From<[[N; 2]; 3]> for MatrixMN<N, U2, U3>where
DefaultAllocator: Allocator<N, U2, U3>,
source§impl<N: Scalar> From<[[N; 2]; 4]> for MatrixMN<N, U2, U4>where
DefaultAllocator: Allocator<N, U2, U4>,
impl<N: Scalar> From<[[N; 2]; 4]> for MatrixMN<N, U2, U4>where
DefaultAllocator: Allocator<N, U2, U4>,
source§impl<N: Scalar> From<[[N; 2]; 5]> for MatrixMN<N, U2, U5>where
DefaultAllocator: Allocator<N, U2, U5>,
impl<N: Scalar> From<[[N; 2]; 5]> for MatrixMN<N, U2, U5>where
DefaultAllocator: Allocator<N, U2, U5>,
source§impl<N: Scalar> From<[[N; 2]; 6]> for MatrixMN<N, U2, U6>where
DefaultAllocator: Allocator<N, U2, U6>,
impl<N: Scalar> From<[[N; 2]; 6]> for MatrixMN<N, U2, U6>where
DefaultAllocator: Allocator<N, U2, U6>,
source§impl<N: Scalar> From<[[N; 3]; 2]> for MatrixMN<N, U3, U2>where
DefaultAllocator: Allocator<N, U3, U2>,
impl<N: Scalar> From<[[N; 3]; 2]> for MatrixMN<N, U3, U2>where
DefaultAllocator: Allocator<N, U3, U2>,
source§impl<N: Scalar> From<[[N; 3]; 3]> for MatrixMN<N, U3, U3>where
DefaultAllocator: Allocator<N, U3, U3>,
impl<N: Scalar> From<[[N; 3]; 3]> for MatrixMN<N, U3, U3>where
DefaultAllocator: Allocator<N, U3, U3>,
source§impl<N: Scalar> From<[[N; 3]; 4]> for MatrixMN<N, U3, U4>where
DefaultAllocator: Allocator<N, U3, U4>,
impl<N: Scalar> From<[[N; 3]; 4]> for MatrixMN<N, U3, U4>where
DefaultAllocator: Allocator<N, U3, U4>,
source§impl<N: Scalar> From<[[N; 3]; 5]> for MatrixMN<N, U3, U5>where
DefaultAllocator: Allocator<N, U3, U5>,
impl<N: Scalar> From<[[N; 3]; 5]> for MatrixMN<N, U3, U5>where
DefaultAllocator: Allocator<N, U3, U5>,
source§impl<N: Scalar> From<[[N; 3]; 6]> for MatrixMN<N, U3, U6>where
DefaultAllocator: Allocator<N, U3, U6>,
impl<N: Scalar> From<[[N; 3]; 6]> for MatrixMN<N, U3, U6>where
DefaultAllocator: Allocator<N, U3, U6>,
source§impl<N: Scalar> From<[[N; 4]; 2]> for MatrixMN<N, U4, U2>where
DefaultAllocator: Allocator<N, U4, U2>,
impl<N: Scalar> From<[[N; 4]; 2]> for MatrixMN<N, U4, U2>where
DefaultAllocator: Allocator<N, U4, U2>,
source§impl<N: Scalar> From<[[N; 4]; 3]> for MatrixMN<N, U4, U3>where
DefaultAllocator: Allocator<N, U4, U3>,
impl<N: Scalar> From<[[N; 4]; 3]> for MatrixMN<N, U4, U3>where
DefaultAllocator: Allocator<N, U4, U3>,
source§impl<N: Scalar> From<[[N; 4]; 4]> for MatrixMN<N, U4, U4>where
DefaultAllocator: Allocator<N, U4, U4>,
impl<N: Scalar> From<[[N; 4]; 4]> for MatrixMN<N, U4, U4>where
DefaultAllocator: Allocator<N, U4, U4>,
source§impl<N: Scalar> From<[[N; 4]; 5]> for MatrixMN<N, U4, U5>where
DefaultAllocator: Allocator<N, U4, U5>,
impl<N: Scalar> From<[[N; 4]; 5]> for MatrixMN<N, U4, U5>where
DefaultAllocator: Allocator<N, U4, U5>,
source§impl<N: Scalar> From<[[N; 4]; 6]> for MatrixMN<N, U4, U6>where
DefaultAllocator: Allocator<N, U4, U6>,
impl<N: Scalar> From<[[N; 4]; 6]> for MatrixMN<N, U4, U6>where
DefaultAllocator: Allocator<N, U4, U6>,
source§impl<N: Scalar> From<[[N; 5]; 2]> for MatrixMN<N, U5, U2>where
DefaultAllocator: Allocator<N, U5, U2>,
impl<N: Scalar> From<[[N; 5]; 2]> for MatrixMN<N, U5, U2>where
DefaultAllocator: Allocator<N, U5, U2>,
source§impl<N: Scalar> From<[[N; 5]; 3]> for MatrixMN<N, U5, U3>where
DefaultAllocator: Allocator<N, U5, U3>,
impl<N: Scalar> From<[[N; 5]; 3]> for MatrixMN<N, U5, U3>where
DefaultAllocator: Allocator<N, U5, U3>,
source§impl<N: Scalar> From<[[N; 5]; 4]> for MatrixMN<N, U5, U4>where
DefaultAllocator: Allocator<N, U5, U4>,
impl<N: Scalar> From<[[N; 5]; 4]> for MatrixMN<N, U5, U4>where
DefaultAllocator: Allocator<N, U5, U4>,
source§impl<N: Scalar> From<[[N; 5]; 5]> for MatrixMN<N, U5, U5>where
DefaultAllocator: Allocator<N, U5, U5>,
impl<N: Scalar> From<[[N; 5]; 5]> for MatrixMN<N, U5, U5>where
DefaultAllocator: Allocator<N, U5, U5>,
source§impl<N: Scalar> From<[[N; 5]; 6]> for MatrixMN<N, U5, U6>where
DefaultAllocator: Allocator<N, U5, U6>,
impl<N: Scalar> From<[[N; 5]; 6]> for MatrixMN<N, U5, U6>where
DefaultAllocator: Allocator<N, U5, U6>,
source§impl<N: Scalar> From<[[N; 6]; 2]> for MatrixMN<N, U6, U2>where
DefaultAllocator: Allocator<N, U6, U2>,
impl<N: Scalar> From<[[N; 6]; 2]> for MatrixMN<N, U6, U2>where
DefaultAllocator: Allocator<N, U6, U2>,
source§impl<N: Scalar> From<[[N; 6]; 3]> for MatrixMN<N, U6, U3>where
DefaultAllocator: Allocator<N, U6, U3>,
impl<N: Scalar> From<[[N; 6]; 3]> for MatrixMN<N, U6, U3>where
DefaultAllocator: Allocator<N, U6, U3>,
source§impl<N: Scalar> From<[[N; 6]; 4]> for MatrixMN<N, U6, U4>where
DefaultAllocator: Allocator<N, U6, U4>,
impl<N: Scalar> From<[[N; 6]; 4]> for MatrixMN<N, U6, U4>where
DefaultAllocator: Allocator<N, U6, U4>,
source§impl<N: Scalar> From<[[N; 6]; 5]> for MatrixMN<N, U6, U5>where
DefaultAllocator: Allocator<N, U6, U5>,
impl<N: Scalar> From<[[N; 6]; 5]> for MatrixMN<N, U6, U5>where
DefaultAllocator: Allocator<N, U6, U5>,
source§impl<N: Scalar> From<[[N; 6]; 6]> for MatrixMN<N, U6, U6>where
DefaultAllocator: Allocator<N, U6, U6>,
impl<N: Scalar> From<[[N; 6]; 6]> for MatrixMN<N, U6, U6>where
DefaultAllocator: Allocator<N, U6, U6>,
source§impl<N> From<[N; 1]> for MatrixMN<N, U1, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U1>,
impl<N> From<[N; 1]> for MatrixMN<N, U1, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U1>,
source§impl<N> From<[N; 10]> for MatrixMN<N, U1, U10>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U10>,
impl<N> From<[N; 10]> for MatrixMN<N, U1, U10>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U10>,
source§impl<N> From<[N; 10]> for MatrixMN<N, U10, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U10, U1>,
impl<N> From<[N; 10]> for MatrixMN<N, U10, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U10, U1>,
source§impl<N> From<[N; 11]> for MatrixMN<N, U1, U11>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U11>,
impl<N> From<[N; 11]> for MatrixMN<N, U1, U11>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U11>,
source§impl<N> From<[N; 11]> for MatrixMN<N, U11, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U11, U1>,
impl<N> From<[N; 11]> for MatrixMN<N, U11, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U11, U1>,
source§impl<N> From<[N; 12]> for MatrixMN<N, U1, U12>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U12>,
impl<N> From<[N; 12]> for MatrixMN<N, U1, U12>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U12>,
source§impl<N> From<[N; 12]> for MatrixMN<N, U12, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U12, U1>,
impl<N> From<[N; 12]> for MatrixMN<N, U12, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U12, U1>,
source§impl<N> From<[N; 13]> for MatrixMN<N, U1, U13>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U13>,
impl<N> From<[N; 13]> for MatrixMN<N, U1, U13>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U13>,
source§impl<N> From<[N; 13]> for MatrixMN<N, U13, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U13, U1>,
impl<N> From<[N; 13]> for MatrixMN<N, U13, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U13, U1>,
source§impl<N> From<[N; 14]> for MatrixMN<N, U1, U14>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U14>,
impl<N> From<[N; 14]> for MatrixMN<N, U1, U14>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U14>,
source§impl<N> From<[N; 14]> for MatrixMN<N, U14, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U14, U1>,
impl<N> From<[N; 14]> for MatrixMN<N, U14, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U14, U1>,
source§impl<N> From<[N; 15]> for MatrixMN<N, U1, U15>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U15>,
impl<N> From<[N; 15]> for MatrixMN<N, U1, U15>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U15>,
source§impl<N> From<[N; 15]> for MatrixMN<N, U15, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U15, U1>,
impl<N> From<[N; 15]> for MatrixMN<N, U15, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U15, U1>,
source§impl<N> From<[N; 16]> for MatrixMN<N, U1, U16>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U16>,
impl<N> From<[N; 16]> for MatrixMN<N, U1, U16>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U16>,
source§impl<N> From<[N; 16]> for MatrixMN<N, U16, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U16, U1>,
impl<N> From<[N; 16]> for MatrixMN<N, U16, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U16, U1>,
source§impl<N> From<[N; 2]> for MatrixMN<N, U1, U2>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U2>,
impl<N> From<[N; 2]> for MatrixMN<N, U1, U2>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U2>,
source§impl<N> From<[N; 2]> for MatrixMN<N, U2, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U2, U1>,
impl<N> From<[N; 2]> for MatrixMN<N, U2, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U2, U1>,
source§impl<N> From<[N; 3]> for MatrixMN<N, U1, U3>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U3>,
impl<N> From<[N; 3]> for MatrixMN<N, U1, U3>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U3>,
source§impl<N> From<[N; 3]> for MatrixMN<N, U3, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U3, U1>,
impl<N> From<[N; 3]> for MatrixMN<N, U3, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U3, U1>,
source§impl<N> From<[N; 4]> for MatrixMN<N, U1, U4>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U4>,
impl<N> From<[N; 4]> for MatrixMN<N, U1, U4>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U4>,
source§impl<N> From<[N; 4]> for MatrixMN<N, U4, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U4, U1>,
impl<N> From<[N; 4]> for MatrixMN<N, U4, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U4, U1>,
source§impl<N> From<[N; 5]> for MatrixMN<N, U1, U5>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U5>,
impl<N> From<[N; 5]> for MatrixMN<N, U1, U5>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U5>,
source§impl<N> From<[N; 5]> for MatrixMN<N, U5, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U5, U1>,
impl<N> From<[N; 5]> for MatrixMN<N, U5, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U5, U1>,
source§impl<N> From<[N; 6]> for MatrixMN<N, U1, U6>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U6>,
impl<N> From<[N; 6]> for MatrixMN<N, U1, U6>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U6>,
source§impl<N> From<[N; 6]> for MatrixMN<N, U6, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U6, U1>,
impl<N> From<[N; 6]> for MatrixMN<N, U6, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U6, U1>,
source§impl<N> From<[N; 7]> for MatrixMN<N, U1, U7>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U7>,
impl<N> From<[N; 7]> for MatrixMN<N, U1, U7>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U7>,
source§impl<N> From<[N; 7]> for MatrixMN<N, U7, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U7, U1>,
impl<N> From<[N; 7]> for MatrixMN<N, U7, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U7, U1>,
source§impl<N> From<[N; 8]> for MatrixMN<N, U1, U8>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U8>,
impl<N> From<[N; 8]> for MatrixMN<N, U1, U8>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U8>,
source§impl<N> From<[N; 8]> for MatrixMN<N, U8, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U8, U1>,
impl<N> From<[N; 8]> for MatrixMN<N, U8, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U8, U1>,
source§impl<N> From<[N; 9]> for MatrixMN<N, U1, U9>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U9>,
impl<N> From<[N; 9]> for MatrixMN<N, U1, U9>where
N: Scalar,
DefaultAllocator: Allocator<N, U1, U9>,
source§impl<N> From<[N; 9]> for MatrixMN<N, U9, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U9, U1>,
impl<N> From<[N; 9]> for MatrixMN<N, U9, U1>where
N: Scalar,
DefaultAllocator: Allocator<N, U9, U1>,
source§impl<N, R: DimName, C: DimName> Identity<Additive> for MatrixMN<N, R, C>where
N: Scalar + Zero,
DefaultAllocator: Allocator<N, R, C>,
impl<N, R: DimName, C: DimName> Identity<Additive> for MatrixMN<N, R, C>where
N: Scalar + Zero,
DefaultAllocator: Allocator<N, R, C>,
source§impl<N: Real, R: DimName, C: DimName> InnerSpace for MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
impl<N: Real, R: DimName, C: DimName> InnerSpace for MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
source§impl<N, R: DimName, C: DimName> Inverse<Additive> for MatrixMN<N, R, C>where
N: Scalar + ClosedNeg,
DefaultAllocator: Allocator<N, R, C>,
impl<N, R: DimName, C: DimName> Inverse<Additive> for MatrixMN<N, R, C>where
N: Scalar + ClosedNeg,
DefaultAllocator: Allocator<N, R, C>,
source§impl<N, R: Dim, C: Dim> JoinSemilattice for MatrixMN<N, R, C>where
N: Scalar + JoinSemilattice,
DefaultAllocator: Allocator<N, R, C>,
impl<N, R: Dim, C: Dim> JoinSemilattice for MatrixMN<N, R, C>where
N: Scalar + JoinSemilattice,
DefaultAllocator: Allocator<N, R, C>,
source§impl<N, R: Dim, C: Dim> Lattice for MatrixMN<N, R, C>where
N: Scalar + Lattice,
DefaultAllocator: Allocator<N, R, C>,
impl<N, R: Dim, C: Dim> Lattice for MatrixMN<N, R, C>where
N: Scalar + Lattice,
DefaultAllocator: Allocator<N, R, C>,
source§fn meet_join(&self, other: &Self) -> (Self, Self)
fn meet_join(&self, other: &Self) -> (Self, Self)
source§fn partial_min<'a>(&'a self, other: &'a Self) -> Option<&'a Self>
fn partial_min<'a>(&'a self, other: &'a Self) -> Option<&'a Self>
self
and other
if they are comparable.source§fn partial_max<'a>(&'a self, other: &'a Self) -> Option<&'a Self>
fn partial_max<'a>(&'a self, other: &'a Self) -> Option<&'a Self>
self
and other
if they are comparable.source§impl<N, R: Dim, C: Dim> MeetSemilattice for MatrixMN<N, R, C>where
N: Scalar + MeetSemilattice,
DefaultAllocator: Allocator<N, R, C>,
impl<N, R: Dim, C: Dim> MeetSemilattice for MatrixMN<N, R, C>where
N: Scalar + MeetSemilattice,
DefaultAllocator: Allocator<N, R, C>,
source§impl<N, R: DimName, C: DimName> Module for MatrixMN<N, R, C>where
N: Scalar + RingCommutative,
DefaultAllocator: Allocator<N, R, C>,
impl<N, R: DimName, C: DimName> Module for MatrixMN<N, R, C>where
N: Scalar + RingCommutative,
DefaultAllocator: Allocator<N, R, C>,
source§impl<'b, N, R1: DimName, C1: DimName> MulAssign<&'b Rotation<N, C1>> for MatrixMN<N, R1, C1>where
N: Scalar + Zero + One + ClosedAdd + ClosedMul,
DefaultAllocator: Allocator<N, R1, C1> + Allocator<N, C1, C1>,
impl<'b, N, R1: DimName, C1: DimName> MulAssign<&'b Rotation<N, C1>> for MatrixMN<N, R1, C1>where
N: Scalar + Zero + One + ClosedAdd + ClosedMul,
DefaultAllocator: Allocator<N, R1, C1> + Allocator<N, C1, C1>,
source§fn mul_assign(&mut self, right: &'b Rotation<N, C1>)
fn mul_assign(&mut self, right: &'b Rotation<N, C1>)
*=
operation. Read moresource§impl<N, R1: DimName, C1: DimName> MulAssign<Rotation<N, C1>> for MatrixMN<N, R1, C1>where
N: Scalar + Zero + One + ClosedAdd + ClosedMul,
DefaultAllocator: Allocator<N, R1, C1> + Allocator<N, C1, C1>,
impl<N, R1: DimName, C1: DimName> MulAssign<Rotation<N, C1>> for MatrixMN<N, R1, C1>where
N: Scalar + Zero + One + ClosedAdd + ClosedMul,
DefaultAllocator: Allocator<N, R1, C1> + Allocator<N, C1, C1>,
source§fn mul_assign(&mut self, right: Rotation<N, C1>)
fn mul_assign(&mut self, right: Rotation<N, C1>)
*=
operation. Read moresource§impl<N: Real, R: DimName, C: DimName> NormedSpace for MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
impl<N: Real, R: DimName, C: DimName> NormedSpace for MatrixMN<N, R, C>where
DefaultAllocator: Allocator<N, R, C>,
source§fn norm_squared(&self) -> N
fn norm_squared(&self) -> N
source§fn normalize_mut(&mut self) -> N
fn normalize_mut(&mut self) -> N
source§fn try_normalize(&self, min_norm: N) -> Option<Self>
fn try_normalize(&self, min_norm: N) -> Option<Self>
eps
.source§fn try_normalize_mut(&mut self, min_norm: N) -> Option<N>
fn try_normalize_mut(&mut self, min_norm: N) -> Option<N>
eps
. Read moresource§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>,
source§fn to_superset(&self) -> MatrixMN<N2, R2, C2>
fn to_superset(&self) -> MatrixMN<N2, R2, C2>
self
to the equivalent element of its superset.source§fn is_in_subset(m: &MatrixMN<N2, R2, C2>) -> bool
fn is_in_subset(m: &MatrixMN<N2, R2, C2>) -> bool
element
is actually part of the subset Self
(and can be converted to it).source§unsafe fn from_superset_unchecked(m: &MatrixMN<N2, R2, C2>) -> Self
unsafe fn from_superset_unchecked(m: &MatrixMN<N2, R2, C2>) -> Self
self.to_superset
but without any property checks. Always succeeds.