pub struct Matrix<M> { /* private fields */ }Expand description
Generic matrix container.
Implementations§
source§impl<I, E: Entity> Matrix<PermOwn<I, E>>
impl<I, E: Entity> Matrix<PermOwn<I, E>>
pub fn as_ref(&self) -> PermutationRef<'_, I, E>
pub fn as_mut(&mut self) -> PermutationMut<'_, I, E>
source§impl<I: Index, E: Entity> Matrix<PermOwn<I, E>>
impl<I: Index, E: Entity> Matrix<PermOwn<I, E>>
sourcepub fn new_checked(forward: Box<[I]>, inverse: Box<[I]>) -> Self
pub fn new_checked(forward: Box<[I]>, inverse: Box<[I]>) -> Self
Creates a new permutation, by checking the validity of the inputs.
Panics
The function panics if any of the following conditions are violated:
forward and inverse must have the same length which must be less than or equal to
I::Signed::MAX, be valid permutations, and be inverse permutations of each other.
sourcepub unsafe fn new_unchecked(forward: Box<[I]>, inverse: Box<[I]>) -> Self
pub unsafe fn new_unchecked(forward: Box<[I]>, inverse: Box<[I]>) -> Self
Creates a new permutation reference, without checking the validity of the inputs.
Safety
forward and inverse must have the same length which must be less than or equal to
I::Signed::MAX, be valid permutations, and be inverse permutations of each other.
pub fn len(&self) -> usize
pub fn cast<T: Entity>(self) -> Permutation<I, T>
source§impl<'a, I: Index, E: Entity> Matrix<PermRef<'a, I, E>>
impl<'a, I: Index, E: Entity> Matrix<PermRef<'a, I, E>>
sourcepub fn new_checked(forward: &'a [I], inverse: &'a [I]) -> Self
pub fn new_checked(forward: &'a [I], inverse: &'a [I]) -> Self
Creates a new permutation reference, by checking the validity of the inputs.
Panics
The function panics if any of the following conditions are violated:
forward and inverse must have the same length which must be less than or equal to
I::Signed::MAX, be valid permutations, and be inverse permutations of each other.
sourcepub unsafe fn new_unchecked(forward: &'a [I], inverse: &'a [I]) -> Self
pub unsafe fn new_unchecked(forward: &'a [I], inverse: &'a [I]) -> Self
Creates a new permutation reference, without checking the validity of the inputs.
Safety
forward and inverse must have the same length which must be less than or equal to
I::Signed::MAX, be valid permutations, and be inverse permutations of each other.
sourcepub fn into_arrays(self) -> (&'a [I], &'a [I])
pub fn into_arrays(self) -> (&'a [I], &'a [I])
Returns the permutation as an array.
pub fn len(&self) -> usize
pub fn cast<T: Entity>(self) -> PermutationRef<'a, I, T>
pub fn canonicalize(self) -> PermutationRef<'a, I::FixedWidth, E>
pub fn uncanonicalize<J: Index>(self) -> PermutationRef<'a, J, E>
source§impl<'a, I: Index, E: Entity> Matrix<PermMut<'a, I, E>>
impl<'a, I: Index, E: Entity> Matrix<PermMut<'a, I, E>>
sourcepub fn new_checked(forward: &'a mut [I], inverse: &'a mut [I]) -> Self
pub fn new_checked(forward: &'a mut [I], inverse: &'a mut [I]) -> Self
Creates a new permutation mutable reference, by checking the validity of the inputs.
Panics
The function panics if any of the following conditions are violated:
forward and inverse must have the same length which must be less than or equal to
I::Signed::MAX, be valid permutations, and be inverse permutations of each other.
sourcepub unsafe fn new_unchecked(forward: &'a mut [I], inverse: &'a mut [I]) -> Self
pub unsafe fn new_unchecked(forward: &'a mut [I], inverse: &'a mut [I]) -> Self
Creates a new permutation mutable reference, without checking the validity of the inputs.
Safety
forward and inverse must have the same length which must be less than or equal to
I::Signed::MAX, be valid permutations, and be inverse permutations of each other.
sourcepub unsafe fn into_arrays(self) -> (&'a mut [I], &'a mut [I])
pub unsafe fn into_arrays(self) -> (&'a mut [I], &'a mut [I])
Returns the permutation as an array.
Safety
The behavior is undefined if the arrays are no longer inverse permutations of each other by
the end of lifetime 'a.
pub fn len(&self) -> usize
pub fn cast<T: Entity>(self) -> PermutationMut<'a, I, T>
pub fn canonicalize(self) -> PermutationMut<'a, I::FixedWidth, E>
pub fn uncanonicalize<J: Index>(self) -> PermutationMut<'a, J, E>
source§impl<'a, E: Entity> Matrix<DiagRef<'a, E>>
impl<'a, E: Entity> Matrix<DiagRef<'a, E>>
pub fn into_column_vector(self) -> MatRef<'a, E>
source§impl<'a, E: Entity> Matrix<DiagMut<'a, E>>
impl<'a, E: Entity> Matrix<DiagMut<'a, E>>
pub fn into_column_vector(self) -> MatMut<'a, E>
source§impl<'a, E: Entity> Matrix<DenseRef<'a, E>>
impl<'a, E: Entity> Matrix<DenseRef<'a, E>>
sourcepub fn from_column_major_slice(
slice: GroupFor<E, &'a [E::Unit]>,
nrows: usize,
ncols: usize
) -> Self
pub fn from_column_major_slice( slice: GroupFor<E, &'a [E::Unit]>, nrows: usize, ncols: usize ) -> Self
Creates a MatRef from slice views over the matrix data, and the matrix dimensions.
The data is interpreted in a column-major format, so that the first chunk of nrows
values from the slices goes in the first column of the matrix, the second chunk of nrows
values goes in the second column, and so on.
Panics
The function panics if any of the following conditions are violated:
nrows * ncols == slice.len()
Example
use faer_core::{mat, MatRef};
let slice = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0_f64];
let view = MatRef::<f64>::from_column_major_slice(&slice, 3, 2);
let expected = mat![[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]];
assert_eq!(expected, view);sourcepub fn from_row_major_slice(
slice: GroupFor<E, &'a [E::Unit]>,
nrows: usize,
ncols: usize
) -> Self
pub fn from_row_major_slice( slice: GroupFor<E, &'a [E::Unit]>, nrows: usize, ncols: usize ) -> Self
Creates a MatRef from slice views over the matrix data, and the matrix dimensions.
The data is interpreted in a row-major format, so that the first chunk of ncols
values from the slices goes in the first column of the matrix, the second chunk of ncols
values goes in the second column, and so on.
Panics
The function panics if any of the following conditions are violated:
nrows * ncols == slice.len()
Example
use faer_core::{mat, MatRef};
let slice = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0_f64];
let view = MatRef::<f64>::from_row_major_slice(&slice, 3, 2);
let expected = mat![[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]];
assert_eq!(expected, view);sourcepub unsafe fn from_raw_parts(
ptr: GroupFor<E, *const E::Unit>,
nrows: usize,
ncols: usize,
row_stride: isize,
col_stride: isize
) -> Self
pub unsafe fn from_raw_parts( ptr: GroupFor<E, *const E::Unit>, nrows: usize, ncols: usize, row_stride: isize, col_stride: isize ) -> Self
Creates a MatRef from pointers to the matrix data, dimensions, and strides.
The row (resp. column) stride is the offset from the memory address of a given matrix
element at indices (row: i, col: j), to the memory address of the matrix element at
indices (row: i + 1, col: 0) (resp. (row: 0, col: i + 1)). This offset is specified in
number of elements, not in bytes.
Safety
The behavior is undefined if any of the following conditions are violated:
- For each matrix unit, the entire memory region addressed by the matrix must be contained
within a single allocation, accessible in its entirety by the corresponding pointer in
ptr. - For each matrix unit, the corresponding pointer must be properly aligned, even for a zero-sized matrix.
- The values accessible by the matrix must be initialized at some point before they are read, or references to them are formed.
- No mutable aliasing is allowed. In other words, none of the elements accessible by any
matrix unit may be accessed for writes by any other means for the duration of the lifetime
'a.
Example
use faer_core::{mat, MatRef};
// row major matrix with 2 rows, 3 columns, with a column at the end that we want to skip.
// the row stride is the pointer offset from the address of 1.0 to the address of 4.0,
// which is 4.
// the column stride is the pointer offset from the address of 1.0 to the address of 2.0,
// which is 1.
let data = [[1.0, 2.0, 3.0, f64::NAN], [4.0, 5.0, 6.0, f64::NAN]];
let matrix = unsafe { MatRef::<f64>::from_raw_parts(data.as_ptr() as *const f64, 2, 3, 4, 1) };
let expected = mat![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
assert_eq!(expected.as_ref(), matrix);pub fn nrows(&self) -> usize
pub fn ncols(&self) -> usize
sourcepub fn row_stride(&self) -> isize
pub fn row_stride(&self) -> isize
Returns the row stride of the matrix, specified in number of elements, not in bytes.
sourcepub fn col_stride(&self) -> isize
pub fn col_stride(&self) -> isize
Returns the column stride of the matrix, specified in number of elements, not in bytes.
sourcepub fn ptr_at(self, row: usize, col: usize) -> GroupFor<E, *const E::Unit>
pub fn ptr_at(self, row: usize, col: usize) -> GroupFor<E, *const E::Unit>
Returns raw pointers to the element at the given indices.
sourcepub unsafe fn ptr_inbounds_at(
self,
row: usize,
col: usize
) -> GroupFor<E, *const E::Unit>
pub unsafe fn ptr_inbounds_at( self, row: usize, col: usize ) -> GroupFor<E, *const E::Unit>
Returns raw pointers to the element at the given indices, assuming the provided indices are within the matrix dimensions.
Safety
The behavior is undefined if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub fn split_at(self, row: usize, col: usize) -> [Self; 4]
pub fn split_at(self, row: usize, col: usize) -> [Self; 4]
Splits the matrix horizontally and vertically at the given indices into four corners and returns an array of each submatrix, in the following order:
- top left.
- top right.
- bottom left.
- bottom right.
Panics
The function panics if any of the following conditions are violated:
row <= self.nrows().col <= self.ncols().
sourcepub fn split_at_row(self, row: usize) -> [Self; 2]
pub fn split_at_row(self, row: usize) -> [Self; 2]
Splits the matrix horizontally at the given row into two parts and returns an array of each submatrix, in the following order:
- top.
- bottom.
sourcepub fn split_at_col(self, col: usize) -> [Self; 2]
pub fn split_at_col(self, col: usize) -> [Self; 2]
Splits the matrix vertically at the given row into two parts and returns an array of each submatrix, in the following order:
- left.
- right.
sourcepub unsafe fn get_unchecked<RowRange, ColRange>(
self,
row: RowRange,
col: ColRange
) -> <Self as MatIndex<RowRange, ColRange>>::Targetwhere
Self: MatIndex<RowRange, ColRange>,
pub unsafe fn get_unchecked<RowRange, ColRange>(
self,
row: RowRange,
col: ColRange
) -> <Self as MatIndex<RowRange, ColRange>>::Targetwhere
Self: MatIndex<RowRange, ColRange>,
Returns references to the element at the given indices, or submatrices if either row or
col is a range.
Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
Safety
The behavior is undefined if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).colmust be contained in[0, self.ncols()).
sourcepub fn get<RowRange, ColRange>(
self,
row: RowRange,
col: ColRange
) -> <Self as MatIndex<RowRange, ColRange>>::Targetwhere
Self: MatIndex<RowRange, ColRange>,
pub fn get<RowRange, ColRange>(
self,
row: RowRange,
col: ColRange
) -> <Self as MatIndex<RowRange, ColRange>>::Targetwhere
Self: MatIndex<RowRange, ColRange>,
Returns references to the element at the given indices, or submatrices if either row or
col is a range, with bound checks.
Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
Panics
The function panics if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).colmust be contained in[0, self.ncols()).
sourcepub unsafe fn read_unchecked(&self, row: usize, col: usize) -> E
pub unsafe fn read_unchecked(&self, row: usize, col: usize) -> E
Reads the value of the element at the given indices.
Safety
The behavior is undefined if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub fn read(&self, row: usize, col: usize) -> E
pub fn read(&self, row: usize, col: usize) -> E
Reads the value of the element at the given indices, with bound checks.
Panics
The function panics if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub fn transpose(self) -> Self
pub fn transpose(self) -> Self
Returns a view over the transpose of self.
Example
use faer_core::mat;
let matrix = mat![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
let view = matrix.as_ref();
let transpose = view.transpose();
let expected = mat![[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]];
assert_eq!(expected.as_ref(), transpose);sourcepub fn conjugate(self) -> MatRef<'a, E::Conj>where
E: Conjugate,
pub fn conjugate(self) -> MatRef<'a, E::Conj>where
E: Conjugate,
Returns a view over the conjugate of self.
sourcepub fn adjoint(self) -> MatRef<'a, E::Conj>where
E: Conjugate,
pub fn adjoint(self) -> MatRef<'a, E::Conj>where
E: Conjugate,
Returns a view over the conjugate transpose of self.
sourcepub fn canonicalize(self) -> (MatRef<'a, E::Canonical>, Conj)where
E: Conjugate,
pub fn canonicalize(self) -> (MatRef<'a, E::Canonical>, Conj)where
E: Conjugate,
Returns a view over the canonical representation of self, as well as a flag declaring
whether self is implicitly conjugated or not.
sourcepub fn reverse_rows(self) -> Self
pub fn reverse_rows(self) -> Self
Returns a view over the self, with the rows in reversed order.
Example
use faer_core::mat;
let matrix = mat![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
let view = matrix.as_ref();
let reversed_rows = view.reverse_rows();
let expected = mat![[4.0, 5.0, 6.0], [1.0, 2.0, 3.0]];
assert_eq!(expected.as_ref(), reversed_rows);sourcepub fn reverse_cols(self) -> Self
pub fn reverse_cols(self) -> Self
Returns a view over the self, with the columns in reversed order.
Example
use faer_core::mat;
let matrix = mat![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
let view = matrix.as_ref();
let reversed_cols = view.reverse_cols();
let expected = mat![[3.0, 2.0, 1.0], [6.0, 5.0, 4.0]];
assert_eq!(expected.as_ref(), reversed_cols);sourcepub fn reverse_rows_and_cols(self) -> Self
pub fn reverse_rows_and_cols(self) -> Self
Returns a view over the self, with the rows and the columns in reversed order.
Example
use faer_core::mat;
let matrix = mat![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
let view = matrix.as_ref();
let reversed = view.reverse_rows_and_cols();
let expected = mat![[6.0, 5.0, 4.0], [3.0, 2.0, 1.0]];
assert_eq!(expected.as_ref(), reversed);sourcepub fn submatrix(
self,
row_start: usize,
col_start: usize,
nrows: usize,
ncols: usize
) -> Self
pub fn submatrix( self, row_start: usize, col_start: usize, nrows: usize, ncols: usize ) -> Self
Returns a view over the submatrix starting at indices (row_start, col_start), and with
dimensions (nrows, ncols).
Panics
The function panics if any of the following conditions are violated:
row_start <= self.nrows().col_start <= self.ncols().nrows <= self.nrows() - row_start.ncols <= self.ncols() - col_start.
Example
use faer_core::mat;
let matrix = mat![
[1.0, 5.0, 9.0],
[2.0, 6.0, 10.0],
[3.0, 7.0, 11.0],
[4.0, 8.0, 12.0f64],
];
let view = matrix.as_ref();
let submatrix = view.submatrix(2, 1, 2, 2);
let expected = mat![[7.0, 11.0], [8.0, 12.0f64]];
assert_eq!(expected.as_ref(), submatrix);sourcepub fn subrows(self, row_start: usize, nrows: usize) -> Self
pub fn subrows(self, row_start: usize, nrows: usize) -> Self
Returns a view over the submatrix starting at row row_start, and with number of rows
nrows.
Panics
The function panics if any of the following conditions are violated:
row_start <= self.nrows().nrows <= self.nrows() - row_start.
Example
use faer_core::mat;
let matrix = mat![
[1.0, 5.0, 9.0],
[2.0, 6.0, 10.0],
[3.0, 7.0, 11.0],
[4.0, 8.0, 12.0f64],
];
let view = matrix.as_ref();
let subrows = view.subrows(1, 2);
let expected = mat![[2.0, 6.0, 10.0], [3.0, 7.0, 11.0],];
assert_eq!(expected.as_ref(), subrows);sourcepub fn subcols(self, col_start: usize, ncols: usize) -> Self
pub fn subcols(self, col_start: usize, ncols: usize) -> Self
Returns a view over the submatrix starting at column col_start, and with number of
columns ncols.
Panics
The function panics if any of the following conditions are violated:
col_start <= self.ncols().ncols <= self.ncols() - col_start.
Example
use faer_core::mat;
let matrix = mat![
[1.0, 5.0, 9.0],
[2.0, 6.0, 10.0],
[3.0, 7.0, 11.0],
[4.0, 8.0, 12.0f64],
];
let view = matrix.as_ref();
let subcols = view.subcols(2, 1);
let expected = mat![[9.0], [10.0], [11.0], [12.0f64]];
assert_eq!(expected.as_ref(), subcols);sourcepub fn row(self, row_idx: usize) -> Self
pub fn row(self, row_idx: usize) -> Self
Returns a view over the row at the given index.
Panics
The function panics if any of the following conditions are violated:
row_idx < self.nrows().
sourcepub fn col(self, col_idx: usize) -> Self
pub fn col(self, col_idx: usize) -> Self
Returns a view over the column at the given index.
Panics
The function panics if any of the following conditions are violated:
col_idx < self.ncols().
sourcepub fn column_vector_as_diagonal(self) -> Matrix<DiagRef<'a, E>>
pub fn column_vector_as_diagonal(self) -> Matrix<DiagRef<'a, E>>
Given a matrix with a single column, returns an object that interprets the column as a diagonal matrix, whoes diagonal elements are values in the column.
pub fn diagonal(self) -> Matrix<DiagRef<'a, E>>
sourcepub fn to_owned(&self) -> Mat<E::Canonical>where
E: Conjugate,
pub fn to_owned(&self) -> Mat<E::Canonical>where
E: Conjugate,
Returns an owning Mat of the data.
sourcepub fn has_nan(&self) -> boolwhere
E: ComplexField,
pub fn has_nan(&self) -> boolwhere
E: ComplexField,
Returns true if any of the elements is NaN, otherwise returns false.
sourcepub fn is_all_finite(&self) -> boolwhere
E: ComplexField,
pub fn is_all_finite(&self) -> boolwhere
E: ComplexField,
Returns true if all of the elements are finite, otherwise returns false.
sourcepub fn cwise(self) -> Zip<(Self,)>
pub fn cwise(self) -> Zip<(Self,)>
Returns a thin wrapper that can be used to execute coefficient-wise operations on matrices.
sourcepub fn into_col_chunks(
self,
chunk_size: usize
) -> impl 'a + DoubleEndedIterator<Item = MatRef<'a, E>>
pub fn into_col_chunks( self, chunk_size: usize ) -> impl 'a + DoubleEndedIterator<Item = MatRef<'a, E>>
Returns an iterator that provides successive chunks of the columns of this matrix, with
each having at most chunk_size columns.
If the number of columns is a multiple of chunk_size, then all chunks have chunk_size
columns.
sourcepub fn into_row_chunks(
self,
chunk_size: usize
) -> impl 'a + DoubleEndedIterator<Item = MatRef<'a, E>>
pub fn into_row_chunks( self, chunk_size: usize ) -> impl 'a + DoubleEndedIterator<Item = MatRef<'a, E>>
Returns an iterator that provides successive chunks of the rows of this matrix, with
each having at most chunk_size rows.
If the number of rows is a multiple of chunk_size, then all chunks have chunk_size
rows.
sourcepub fn into_par_col_chunks(
self,
chunk_size: usize
) -> impl 'a + IndexedParallelIterator<Item = MatRef<'a, E>>
pub fn into_par_col_chunks( self, chunk_size: usize ) -> impl 'a + IndexedParallelIterator<Item = MatRef<'a, E>>
Returns a parallel iterator that provides successive chunks of the columns of this matrix,
with each having at most chunk_size columns.
If the number of columns is a multiple of chunk_size, then all chunks have chunk_size
columns.
Only available with the rayon feature.
sourcepub fn into_par_row_chunks(
self,
chunk_size: usize
) -> impl 'a + IndexedParallelIterator<Item = MatRef<'a, E>>
pub fn into_par_row_chunks( self, chunk_size: usize ) -> impl 'a + IndexedParallelIterator<Item = MatRef<'a, E>>
Returns a parallel iterator that provides successive chunks of the rows of this matrix,
with each having at most chunk_size rows.
If the number of rows is a multiple of chunk_size, then all chunks have chunk_size
rows.
Only available with the rayon feature.
source§impl<'a, E: Entity> Matrix<DenseMut<'a, E>>
impl<'a, E: Entity> Matrix<DenseMut<'a, E>>
sourcepub fn from_column_major_slice(
slice: GroupFor<E, &'a mut [E::Unit]>,
nrows: usize,
ncols: usize
) -> Self
pub fn from_column_major_slice( slice: GroupFor<E, &'a mut [E::Unit]>, nrows: usize, ncols: usize ) -> Self
Creates a MatMut from slice views over the matrix data, and the matrix dimensions.
The data is interpreted in a column-major format, so that the first chunk of nrows
values from the slices goes in the first column of the matrix, the second chunk of nrows
values goes in the second column, and so on.
Panics
The function panics if any of the following conditions are violated:
nrows * ncols == slice.len()
Example
use faer_core::{mat, MatMut};
let mut slice = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0_f64];
let view = MatMut::<f64>::from_column_major_slice(&mut slice, 3, 2);
let expected = mat![[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]];
assert_eq!(expected, view);sourcepub fn from_row_major_slice(
slice: GroupFor<E, &'a mut [E::Unit]>,
nrows: usize,
ncols: usize
) -> Self
pub fn from_row_major_slice( slice: GroupFor<E, &'a mut [E::Unit]>, nrows: usize, ncols: usize ) -> Self
Creates a MatMut from slice views over the matrix data, and the matrix dimensions.
The data is interpreted in a row-major format, so that the first chunk of ncols
values from the slices goes in the first column of the matrix, the second chunk of ncols
values goes in the second column, and so on.
Panics
The function panics if any of the following conditions are violated:
nrows * ncols == slice.len()
Example
use faer_core::{mat, MatMut};
let mut slice = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0_f64];
let view = MatMut::<f64>::from_row_major_slice(&mut slice, 3, 2);
let expected = mat![[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]];
assert_eq!(expected, view);sourcepub unsafe fn from_raw_parts(
ptr: GroupFor<E, *mut E::Unit>,
nrows: usize,
ncols: usize,
row_stride: isize,
col_stride: isize
) -> Self
pub unsafe fn from_raw_parts( ptr: GroupFor<E, *mut E::Unit>, nrows: usize, ncols: usize, row_stride: isize, col_stride: isize ) -> Self
Creates a MatMut from pointers to the matrix data, dimensions, and strides.
The row (resp. column) stride is the offset from the memory address of a given matrix
element at indices (row: i, col: j), to the memory address of the matrix element at
indices (row: i + 1, col: 0) (resp. (row: 0, col: i + 1)). This offset is specified in
number of elements, not in bytes.
Safety
The behavior is undefined if any of the following conditions are violated:
- For each matrix unit, the entire memory region addressed by the matrix must be contained
within a single allocation, accessible in its entirety by the corresponding pointer in
ptr. - For each matrix unit, the corresponding pointer must be properly aligned, even for a zero-sized matrix.
- The values accessible by the matrix must be initialized at some point before they are read, or references to them are formed.
- No aliasing (including self aliasing) is allowed. In other words, none of the elements
accessible by any matrix unit may be accessed for reads or writes by any other means for
the duration of the lifetime
'a. No two elements within a single matrix unit may point to the same address (such a thing can be achieved with a zero stride, for example), and no two matrix units may point to the same address.
Example
use faer_core::{mat, MatMut};
// row major matrix with 2 rows, 3 columns, with a column at the end that we want to skip.
// the row stride is the pointer offset from the address of 1.0 to the address of 4.0,
// which is 4.
// the column stride is the pointer offset from the address of 1.0 to the address of 2.0,
// which is 1.
let mut data = [[1.0, 2.0, 3.0, f64::NAN], [4.0, 5.0, 6.0, f64::NAN]];
let mut matrix =
unsafe { MatMut::<f64>::from_raw_parts(data.as_mut_ptr() as *mut f64, 2, 3, 4, 1) };
let expected = mat![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
assert_eq!(expected.as_ref(), matrix);pub fn nrows(&self) -> usize
pub fn ncols(&self) -> usize
sourcepub fn row_stride(&self) -> isize
pub fn row_stride(&self) -> isize
Returns the row stride of the matrix, specified in number of elements, not in bytes.
sourcepub fn col_stride(&self) -> isize
pub fn col_stride(&self) -> isize
Returns the column stride of the matrix, specified in number of elements, not in bytes.
sourcepub fn ptr_at(self, row: usize, col: usize) -> GroupFor<E, *mut E::Unit>
pub fn ptr_at(self, row: usize, col: usize) -> GroupFor<E, *mut E::Unit>
Returns raw pointers to the element at the given indices.
sourcepub unsafe fn ptr_inbounds_at(
self,
row: usize,
col: usize
) -> GroupFor<E, *mut E::Unit>
pub unsafe fn ptr_inbounds_at( self, row: usize, col: usize ) -> GroupFor<E, *mut E::Unit>
Returns raw pointers to the element at the given indices, assuming the provided indices are within the matrix dimensions.
Safety
The behavior is undefined if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub fn split_at(self, row: usize, col: usize) -> [Self; 4]
pub fn split_at(self, row: usize, col: usize) -> [Self; 4]
Splits the matrix horizontally and vertically at the given indices into four corners and returns an array of each submatrix, in the following order:
- top left.
- top right.
- bottom left.
- bottom right.
Panics
The function panics if any of the following conditions are violated:
row <= self.nrows().col <= self.ncols().
sourcepub fn split_at_row(self, row: usize) -> [Self; 2]
pub fn split_at_row(self, row: usize) -> [Self; 2]
Splits the matrix horizontally at the given row into two parts and returns an array of each submatrix, in the following order:
- top.
- bottom.
sourcepub fn split_at_col(self, col: usize) -> [Self; 2]
pub fn split_at_col(self, col: usize) -> [Self; 2]
Splits the matrix vertically at the given row into two parts and returns an array of each submatrix, in the following order:
- left.
- right.
sourcepub unsafe fn get_unchecked<RowRange, ColRange>(
self,
row: RowRange,
col: ColRange
) -> <Self as MatIndex<RowRange, ColRange>>::Targetwhere
Self: MatIndex<RowRange, ColRange>,
pub unsafe fn get_unchecked<RowRange, ColRange>(
self,
row: RowRange,
col: ColRange
) -> <Self as MatIndex<RowRange, ColRange>>::Targetwhere
Self: MatIndex<RowRange, ColRange>,
Returns mutable references to the element at the given indices, or submatrices if either
row or col is a range.
Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
Safety
The behavior is undefined if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).colmust be contained in[0, self.ncols()).
sourcepub fn get<RowRange, ColRange>(
self,
row: RowRange,
col: ColRange
) -> <Self as MatIndex<RowRange, ColRange>>::Targetwhere
Self: MatIndex<RowRange, ColRange>,
pub fn get<RowRange, ColRange>(
self,
row: RowRange,
col: ColRange
) -> <Self as MatIndex<RowRange, ColRange>>::Targetwhere
Self: MatIndex<RowRange, ColRange>,
Returns mutable references to the element at the given indices, or submatrices if either
row or col is a range, with bound checks.
Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
Panics
The function panics if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).colmust be contained in[0, self.ncols()).
sourcepub unsafe fn read_unchecked(&self, row: usize, col: usize) -> E
pub unsafe fn read_unchecked(&self, row: usize, col: usize) -> E
Reads the value of the element at the given indices.
Safety
The behavior is undefined if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub fn read(&self, row: usize, col: usize) -> E
pub fn read(&self, row: usize, col: usize) -> E
Reads the value of the element at the given indices, with bound checks.
Panics
The function panics if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub unsafe fn write_unchecked(&mut self, row: usize, col: usize, value: E)
pub unsafe fn write_unchecked(&mut self, row: usize, col: usize, value: E)
Writes the value to the element at the given indices.
Safety
The behavior is undefined if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub fn write(&mut self, row: usize, col: usize, value: E)
pub fn write(&mut self, row: usize, col: usize, value: E)
Writes the value to the element at the given indices, with bound checks.
Panics
The function panics if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub fn clone_from(&mut self, other: impl AsMatRef<E>)
pub fn clone_from(&mut self, other: impl AsMatRef<E>)
Copies the values from other into self.
Panics
The function panics if any of the following conditions are violated:
self.nrows() == other.nrows().self.ncols() == other.ncols().
sourcepub fn fill_zeros(&mut self)where
E: ComplexField,
pub fn fill_zeros(&mut self)where
E: ComplexField,
Fills the elements of self with zeros.
sourcepub fn transpose(self) -> Self
pub fn transpose(self) -> Self
Returns a view over the transpose of self.
Example
use faer_core::mat;
let mut matrix = mat![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
let view = matrix.as_mut();
let transpose = view.transpose();
let mut expected = mat![[1.0, 4.0], [2.0, 5.0], [3.0, 6.0]];
assert_eq!(expected.as_mut(), transpose);sourcepub fn conjugate(self) -> MatMut<'a, E::Conj>where
E: Conjugate,
pub fn conjugate(self) -> MatMut<'a, E::Conj>where
E: Conjugate,
Returns a view over the conjugate of self.
sourcepub fn adjoint(self) -> MatMut<'a, E::Conj>where
E: Conjugate,
pub fn adjoint(self) -> MatMut<'a, E::Conj>where
E: Conjugate,
Returns a view over the conjugate transpose of self.
sourcepub fn canonicalize(self) -> (MatMut<'a, E::Canonical>, Conj)where
E: Conjugate,
pub fn canonicalize(self) -> (MatMut<'a, E::Canonical>, Conj)where
E: Conjugate,
Returns a view over the canonical representation of self, as well as a flag declaring
whether self is implicitly conjugated or not.
sourcepub fn reverse_rows(self) -> Self
pub fn reverse_rows(self) -> Self
Returns a view over the self, with the rows in reversed order.
Example
use faer_core::mat;
let mut matrix = mat![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
let view = matrix.as_mut();
let reversed_rows = view.reverse_rows();
let mut expected = mat![[4.0, 5.0, 6.0], [1.0, 2.0, 3.0]];
assert_eq!(expected.as_mut(), reversed_rows);sourcepub fn reverse_cols(self) -> Self
pub fn reverse_cols(self) -> Self
Returns a view over the self, with the columns in reversed order.
Example
use faer_core::mat;
let mut matrix = mat![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
let view = matrix.as_mut();
let reversed_cols = view.reverse_cols();
let mut expected = mat![[3.0, 2.0, 1.0], [6.0, 5.0, 4.0]];
assert_eq!(expected.as_mut(), reversed_cols);sourcepub fn reverse_rows_and_cols(self) -> Self
pub fn reverse_rows_and_cols(self) -> Self
Returns a view over the self, with the rows and the columns in reversed order.
Example
use faer_core::mat;
let mut matrix = mat![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
let view = matrix.as_mut();
let reversed = view.reverse_rows_and_cols();
let mut expected = mat![[6.0, 5.0, 4.0], [3.0, 2.0, 1.0]];
assert_eq!(expected.as_mut(), reversed);sourcepub fn submatrix(
self,
row_start: usize,
col_start: usize,
nrows: usize,
ncols: usize
) -> Self
pub fn submatrix( self, row_start: usize, col_start: usize, nrows: usize, ncols: usize ) -> Self
Returns a view over the submatrix starting at indices (row_start, col_start), and with
dimensions (nrows, ncols).
Panics
The function panics if any of the following conditions are violated:
row_start <= self.nrows().col_start <= self.ncols().nrows <= self.nrows() - row_start.ncols <= self.ncols() - col_start.
Example
use faer_core::mat;
let mut matrix = mat![
[1.0, 5.0, 9.0],
[2.0, 6.0, 10.0],
[3.0, 7.0, 11.0],
[4.0, 8.0, 12.0f64],
];
let view = matrix.as_mut();
let submatrix = view.submatrix(2, 1, 2, 2);
let mut expected = mat![[7.0, 11.0], [8.0, 12.0f64]];
assert_eq!(expected.as_mut(), submatrix);sourcepub fn subrows(self, row_start: usize, nrows: usize) -> Self
pub fn subrows(self, row_start: usize, nrows: usize) -> Self
Returns a view over the submatrix starting at row row_start, and with number of rows
nrows.
Panics
The function panics if any of the following conditions are violated:
row_start <= self.nrows().nrows <= self.nrows() - row_start.
Example
use faer_core::mat;
let mut matrix = mat![
[1.0, 5.0, 9.0],
[2.0, 6.0, 10.0],
[3.0, 7.0, 11.0],
[4.0, 8.0, 12.0f64],
];
let view = matrix.as_mut();
let subrows = view.subrows(1, 2);
let mut expected = mat![[2.0, 6.0, 10.0], [3.0, 7.0, 11.0],];
assert_eq!(expected.as_mut(), subrows);sourcepub fn subcols(self, col_start: usize, ncols: usize) -> Self
pub fn subcols(self, col_start: usize, ncols: usize) -> Self
Returns a view over the submatrix starting at column col_start, and with number of
columns ncols.
Panics
The function panics if any of the following conditions are violated:
col_start <= self.ncols().ncols <= self.ncols() - col_start.
Example
use faer_core::mat;
let mut matrix = mat![
[1.0, 5.0, 9.0],
[2.0, 6.0, 10.0],
[3.0, 7.0, 11.0],
[4.0, 8.0, 12.0f64],
];
let view = matrix.as_mut();
let subcols = view.subcols(2, 1);
let mut expected = mat![[9.0], [10.0], [11.0], [12.0f64]];
assert_eq!(expected.as_mut(), subcols);sourcepub fn row(self, row_idx: usize) -> Self
pub fn row(self, row_idx: usize) -> Self
Returns a view over the row at the given index.
Panics
The function panics if any of the following conditions are violated:
row_idx < self.nrows().
sourcepub fn col(self, col_idx: usize) -> Self
pub fn col(self, col_idx: usize) -> Self
Returns a view over the column at the given index.
Panics
The function panics if any of the following conditions are violated:
col_idx < self.ncols().
sourcepub fn column_vector_as_diagonal(self) -> Matrix<DiagMut<'a, E>>
pub fn column_vector_as_diagonal(self) -> Matrix<DiagMut<'a, E>>
Given a matrix with a single column, returns an object that interprets the column as a diagonal matrix, whoes diagonal elements are values in the column.
pub fn diagonal(self) -> Matrix<DiagMut<'a, E>>
sourcepub fn to_owned(&self) -> Mat<E::Canonical>where
E: Conjugate,
pub fn to_owned(&self) -> Mat<E::Canonical>where
E: Conjugate,
Returns an owning Mat of the data
sourcepub fn has_nan(&self) -> boolwhere
E: ComplexField,
pub fn has_nan(&self) -> boolwhere
E: ComplexField,
Returns true if any of the elements is NaN, otherwise returns false.
sourcepub fn is_all_finite(&self) -> boolwhere
E: ComplexField,
pub fn is_all_finite(&self) -> boolwhere
E: ComplexField,
Returns true if all of the elements are finite, otherwise returns false.
sourcepub fn cwise(self) -> Zip<(Self,)>
pub fn cwise(self) -> Zip<(Self,)>
Returns a thin wrapper that can be used to execute coefficient-wise operations on matrices.
sourcepub fn into_col_chunks(
self,
chunk_size: usize
) -> impl 'a + DoubleEndedIterator<Item = MatMut<'a, E>>
pub fn into_col_chunks( self, chunk_size: usize ) -> impl 'a + DoubleEndedIterator<Item = MatMut<'a, E>>
Returns an iterator that provides successive chunks of the columns of this matrix, with
each having at most chunk_size columns.
If the number of columns is a multiple of chunk_size, then all chunks have chunk_size
columns.
sourcepub fn into_row_chunks(
self,
chunk_size: usize
) -> impl 'a + DoubleEndedIterator<Item = MatMut<'a, E>>
pub fn into_row_chunks( self, chunk_size: usize ) -> impl 'a + DoubleEndedIterator<Item = MatMut<'a, E>>
Returns an iterator that provides successive chunks of the rows of this matrix,
with each having at most chunk_size rows.
If the number of rows is a multiple of chunk_size, then all chunks have chunk_size
rows.
sourcepub fn into_par_col_chunks(
self,
chunk_size: usize
) -> impl 'a + IndexedParallelIterator<Item = MatMut<'a, E>>
pub fn into_par_col_chunks( self, chunk_size: usize ) -> impl 'a + IndexedParallelIterator<Item = MatMut<'a, E>>
Returns a parallel iterator that provides successive chunks of the columns of this matrix,
with each having at most chunk_size columns.
If the number of columns is a multiple of chunk_size, then all chunks have chunk_size
columns.
Only available with the rayon feature.
sourcepub fn into_par_row_chunks(
self,
chunk_size: usize
) -> impl 'a + IndexedParallelIterator<Item = MatMut<'a, E>>
pub fn into_par_row_chunks( self, chunk_size: usize ) -> impl 'a + IndexedParallelIterator<Item = MatMut<'a, E>>
Returns a parallel iterator that provides successive chunks of the rows of this matrix,
with each having at most chunk_size rows.
If the number of rows is a multiple of chunk_size, then all chunks have chunk_size
rows.
Only available with the rayon feature.
source§impl<E: Entity> Matrix<DenseOwn<E>>
impl<E: Entity> Matrix<DenseOwn<E>>
pub fn new() -> Self
sourcepub fn with_capacity(row_capacity: usize, col_capacity: usize) -> Self
pub fn with_capacity(row_capacity: usize, col_capacity: usize) -> Self
Returns a new matrix with dimensions (0, 0), with enough capacity to hold a maximum of
row_capacity rows and col_capacity columns without reallocating. If either is 0,
the matrix will not allocate.
Panics
The function panics if the total capacity in bytes exceeds isize::MAX.
sourcepub fn from_fn(
nrows: usize,
ncols: usize,
f: impl FnMut(usize, usize) -> E
) -> Self
pub fn from_fn( nrows: usize, ncols: usize, f: impl FnMut(usize, usize) -> E ) -> Self
Returns a new matrix with dimensions (nrows, ncols), filled with the provided function.
Panics
The function panics if the total capacity in bytes exceeds isize::MAX.
sourcepub fn zeros(nrows: usize, ncols: usize) -> Selfwhere
E: ComplexField,
pub fn zeros(nrows: usize, ncols: usize) -> Selfwhere
E: ComplexField,
Returns a new matrix with dimensions (nrows, ncols), filled with zeros.
Panics
The function panics if the total capacity in bytes exceeds isize::MAX.
sourcepub fn identity(nrows: usize, ncols: usize) -> Selfwhere
E: ComplexField,
pub fn identity(nrows: usize, ncols: usize) -> Selfwhere
E: ComplexField,
Returns a new matrix with dimensions (nrows, ncols), filled with zeros, except the main
diagonal which is filled with ones.
Panics
The function panics if the total capacity in bytes exceeds isize::MAX.
pub fn nrows(&self) -> usize
pub fn ncols(&self) -> usize
sourcepub unsafe fn set_dims(&mut self, nrows: usize, ncols: usize)
pub unsafe fn set_dims(&mut self, nrows: usize, ncols: usize)
Set the dimensions of the matrix.
Safety
The behavior is undefined if any of the following conditions are violated:
nrows < self.row_capacity().ncols < self.col_capacity().- The elements that were previously out of bounds but are now in bounds must be initialized.
sourcepub fn as_ptr(&self) -> GroupFor<E, *const E::Unit>
pub fn as_ptr(&self) -> GroupFor<E, *const E::Unit>
Returns a pointer to the data of the matrix.
sourcepub fn as_mut_ptr(&mut self) -> GroupFor<E, *mut E::Unit>
pub fn as_mut_ptr(&mut self) -> GroupFor<E, *mut E::Unit>
Returns a mutable pointer to the data of the matrix.
sourcepub fn row_capacity(&self) -> usize
pub fn row_capacity(&self) -> usize
Returns the row capacity, that is, the number of rows that the matrix is able to hold without needing to reallocate, excluding column insertions.
sourcepub fn col_capacity(&self) -> usize
pub fn col_capacity(&self) -> usize
Returns the column capacity, that is, the number of columns that the matrix is able to hold without needing to reallocate, excluding row insertions.
sourcepub fn row_stride(&self) -> isize
pub fn row_stride(&self) -> isize
Returns the offset between the first elements of two successive rows in the matrix.
Always returns 1 since the matrix is column major.
sourcepub fn col_stride(&self) -> isize
pub fn col_stride(&self) -> isize
Returns the offset between the first elements of two successive columns in the matrix.
sourcepub fn reserve_exact(&mut self, row_capacity: usize, col_capacity: usize)
pub fn reserve_exact(&mut self, row_capacity: usize, col_capacity: usize)
Reserves the minimum capacity for row_capacity rows and col_capacity
columns without reallocating. Does nothing if the capacity is already sufficient.
Panics
The function panics if the new total capacity in bytes exceeds isize::MAX.
sourcepub fn resize_with(
&mut self,
new_nrows: usize,
new_ncols: usize,
f: impl FnMut(usize, usize) -> E
)
pub fn resize_with( &mut self, new_nrows: usize, new_ncols: usize, f: impl FnMut(usize, usize) -> E )
Resizes the matrix in-place so that the new dimensions are (new_nrows, new_ncols).
New elements are created with the given function f, so that elements at indices (i, j)
are created by calling f(i, j).
sourcepub fn col_ref(&self, col: usize) -> GroupFor<E, &[E::Unit]>
pub fn col_ref(&self, col: usize) -> GroupFor<E, &[E::Unit]>
Returns a reference to a slice over the column at the given index.
sourcepub fn col_mut(&mut self, col: usize) -> GroupFor<E, &mut [E::Unit]>
pub fn col_mut(&mut self, col: usize) -> GroupFor<E, &mut [E::Unit]>
Returns a mutable reference to a slice over the column at the given index.
sourcepub unsafe fn get_unchecked<RowRange, ColRange>(
&self,
row: RowRange,
col: ColRange
) -> <MatRef<'_, E> as MatIndex<RowRange, ColRange>>::Target
pub unsafe fn get_unchecked<RowRange, ColRange>( &self, row: RowRange, col: ColRange ) -> <MatRef<'_, E> as MatIndex<RowRange, ColRange>>::Target
Returns references to the element at the given indices, or submatrices if either row or
col is a range.
Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
Safety
The behavior is undefined if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).colmust be contained in[0, self.ncols()).
sourcepub fn get<RowRange, ColRange>(
&self,
row: RowRange,
col: ColRange
) -> <MatRef<'_, E> as MatIndex<RowRange, ColRange>>::Target
pub fn get<RowRange, ColRange>( &self, row: RowRange, col: ColRange ) -> <MatRef<'_, E> as MatIndex<RowRange, ColRange>>::Target
Returns references to the element at the given indices, or submatrices if either row or
col is a range, with bound checks.
Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
Panics
The function panics if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).colmust be contained in[0, self.ncols()).
sourcepub unsafe fn get_mut_unchecked<RowRange, ColRange>(
&mut self,
row: RowRange,
col: ColRange
) -> <MatMut<'_, E> as MatIndex<RowRange, ColRange>>::Target
pub unsafe fn get_mut_unchecked<RowRange, ColRange>( &mut self, row: RowRange, col: ColRange ) -> <MatMut<'_, E> as MatIndex<RowRange, ColRange>>::Target
Returns mutable references to the element at the given indices, or submatrices if either
row or col is a range.
Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
Safety
The behavior is undefined if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).colmust be contained in[0, self.ncols()).
sourcepub fn get_mut<RowRange, ColRange>(
&mut self,
row: RowRange,
col: ColRange
) -> <MatMut<'_, E> as MatIndex<RowRange, ColRange>>::Target
pub fn get_mut<RowRange, ColRange>( &mut self, row: RowRange, col: ColRange ) -> <MatMut<'_, E> as MatIndex<RowRange, ColRange>>::Target
Returns mutable references to the element at the given indices, or submatrices if either
row or col is a range, with bound checks.
Note
The values pointed to by the references are expected to be initialized, even if the pointed-to value is not read, otherwise the behavior is undefined.
Panics
The function panics if any of the following conditions are violated:
rowmust be contained in[0, self.nrows()).colmust be contained in[0, self.ncols()).
sourcepub unsafe fn read_unchecked(&self, row: usize, col: usize) -> E
pub unsafe fn read_unchecked(&self, row: usize, col: usize) -> E
Reads the value of the element at the given indices.
Safety
The behavior is undefined if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub fn read(&self, row: usize, col: usize) -> E
pub fn read(&self, row: usize, col: usize) -> E
Reads the value of the element at the given indices, with bound checks.
Panics
The function panics if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub unsafe fn write_unchecked(&mut self, row: usize, col: usize, value: E)
pub unsafe fn write_unchecked(&mut self, row: usize, col: usize, value: E)
Writes the value to the element at the given indices.
Safety
The behavior is undefined if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub fn write(&mut self, row: usize, col: usize, value: E)
pub fn write(&mut self, row: usize, col: usize, value: E)
Writes the value to the element at the given indices, with bound checks.
Panics
The function panics if any of the following conditions are violated:
row < self.nrows().col < self.ncols().
sourcepub fn clone_from(&mut self, other: impl AsMatRef<E>)
pub fn clone_from(&mut self, other: impl AsMatRef<E>)
Copies the values from other into self.
sourcepub fn fill_zeros(&mut self)where
E: ComplexField,
pub fn fill_zeros(&mut self)where
E: ComplexField,
Fills the elements of self with zeros.
sourcepub fn conjugate(&self) -> MatRef<'_, E::Conj>where
E: Conjugate,
pub fn conjugate(&self) -> MatRef<'_, E::Conj>where
E: Conjugate,
Returns a view over the conjugate of self.
sourcepub fn adjoint(&self) -> MatRef<'_, E::Conj>where
E: Conjugate,
pub fn adjoint(&self) -> MatRef<'_, E::Conj>where
E: Conjugate,
Returns a view over the conjugate transpose of self.
pub fn diagonal(&self) -> Matrix<DiagRef<'_, E>>
sourcepub fn to_owned(&self) -> Mat<E::Canonical>where
E: Conjugate,
pub fn to_owned(&self) -> Mat<E::Canonical>where
E: Conjugate,
Returns an owning Mat of the data
sourcepub fn has_nan(&self) -> boolwhere
E: ComplexField,
pub fn has_nan(&self) -> boolwhere
E: ComplexField,
Returns true if any of the elements is NaN, otherwise returns false.
sourcepub fn is_all_finite(&self) -> boolwhere
E: ComplexField,
pub fn is_all_finite(&self) -> boolwhere
E: ComplexField,
Returns true if all of the elements are finite, otherwise returns false.
sourcepub fn col_chunks(
&self,
chunk_size: usize
) -> impl '_ + DoubleEndedIterator<Item = MatRef<'_, E>>
pub fn col_chunks( &self, chunk_size: usize ) -> impl '_ + DoubleEndedIterator<Item = MatRef<'_, E>>
Returns an iterator that provides successive chunks of the columns of a view over this
matrix, with each having at most chunk_size columns.
If the number of columns is a multiple of chunk_size, then all chunks have chunk_size
columns.
sourcepub fn col_chunks_mut(
&mut self,
chunk_size: usize
) -> impl '_ + DoubleEndedIterator<Item = MatMut<'_, E>>
pub fn col_chunks_mut( &mut self, chunk_size: usize ) -> impl '_ + DoubleEndedIterator<Item = MatMut<'_, E>>
Returns an iterator that provides successive chunks of the columns of a mutable view over
this matrix, with each having at most chunk_size columns.
If the number of columns is a multiple of chunk_size, then all chunks have chunk_size
columns.
sourcepub fn par_col_chunks(
&self,
chunk_size: usize
) -> impl '_ + IndexedParallelIterator<Item = MatRef<'_, E>>
pub fn par_col_chunks( &self, chunk_size: usize ) -> impl '_ + IndexedParallelIterator<Item = MatRef<'_, E>>
Returns a parallel iterator that provides successive chunks of the columns of a view over
this matrix, with each having at most chunk_size columns.
If the number of columns is a multiple of chunk_size, then all chunks have chunk_size
columns.
Only available with the rayon feature.
sourcepub fn par_col_chunks_mut(
&mut self,
chunk_size: usize
) -> impl '_ + IndexedParallelIterator<Item = MatMut<'_, E>>
pub fn par_col_chunks_mut( &mut self, chunk_size: usize ) -> impl '_ + IndexedParallelIterator<Item = MatMut<'_, E>>
Returns a parallel iterator that provides successive chunks of the columns of a mutable view
over this matrix, with each having at most chunk_size columns.
If the number of columns is a multiple of chunk_size, then all chunks have chunk_size
columns.
Only available with the rayon feature.
sourcepub fn row_chunks(
&self,
chunk_size: usize
) -> impl '_ + DoubleEndedIterator<Item = MatRef<'_, E>>
pub fn row_chunks( &self, chunk_size: usize ) -> impl '_ + DoubleEndedIterator<Item = MatRef<'_, E>>
Returns an iterator that provides successive chunks of the rows of a view over this
matrix, with each having at most chunk_size rows.
If the number of rows is a multiple of chunk_size, then all chunks have chunk_size
rows.
sourcepub fn row_chunks_mut(
&mut self,
chunk_size: usize
) -> impl '_ + DoubleEndedIterator<Item = MatMut<'_, E>>
pub fn row_chunks_mut( &mut self, chunk_size: usize ) -> impl '_ + DoubleEndedIterator<Item = MatMut<'_, E>>
Returns an iterator that provides successive chunks of the rows of a mutable view over
this matrix, with each having at most chunk_size rows.
If the number of rows is a multiple of chunk_size, then all chunks have chunk_size
rows.
sourcepub fn par_row_chunks(
&self,
chunk_size: usize
) -> impl '_ + IndexedParallelIterator<Item = MatRef<'_, E>>
pub fn par_row_chunks( &self, chunk_size: usize ) -> impl '_ + IndexedParallelIterator<Item = MatRef<'_, E>>
Returns a parallel iterator that provides successive chunks of the rows of a view over this
matrix, with each having at most chunk_size rows.
If the number of rows is a multiple of chunk_size, then all chunks have chunk_size
rows.
Only available with the rayon feature.
sourcepub fn par_row_chunks_mut(
&mut self,
chunk_size: usize
) -> impl '_ + IndexedParallelIterator<Item = MatMut<'_, E>>
pub fn par_row_chunks_mut( &mut self, chunk_size: usize ) -> impl '_ + IndexedParallelIterator<Item = MatMut<'_, E>>
Returns a parallel iterator that provides successive chunks of the rows of a mutable view
over this matrix, with each having at most chunk_size rows.
If the number of rows is a multiple of chunk_size, then all chunks have chunk_size
rows.
Only available with the rayon feature.
Trait Implementations§
source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Add<&Matrix<Rhs>> for &Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Add<&Matrix<Rhs>> for &Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatAdd<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatAdd<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
+ operator.source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Add<&Matrix<Rhs>> for Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Add<&Matrix<Rhs>> for Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatAdd<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatAdd<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
+ operator.source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Add<Matrix<Rhs>> for &Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Add<Matrix<Rhs>> for &Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatAdd<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatAdd<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
+ operator.source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Add<Matrix<Rhs>> for Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Add<Matrix<Rhs>> for Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatAdd<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatAdd<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
+ operator.source§impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> AddAssign<&Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatAddAssign<Rhs::Kind>,
impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> AddAssign<&Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatAddAssign<Rhs::Kind>,
source§fn add_assign(&mut self, rhs: &Matrix<Rhs>)
fn add_assign(&mut self, rhs: &Matrix<Rhs>)
+= operation. Read moresource§impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> AddAssign<Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatAddAssign<Rhs::Kind>,
impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> AddAssign<Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatAddAssign<Rhs::Kind>,
source§fn add_assign(&mut self, rhs: Matrix<Rhs>)
fn add_assign(&mut self, rhs: Matrix<Rhs>)
+= operation. Read moresource§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Mul<&Matrix<Rhs>> for &Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Mul<&Matrix<Rhs>> for &Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatMul<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatMul<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
* operator.source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Mul<&Matrix<Rhs>> for Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Mul<&Matrix<Rhs>> for Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatMul<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatMul<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
* operator.source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Mul<Matrix<Rhs>> for &Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Mul<Matrix<Rhs>> for &Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatMul<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatMul<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
* operator.source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Mul<Matrix<Rhs>> for Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Mul<Matrix<Rhs>> for Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatMul<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatMul<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
* operator.source§impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> MulAssign<&Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatMulAssign<Rhs::Kind>,
impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> MulAssign<&Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatMulAssign<Rhs::Kind>,
source§fn mul_assign(&mut self, rhs: &Matrix<Rhs>)
fn mul_assign(&mut self, rhs: &Matrix<Rhs>)
*= operation. Read moresource§impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> MulAssign<Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatMulAssign<Rhs::Kind>,
impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> MulAssign<Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatMulAssign<Rhs::Kind>,
source§fn mul_assign(&mut self, rhs: Matrix<Rhs>)
fn mul_assign(&mut self, rhs: Matrix<Rhs>)
*= operation. Read moresource§impl<Mat: GenericMatrix> Neg for &Matrix<Mat>
impl<Mat: GenericMatrix> Neg for &Matrix<Mat>
source§impl<Mat: GenericMatrix> Neg for Matrix<Mat>
impl<Mat: GenericMatrix> Neg for Matrix<Mat>
source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> PartialEq<Matrix<Rhs>> for Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> PartialEq<Matrix<Rhs>> for Matrix<Lhs>
source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Sub<&Matrix<Rhs>> for &Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Sub<&Matrix<Rhs>> for &Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatSub<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatSub<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
- operator.source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Sub<&Matrix<Rhs>> for Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Sub<&Matrix<Rhs>> for Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatSub<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatSub<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
- operator.source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Sub<Matrix<Rhs>> for &Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Sub<Matrix<Rhs>> for &Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatSub<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatSub<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
- operator.source§impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Sub<Matrix<Rhs>> for Matrix<Lhs>
impl<Lhs: GenericMatrix, Rhs: GenericMatrix> Sub<Matrix<Rhs>> for Matrix<Lhs>
§type Output = <<<Lhs as GenericMatrix>::Kind as MatSub<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
type Output = <<<Lhs as GenericMatrix>::Kind as MatSub<<Rhs as GenericMatrix>::Kind>>::Output as MatrixKind>::Own<<<Lhs as GenericMatrix>::Elem as Conjugate>::Canonical>
- operator.source§impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> SubAssign<&Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatSubAssign<Rhs::Kind>,
impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> SubAssign<&Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatSubAssign<Rhs::Kind>,
source§fn sub_assign(&mut self, rhs: &Matrix<Rhs>)
fn sub_assign(&mut self, rhs: &Matrix<Rhs>)
-= operation. Read moresource§impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> SubAssign<Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatSubAssign<Rhs::Kind>,
impl<Lhs: GenericMatrixMut, Rhs: GenericMatrix> SubAssign<Matrix<Rhs>> for Matrix<Lhs>where
Lhs::Elem: ComplexField,
Rhs::Elem: Conjugate<Canonical = Lhs::Elem>,
Lhs::Kind: MatSubAssign<Rhs::Kind>,
source§fn sub_assign(&mut self, rhs: Matrix<Rhs>)
fn sub_assign(&mut self, rhs: Matrix<Rhs>)
-= operation. Read more