pub trait Matrix<T> {
// Required methods
fn num_rows(&self) -> usize;
fn num_cols(&self) -> usize;
fn at(&self, idx: impl IntoIdx<D2>) -> T;
fn all(&self) -> impl Iterator<Item = T>;
// Provided methods
fn in_bounds(&self, idx: impl Into<<D2 as Dim>::LeqIdx>) -> bool { ... }
fn try_at(&self, idx: impl IntoIdx<D2>) -> Option<T> { ... }
fn equality(&self, other: &impl Matrix<T>) -> Equality<D2>
where T: PartialEq { ... }
}
Expand description
A matrix or a matrix view over a D2
vector with rectangular cardinality,
or over a flattened representation by a D1
vector.
An owned matrix can be created by:
- calling
into_matrix
method on aD2
vector implementingNVec<D2, _>
, or equivalently,V2<_>
; or by: - calling
v1_into_matrix
method on aD1
vector implementingNVec<D1, _>
, or equivalently,V1<_>
.
Alternatively, matrix views can be created by:
- calling
as_matrix
oras_matrix_col_major
methods on aD2
vector; or by: - calling
as_matrix
oras_matrix_col_major
methods on aD1
vector.
All above mentioned methods have their _mut
versions to create a
mutable matrix view.
Required Methods§
Sourcefn all(&self) -> impl Iterator<Item = T>
fn all(&self) -> impl Iterator<Item = T>
Returns an iterator of all elements of the matrix. The direction of iteration depends on whether the matrix is row-major or column-major.
Row-major matrices are created by:
Column-major matrices are created by:
- calling
as_matrix_col_major
on aD2
vector, or - calling
as_matrix_col_major
on aD1
vector.
All above mentioned methods have their _mut
versions to create a
mutable matrix view.
Provided Methods§
Sourcefn in_bounds(&self, idx: impl Into<<D2 as Dim>::LeqIdx>) -> bool
fn in_bounds(&self, idx: impl Into<<D2 as Dim>::LeqIdx>) -> bool
Returns true if the given idx
is in bounds of the matrix.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.