Type Alias nalgebra::base::OMatrix

source ·
pub type OMatrix<T, R, C> = Matrix<T, R, C, Owned<T, R, C>>;
Expand description

An owned matrix 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.

Aliased Type§

struct OMatrix<T, R, C> {
    pub data: <DefaultAllocator as Allocator<T, R, C>>::Buffer,
    /* private fields */
}

Fields§

§data: <DefaultAllocator as Allocator<T, R, C>>::Buffer

The data storage that contains all the matrix components. Disappointed?

Well, if you came here to see how you can access the matrix components, you may be in luck: you can access the individual components of all vectors with compile-time dimensions <= 6 using field notation like this: vec.x, vec.y, vec.z, vec.w, vec.a, vec.b. Reference and assignation work too:

let mut vec = Vector3::new(1.0, 2.0, 3.0);
vec.x = 10.0;
vec.y += 30.0;
assert_eq!(vec.x, 10.0);
assert_eq!(vec.y + 100.0, 132.0);

Similarly, for matrices with compile-time dimensions <= 6, you can use field notation like this: mat.m11, mat.m42, etc. The first digit identifies the row to address and the second digit identifies the column to address. So mat.m13 identifies the component at the first row and third column (note that the count of rows and columns start at 1 instead of 0 here. This is so we match the mathematical notation).

For all matrices and vectors, independently from their size, individual components can be accessed and modified using indexing: vec[20], mat[(20, 19)]. Here the indexing starts at 0 as you would expect.

Implementations§

source§

impl<T, D: DimName> OMatrix<T, D, D>
where T: Scalar + Zero + One, DefaultAllocator: Allocator<T, D, D>,

§Translation and scaling in any dimension

source

pub fn new_scaling(scaling: T) -> Self

Creates a new homogeneous matrix that applies the same scaling factor on each dimension.

source

pub fn new_nonuniform_scaling<SB>( scaling: &Vector<T, DimNameDiff<D, U1>, SB> ) -> Self
where D: DimNameSub<U1>, SB: Storage<T, DimNameDiff<D, U1>>,

Creates a new homogeneous matrix that applies a distinct scaling factor for each dimension.

source

pub fn new_translation<SB>( translation: &Vector<T, DimNameDiff<D, U1>, SB> ) -> Self
where D: DimNameSub<U1>, SB: Storage<T, DimNameDiff<D, U1>>,

Creates a new homogeneous matrix that applies a pure translation.

source§

impl<T: Scalar, R: Dim, C: Dim> OMatrix<T, R, C>
where DefaultAllocator: Allocator<T, R, C>,

§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.

source

pub fn from_element_generic(nrows: R, ncols: C, elem: T) -> Self

Creates a matrix with all its elements set to elem.

source

pub fn repeat_generic(nrows: R, ncols: C, elem: T) -> Self

Creates a matrix with all its elements set to elem.

Same as from_element_generic.

source

pub fn zeros_generic(nrows: R, ncols: C) -> Self
where T: Zero,

Creates a matrix with all its elements set to 0.

source

pub fn from_iterator_generic<I>(nrows: R, ncols: C, iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a matrix with all its elements filled by an iterator.

source

pub fn from_row_iterator_generic<I>(nrows: R, ncols: C, iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a matrix with all its elements filled by an row-major order iterator.

source

pub fn from_row_slice_generic(nrows: R, ncols: C, slice: &[T]) -> 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.

source

pub fn from_column_slice_generic(nrows: R, ncols: C, slice: &[T]) -> 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).

source

pub fn from_fn_generic<F>(nrows: R, ncols: C, f: F) -> Self
where F: FnMut(usize, usize) -> T,

Creates a matrix filled with the results of a function applied to each of its component coordinates.

source

pub fn identity_generic(nrows: R, ncols: C) -> Self
where T: 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.

source

pub fn from_diagonal_element_generic(nrows: R, ncols: C, elt: T) -> Self
where T: 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.

source

pub fn from_partial_diagonal_generic(nrows: R, ncols: C, elts: &[T]) -> Self
where T: 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.

source

pub fn from_rows<SB>(rows: &[Matrix<T, Const<1>, C, SB>]) -> Self
where SB: RawStorage<T, Const<1>, 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);
source

pub fn from_columns<SB>(columns: &[Vector<T, R, SB>]) -> Self
where SB: RawStorage<T, 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);
source

pub fn new_random_generic(nrows: R, ncols: C) -> Self

Creates a matrix filled with random values.

source

pub fn from_distribution_generic<Distr: Distribution<T> + ?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.

source

pub fn from_vec_generic(nrows: R, ncols: C, data: Vec<T>) -> 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(Dyn(vec.len()), Const::<1>, 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);
source§

impl<T, D: Dim> OMatrix<T, D, D>
where T: Scalar, DefaultAllocator: Allocator<T, D, D>,

source

pub fn from_diagonal<SB: RawStorage<T, D>>(diag: &Vector<T, D, SB>) -> Self
where T: Zero,

Creates a square matrix with its diagonal set to diag and all other entries set to 0.

§Example

let m = Matrix3::from_diagonal(&Vector3::new(1.0, 2.0, 3.0));
// The two additional arguments represent the matrix dimensions.
let dm = DMatrix::from_diagonal(&DVector::from_row_slice(&[1.0, 2.0, 3.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 == 3.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)] == 3.0);
source§

impl<T: Scalar, R: DimName, C: DimName> OMatrix<T, R, C>
where DefaultAllocator: Allocator<T, R, C>,

§Constructors of statically-sized vectors or statically-sized matrices

source

pub fn from_element(elem: T) -> 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);
source

pub fn repeat(elem: T) -> 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);
source

pub fn zeros() -> Self
where T: 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);
source

pub fn from_iterator<I>(iter: I) -> Self
where I: IntoIterator<Item = T>,

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);
source

pub fn from_row_iterator<I>(iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a matrix or vector with all its elements filled by a row-major iterator.

The output matrix is filled row-by-row.

§Example

let v = Vector3::from_row_iterator((0..3).into_iter());
// The additional argument represents the vector dimension.
let dv = DVector::from_row_iterator(3, (0..3).into_iter());
let m = Matrix2x3::from_row_iterator((0..6).into_iter());
// The two additional arguments represent the matrix dimensions.
let dm = DMatrix::from_row_iterator(2, 3, (0..6).into_iter());

// For Vectors from_row_iterator is identical to from_iterator
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);
source

pub fn from_fn<F>(f: F) -> Self
where F: FnMut(usize, usize) -> T,

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);
source

pub fn identity() -> Self
where T: 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);
source

pub fn from_diagonal_element(elt: T) -> Self
where T: 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);
source

pub fn from_partial_diagonal(elts: &[T]) -> Self
where T: 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);
source

pub fn from_distribution<Distr: Distribution<T> + ?Sized, G: Rng + ?Sized>( distribution: &Distr, rng: &mut G ) -> Self

Creates a matrix or vector filled with random values from the given distribution.

source

pub fn new_random() -> Self

Creates a matrix filled with random values.

source§

impl<T: Scalar, R: DimName> OMatrix<T, R, Dyn>

§Constructors of matrices with a dynamic number of columns

source

pub fn from_element(ncols: usize, elem: T) -> 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);
source

pub fn repeat(ncols: usize, elem: T) -> 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);
source

pub fn zeros(ncols: usize) -> Self
where T: 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);
source

pub fn from_iterator<I>(ncols: usize, iter: I) -> Self
where I: IntoIterator<Item = T>,

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);
source

pub fn from_row_iterator<I>(ncols: usize, iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a matrix or vector with all its elements filled by a row-major iterator.

The output matrix is filled row-by-row.

§Example

let v = Vector3::from_row_iterator((0..3).into_iter());
// The additional argument represents the vector dimension.
let dv = DVector::from_row_iterator(3, (0..3).into_iter());
let m = Matrix2x3::from_row_iterator((0..6).into_iter());
// The two additional arguments represent the matrix dimensions.
let dm = DMatrix::from_row_iterator(2, 3, (0..6).into_iter());

// For Vectors from_row_iterator is identical to from_iterator
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);
source

pub fn from_fn<F>(ncols: usize, f: F) -> Self
where F: FnMut(usize, usize) -> T,

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);
source

pub fn identity(ncols: usize) -> Self
where T: 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);
source

pub fn from_diagonal_element(ncols: usize, elt: T) -> Self
where T: 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);
source

pub fn from_partial_diagonal(ncols: usize, elts: &[T]) -> Self
where T: 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);
source

pub fn from_distribution<Distr: Distribution<T> + ?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.

source

pub fn new_random(ncols: usize) -> Self

Creates a matrix filled with random values.

source§

impl<T: Scalar, C: DimName> OMatrix<T, Dyn, C>

§Constructors of dynamic vectors and matrices with a dynamic number of rows

source

pub fn from_element(nrows: usize, elem: T) -> 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);
source

pub fn repeat(nrows: usize, elem: T) -> 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);
source

pub fn zeros(nrows: usize) -> Self
where T: 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);
source

pub fn from_iterator<I>(nrows: usize, iter: I) -> Self
where I: IntoIterator<Item = T>,

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);
source

pub fn from_row_iterator<I>(nrows: usize, iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a matrix or vector with all its elements filled by a row-major iterator.

The output matrix is filled row-by-row.

§Example

let v = Vector3::from_row_iterator((0..3).into_iter());
// The additional argument represents the vector dimension.
let dv = DVector::from_row_iterator(3, (0..3).into_iter());
let m = Matrix2x3::from_row_iterator((0..6).into_iter());
// The two additional arguments represent the matrix dimensions.
let dm = DMatrix::from_row_iterator(2, 3, (0..6).into_iter());

// For Vectors from_row_iterator is identical to from_iterator
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);
source

pub fn from_fn<F>(nrows: usize, f: F) -> Self
where F: FnMut(usize, usize) -> T,

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);
source

pub fn identity(nrows: usize) -> Self
where T: 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);
source

pub fn from_diagonal_element(nrows: usize, elt: T) -> Self
where T: 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);
source

pub fn from_partial_diagonal(nrows: usize, elts: &[T]) -> Self
where T: 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);
source

pub fn from_distribution<Distr: Distribution<T> + ?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.

source

pub fn new_random(nrows: usize) -> Self

Creates a matrix filled with random values.

source§

impl<T: Scalar> OMatrix<T, Dyn, Dyn>

§Constructors of fully dynamic matrices

source

pub fn from_element(nrows: usize, ncols: usize, elem: T) -> 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);
source

pub fn repeat(nrows: usize, ncols: usize, elem: T) -> 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);
source

pub fn zeros(nrows: usize, ncols: usize) -> Self
where T: 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);
source

pub fn from_iterator<I>(nrows: usize, ncols: usize, iter: I) -> Self
where I: IntoIterator<Item = T>,

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);
source

pub fn from_row_iterator<I>(nrows: usize, ncols: usize, iter: I) -> Self
where I: IntoIterator<Item = T>,

Creates a matrix or vector with all its elements filled by a row-major iterator.

The output matrix is filled row-by-row.

§Example

let v = Vector3::from_row_iterator((0..3).into_iter());
// The additional argument represents the vector dimension.
let dv = DVector::from_row_iterator(3, (0..3).into_iter());
let m = Matrix2x3::from_row_iterator((0..6).into_iter());
// The two additional arguments represent the matrix dimensions.
let dm = DMatrix::from_row_iterator(2, 3, (0..6).into_iter());

// For Vectors from_row_iterator is identical to from_iterator
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);
source

pub fn from_fn<F>(nrows: usize, ncols: usize, f: F) -> Self
where F: FnMut(usize, usize) -> T,

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);
source

pub fn identity(nrows: usize, ncols: usize) -> Self
where T: 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);
source

pub fn from_diagonal_element(nrows: usize, ncols: usize, elt: T) -> Self
where T: 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);
source

pub fn from_partial_diagonal(nrows: usize, ncols: usize, elts: &[T]) -> Self
where T: 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);
source

pub fn from_distribution<Distr: Distribution<T> + ?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.

source

pub fn new_random(nrows: usize, ncols: usize) -> Self

Creates a matrix filled with random values.

source§

impl<T: Scalar, R: DimName, C: DimName> OMatrix<T, R, C>
where DefaultAllocator: Allocator<T, R, C>,

source

pub fn from_row_slice(data: &[T]) -> 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(&[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);
source

pub fn from_column_slice(data: &[T]) -> 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(&[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);
source

pub fn from_vec(data: Vec<T>) -> 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<T: Scalar, R: DimName> OMatrix<T, R, Dyn>

source

pub fn from_row_slice(data: &[T]) -> 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(&[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);
source

pub fn from_column_slice(data: &[T]) -> 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(&[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);
source

pub fn from_vec(data: Vec<T>) -> 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<T: Scalar, C: DimName> OMatrix<T, Dyn, C>

source

pub fn from_row_slice(data: &[T]) -> 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(&[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);
source

pub fn from_column_slice(data: &[T]) -> 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(&[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);
source

pub fn from_vec(data: Vec<T>) -> 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<T: Scalar> OMatrix<T, Dyn, Dyn>

source

pub fn from_row_slice(nrows: usize, ncols: usize, data: &[T]) -> 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(&[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);
source

pub fn from_column_slice(nrows: usize, ncols: usize, data: &[T]) -> 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(&[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);
source

pub fn from_vec(nrows: usize, ncols: usize, data: Vec<T>) -> 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<T: Scalar> OMatrix<T, Dyn, Dyn>

§In-place resizing

source

pub fn resize_mut(&mut self, new_nrows: usize, new_ncols: usize, val: T)

Resizes this matrix in-place.

The values are copied such that self[(i, j)] == result[(i, j)]. If the result has more rows and/or columns than self, then the extra rows or columns are filled with val.

Defined only for owned fully-dynamic matrices, i.e., DMatrix.

source§

impl<T: Scalar, C: Dim> OMatrix<T, Dyn, C>

source

pub fn resize_vertically_mut(&mut self, new_nrows: usize, val: T)
where DefaultAllocator: Reallocator<T, Dyn, C, Dyn, 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).

source§

impl<T: Scalar, R: Dim> OMatrix<T, R, Dyn>

source

pub fn resize_horizontally_mut(&mut self, new_ncols: usize, val: T)
where DefaultAllocator: Reallocator<T, R, Dyn, R, Dyn>,

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).

source§

impl<T: ComplexField, D> OMatrix<T, D, D>
where D: DimMin<D, Output = D>, DefaultAllocator: Allocator<T, D, D> + Allocator<(usize, usize), DimMinimum<D, D>> + Allocator<T, D> + Allocator<T::RealField, D> + Allocator<T::RealField, D, D>,

source

pub fn exp(&self) -> Self

Computes exponential of this matrix

Trait Implementations§

source§

impl<T, R: DimName, C: DimName> AbstractMagma<Additive> for OMatrix<T, R, C>

source§

fn operate(&self, other: &Self) -> Self

Performs an operation.
source§

fn op(&self, _: O, lhs: &Self) -> Self

Performs specific operation.
source§

impl<T, D: DimName> AbstractMagma<Multiplicative> for OMatrix<T, D, D>

source§

fn operate(&self, other: &Self) -> Self

Performs an operation.
source§

fn op(&self, _: O, lhs: &Self) -> Self

Performs specific operation.
source§

impl<T, R: DimName, C: DimName> AbstractModule for OMatrix<T, R, C>

§

type AbstractRing = T

The underlying scalar field.
source§

fn multiply_by(&self, n: T) -> Self

Multiplies an element of the ring with an element of the module.
source§

impl<T, R, C> Arbitrary for OMatrix<T, R, C>
where R: Dim, C: Dim, T: Scalar + Arbitrary + Send, DefaultAllocator: Allocator<T, R, C>, Owned<T, R, C>: Clone + Send,

source§

fn arbitrary(g: &mut Gen) -> Self

Return an arbitrary value. Read more
source§

fn shrink(&self) -> Box<dyn Iterator<Item = Self>>

Return an iterator of values that are smaller than itself. Read more
source§

impl<T, R, C> Arbitrary for OMatrix<T, R, C>

§

type Parameters = MatrixParameters<<T as Arbitrary>::Parameters, R, C>

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
source§

fn arbitrary_with(args: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
§

type Strategy = MatrixStrategy<<T as Arbitrary>::Strategy, R, C>

The type of Strategy used to generate values of type Self.
source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
source§

impl<T, R: DimName, C: DimName> Bounded for OMatrix<T, R, C>
where T: Scalar + Bounded, DefaultAllocator: Allocator<T, R, C>,

source§

fn max_value() -> Self

Returns the largest finite number this type can represent
source§

fn min_value() -> Self

Returns the smallest finite number this type can represent
source§

impl<T: ComplexField + ComplexField<RealField = <T as ComplexField>::RealField>, R: DimName, C: DimName> FiniteDimInnerSpace for OMatrix<T, R, C>

source§

fn orthonormalize(vs: &mut [Self]) -> usize

Orthonormalizes the given family of vectors. The largest free family of vectors is moved at the beginning of the array and its size is returned. Vectors at an indices larger or equal to this length can be modified to an arbitrary value.
source§

fn orthonormal_subspace_basis<F>(vs: &[Self], f: F)
where F: FnMut(&Self) -> bool,

Applies the given closure to each element of the orthonormal basis of the subspace orthogonal to free family of vectors vs. If vs is not a free family, the result is unspecified.
source§

impl<T, R: DimName, C: DimName> FiniteDimVectorSpace for OMatrix<T, R, C>
where T: Scalar + Field, DefaultAllocator: Allocator<T, R, C>,

source§

fn dimension() -> usize

The vector space dimension.
source§

fn canonical_basis_element(i: usize) -> Self

The i-the canonical basis element.
source§

fn dot(&self, other: &Self) -> T

The dot product between two vectors.
source§

unsafe fn component_unchecked(&self, i: usize) -> &T

Same as &self[i] but without bound-checking.
source§

unsafe fn component_unchecked_mut(&mut self, i: usize) -> &mut T

Same as &mut self[i] but without bound-checking.
source§

fn canonical_basis<F>(f: F)
where F: FnMut(&Self) -> bool,

Applies the given closule to each element of this vector space’s canonical basis. Stops if f returns false.
source§

impl<T, R: Dim, C: Dim> From<[Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>; 16]> for OMatrix<T, R, C>

source§

fn from(arr: [OMatrix<T::Element, R, C>; 16]) -> Self

Converts to this type from the input type.
source§

impl<T, R: Dim, C: Dim> From<[Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>; 2]> for OMatrix<T, R, C>

source§

fn from(arr: [OMatrix<T::Element, R, C>; 2]) -> Self

Converts to this type from the input type.
source§

impl<T, R: Dim, C: Dim> From<[Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>; 4]> for OMatrix<T, R, C>

source§

fn from(arr: [OMatrix<T::Element, R, C>; 4]) -> Self

Converts to this type from the input type.
source§

impl<T, R: Dim, C: Dim> From<[Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>; 8]> for OMatrix<T, R, C>

source§

fn from(arr: [OMatrix<T::Element, R, C>; 8]) -> Self

Converts to this type from the input type.
source§

impl<T> From<ColumnMatrix2<T>> for OMatrix<T, U2, U2>

source§

fn from(m: ColumnMatrix2<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<ColumnMatrix2x3<T>> for OMatrix<T, U2, U3>

source§

fn from(m: ColumnMatrix2x3<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<ColumnMatrix3<T>> for OMatrix<T, U3, U3>

source§

fn from(m: ColumnMatrix3<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<ColumnMatrix3x4<T>> for OMatrix<T, U3, U4>

source§

fn from(m: ColumnMatrix3x4<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<ColumnMatrix4<T>> for OMatrix<T, U4, U4>

source§

fn from(m: ColumnMatrix4<T>) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Scalar + Zero, R: Dim, C: Dim, S> From<CsMatrix<T, R, C, S>> for OMatrix<T, R, C>
where S: CsStorage<T, R, C>, DefaultAllocator: Allocator<T, R, C>,

source§

fn from(m: CsMatrix<T, R, C, S>) -> Self

Converts to this type from the input type.
source§

impl<T: SimdRealField, R, const D: usize> From<Isometry<T, R, D>> for OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>

source§

fn from(iso: Isometry<T, R, D>) -> Self

Converts to this type from the input type.
source§

impl<T: Scalar + Zero + One, const D: usize> From<Scale<T, D>> for OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>

source§

fn from(t: Scale<T, D>) -> Self

Converts to this type from the input type.
source§

impl<T: SimdRealField, R, const D: usize> From<Similarity<T, R, D>> for OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>

source§

fn from(sim: Similarity<T, R, D>) -> Self

Converts to this type from the input type.
source§

impl<T: RealField, C, const D: usize> From<Transform<T, C, D>> for OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>

source§

fn from(t: Transform<T, C, D>) -> Self

Converts to this type from the input type.
source§

impl<T: Scalar + Zero + One, const D: usize> From<Translation<T, D>> for OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>

source§

fn from(t: Translation<T, D>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Vector2<T>> for OMatrix<T, U2, U1>

source§

fn from(v: Vector2<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Vector3<T>> for OMatrix<T, U3, U1>

source§

fn from(v: Vector3<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Vector4<T>> for OMatrix<T, U4, U1>

source§

fn from(v: Vector4<T>) -> Self

Converts to this type from the input type.
source§

impl<T, R: DimName, C: DimName> Identity<Additive> for OMatrix<T, R, C>
where T: Scalar + Zero, DefaultAllocator: Allocator<T, R, C>,

source§

fn identity() -> Self

The identity element.
source§

fn id(_: O) -> Self
where Self: Sized,

Specific identity.
source§

impl<T, D: DimName> Identity<Multiplicative> for OMatrix<T, D, D>
where T: Scalar + Zero + One, DefaultAllocator: Allocator<T, D, D>,

source§

fn identity() -> Self

The identity element.
source§

fn id(_: O) -> Self
where Self: Sized,

Specific identity.
source§

impl<T: ComplexField + ComplexField<RealField = <T as ComplexField>::RealField>, R: DimName, C: DimName> InnerSpace for OMatrix<T, R, C>

source§

fn angle(&self, other: &Self) -> <T as ComplexField>::RealField

Measures the angle between two vectors.
source§

fn inner_product(&self, other: &Self) -> T

Computes the inner product of self with other.
source§

impl<T> Into<ColumnMatrix2<T>> for OMatrix<T, U2, U2>

source§

fn into(self) -> ColumnMatrix2<T>

Converts this type into the (usually inferred) input type.
source§

impl<T> Into<ColumnMatrix2x3<T>> for OMatrix<T, U2, U3>

source§

fn into(self) -> ColumnMatrix2x3<T>

Converts this type into the (usually inferred) input type.
source§

impl<T> Into<ColumnMatrix3<T>> for OMatrix<T, U3, U3>

source§

fn into(self) -> ColumnMatrix3<T>

Converts this type into the (usually inferred) input type.
source§

impl<T> Into<ColumnMatrix3x4<T>> for OMatrix<T, U3, U4>

source§

fn into(self) -> ColumnMatrix3x4<T>

Converts this type into the (usually inferred) input type.
source§

impl<T> Into<ColumnMatrix4<T>> for OMatrix<T, U4, U4>

source§

fn into(self) -> ColumnMatrix4<T>

Converts this type into the (usually inferred) input type.
source§

impl<T, R: Dim, C: Dim> JoinSemilattice for OMatrix<T, R, C>

source§

fn join(&self, other: &Self) -> Self

Returns the join (aka. supremum) of two values.
source§

impl<T, R: Dim, C: Dim> Lattice for OMatrix<T, R, C>
where T: Scalar + Lattice, DefaultAllocator: Allocator<T, R, C>,

source§

fn meet_join(&self, other: &Self) -> (Self, Self)

Returns the infimum and the supremum simultaneously.
source§

fn partial_min<'a>(&'a self, other: &'a Self) -> Option<&'a Self>

Return the minimum of self and other if they are comparable.
source§

fn partial_max<'a>(&'a self, other: &'a Self) -> Option<&'a Self>

Return the maximum of self and other if they are comparable.
source§

fn partial_sort2<'a>(&'a self, other: &'a Self) -> Option<(&'a Self, &'a Self)>

Sorts two values in increasing order using a partial ordering.
source§

fn partial_clamp<'a>(&'a self, min: &'a Self, max: &'a Self) -> Option<&'a Self>

Clamp value between min and max. Returns None if value is not comparable to min or max.
source§

impl<T, R: Dim, C: Dim> MeetSemilattice for OMatrix<T, R, C>

source§

fn meet(&self, other: &Self) -> Self

Returns the meet (aka. infimum) of two values.
source§

impl<T, R: DimName, C: DimName> Module for OMatrix<T, R, C>

§

type Ring = T

The underlying scalar field.
source§

impl<T: SimdComplexField, R: Dim, C: Dim> Normed for OMatrix<T, R, C>
where DefaultAllocator: Allocator<T, R, C>,

§

type Norm = <T as SimdComplexField>::SimdRealField

The type of the norm.
source§

fn norm(&self) -> T::SimdRealField

Computes the norm.
source§

fn norm_squared(&self) -> T::SimdRealField

Computes the squared norm.
source§

fn scale_mut(&mut self, n: Self::Norm)

Multiply self by n.
source§

fn unscale_mut(&mut self, n: Self::Norm)

Divides self by n.
source§

impl<T: ComplexField + ComplexField<RealField = <T as ComplexField>::RealField>, R: DimName, C: DimName> NormedSpace for OMatrix<T, R, C>

§

type RealField = <T as ComplexField>::RealField

The result of the norm (not necessarily the same same as the field used by this vector space).
§

type ComplexField = T

The field of this space must be this complex number.
source§

fn norm_squared(&self) -> <T as ComplexField>::RealField

The squared norm of this vector.
source§

fn norm(&self) -> <T as ComplexField>::RealField

The norm of this vector.
source§

fn normalize(&self) -> Self

Returns a normalized version of this vector.
source§

fn normalize_mut(&mut self) -> <T as ComplexField>::RealField

Normalizes this vector in-place and returns its norm.
source§

fn try_normalize( &self, min_norm: <T as ComplexField>::RealField ) -> Option<Self>

Returns a normalized version of this vector unless its norm as smaller or equal to eps.
source§

fn try_normalize_mut( &mut self, min_norm: <T as ComplexField>::RealField ) -> Option<<T as ComplexField>::RealField>

Normalizes this vector in-place or does nothing if its norm is smaller or equal to eps. Read more
source§

impl<T, D: DimName> One for OMatrix<T, D, D>

source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
source§

impl<'a, T, D: DimName> Product<&'a Matrix<T, D, D, <DefaultAllocator as Allocator<T, D, D>>::Buffer>> for OMatrix<T, D, D>

source§

fn product<I: Iterator<Item = &'a OMatrix<T, D, D>>>( iter: I ) -> OMatrix<T, D, D>

Method which takes an iterator and generates Self from the elements by multiplying the items.
source§

impl<T, D: DimName> Product for OMatrix<T, D, D>

source§

fn product<I: Iterator<Item = OMatrix<T, D, D>>>(iter: I) -> OMatrix<T, D, D>

Method which takes an iterator and generates Self from the elements by multiplying the items.
source§

impl<T, R, C> SimdValue for OMatrix<T, R, C>
where T: Scalar + SimdValue, R: Dim, C: Dim, T::Element: Scalar, DefaultAllocator: Allocator<T, R, C> + Allocator<T::Element, R, C>,

§

type Element = Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>

The type of the elements of each lane of this SIMD value.
§

type SimdBool = <T as SimdValue>::SimdBool

Type of the result of comparing two SIMD values like self.
source§

fn lanes() -> usize

The number of lanes of this SIMD value.
source§

fn splat(val: Self::Element) -> Self

Initializes an SIMD value with each lanes set to val.
source§

fn extract(&self, i: usize) -> Self::Element

Extracts the i-th lane of self. Read more
source§

unsafe fn extract_unchecked(&self, i: usize) -> Self::Element

Extracts the i-th lane of self without bound-checking.
source§

fn replace(&mut self, i: usize, val: Self::Element)

Replaces the i-th lane of self by val. Read more
source§

unsafe fn replace_unchecked(&mut self, i: usize, val: Self::Element)

Replaces the i-th lane of self by val without bound-checking.
source§

fn select(self, cond: Self::SimdBool, other: Self) -> Self

Merges self and other depending on the lanes of cond. Read more
source§

fn map_lanes(self, f: impl Fn(Self::Element) -> Self::Element) -> Self
where Self: Clone,

Applies a function to each lane of self. Read more
source§

fn zip_map_lanes( self, b: Self, f: impl Fn(Self::Element, Self::Element) -> Self::Element ) -> Self
where Self: Clone,

Applies a function to each lane of self paired with the corresponding lane of b. Read more
source§

impl<T1, T2, R1, C1, R2, C2> SubsetOf<Matrix<T2, R2, C2, <DefaultAllocator as Allocator<T2, R2, C2>>::Buffer>> for OMatrix<T1, R1, C1>
where R1: Dim, C1: Dim, R2: Dim, C2: Dim, T1: Scalar, T2: Scalar + SupersetOf<T1>, DefaultAllocator: Allocator<T2, R2, C2> + Allocator<T1, R1, C1> + SameShapeAllocator<T1, R1, C1, R2, C2>, ShapeConstraint: SameNumberOfRows<R1, R2> + SameNumberOfColumns<C1, C2>,

source§

fn to_superset(&self) -> OMatrix<T2, R2, C2>

The inclusion map: converts self to the equivalent element of its superset.
source§

fn is_in_subset(m: &OMatrix<T2, R2, C2>) -> bool

Checks if element is actually part of the subset Self (and can be converted to it).
source§

fn from_superset_unchecked(m: &OMatrix<T2, R2, C2>) -> Self

Use with care! Same as self.to_superset but without any property checks. Always succeeds.
source§

fn from_superset(element: &T) -> Option<Self>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

impl<'a, T, C: Dim> Sum<&'a Matrix<T, Dyn, C, <DefaultAllocator as Allocator<T, Dyn, C>>::Buffer>> for OMatrix<T, Dyn, C>

source§

fn sum<I: Iterator<Item = &'a OMatrix<T, Dyn, C>>>( iter: I ) -> OMatrix<T, Dyn, C>

§Example
let v = &DVector::repeat(3, 1.0f64);

assert_eq!(vec![v, v, v].into_iter().sum::<DVector<f64>>(),
           v + v + v);
§Panics

Panics if the iterator is empty:

iter::empty::<&DMatrix<f64>>().sum::<DMatrix<f64>>(); // panics!
source§

impl<'a, T, R: DimName, C: DimName> Sum<&'a Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>> for OMatrix<T, R, C>

source§

fn sum<I: Iterator<Item = &'a OMatrix<T, R, C>>>(iter: I) -> OMatrix<T, R, C>

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl<T, C: Dim> Sum for OMatrix<T, Dyn, C>

source§

fn sum<I: Iterator<Item = OMatrix<T, Dyn, C>>>(iter: I) -> OMatrix<T, Dyn, C>

§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!
source§

impl<T, R: DimName, C: DimName> Sum for OMatrix<T, R, C>

source§

fn sum<I: Iterator<Item = OMatrix<T, R, C>>>(iter: I) -> OMatrix<T, R, C>

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl<T, R: DimName, C: DimName> TwoSidedInverse<Additive> for OMatrix<T, R, C>

source§

fn two_sided_inverse(&self) -> Self

Returns the two_sided_inverse of self, relative to the operator O. Read more
source§

fn two_sided_inverse_mut(&mut self)

In-place inversion of self, relative to the operator O. Read more
source§

impl<T, R: DimName, C: DimName> VectorSpace for OMatrix<T, R, C>
where T: Scalar + Field, DefaultAllocator: Allocator<T, R, C>,

§

type Field = T

The underlying scalar field.
source§

impl<T, R: DimName, C: DimName> Zero for OMatrix<T, R, C>

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<T, R: DimName, C: DimName> AbstractGroup<Additive> for OMatrix<T, R, C>

source§

impl<T, R: DimName, C: DimName> AbstractGroupAbelian<Additive> for OMatrix<T, R, C>

source§

impl<T, R: DimName, C: DimName> AbstractLoop<Additive> for OMatrix<T, R, C>

source§

impl<T, R: DimName, C: DimName> AbstractMonoid<Additive> for OMatrix<T, R, C>

source§

impl<T, D: DimName> AbstractMonoid<Multiplicative> for OMatrix<T, D, D>

source§

impl<T, R: DimName, C: DimName> AbstractQuasigroup<Additive> for OMatrix<T, R, C>

source§

impl<T, R: DimName, C: DimName> AbstractSemigroup<Additive> for OMatrix<T, R, C>

source§

impl<T, D: DimName> AbstractSemigroup<Multiplicative> for OMatrix<T, D, D>