pub struct Matrix<C> {
pub values: Vec<C>,
pub dimensions: MatrixDimensions,
}
Expand description
Two-dimensional matrix.
Fields§
§values: Vec<C>
Matrix values as a single vector.
dimensions: MatrixDimensions
Matrix dimensions.
Implementations§
Source§impl<C> Matrix<C>
impl<C> Matrix<C>
Sourcepub fn index<T: Into<MatrixCoordinates>>(
&self,
coordinates: T,
) -> Result<usize, CoordinatesOutOfBoundsError>
pub fn index<T: Into<MatrixCoordinates>>( &self, coordinates: T, ) -> Result<usize, CoordinatesOutOfBoundsError>
Get the vector index based on a set of coordinates.
Sourcepub fn slice<R: Into<MatrixRange>>(
&self,
range: R,
) -> Result<MatrixSlice<'_, C>, MatrixSliceError>
pub fn slice<R: Into<MatrixRange>>( &self, range: R, ) -> Result<MatrixSlice<'_, C>, MatrixSliceError>
Slice this matrix to these rows and columns.
Trait Implementations§
Source§impl<'de, C> Deserialize<'de> for Matrix<C>
impl<'de, C> Deserialize<'de> for Matrix<C>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<C> Domain2D for Matrix<C>
impl<C> Domain2D for Matrix<C>
Source§fn range(&self) -> MatrixRange
fn range(&self) -> MatrixRange
The area spanned by this domain.
Source§fn start(&self) -> MatrixCoordinates
fn start(&self) -> MatrixCoordinates
Starting coordinate of this domain (inclusive).
Source§fn end(&self) -> MatrixCoordinates
fn end(&self) -> MatrixCoordinates
Ending coordinate of this domain (exclusive).
Source§impl<C> MatrixMut<C> for Matrix<C>
impl<C> MatrixMut<C> for Matrix<C>
Source§fn set<T: Into<MatrixCoordinates>>(
&mut self,
coordinates: T,
value: C,
) -> Result<C, CoordinatesOutOfBoundsError>
fn set<T: Into<MatrixCoordinates>>( &mut self, coordinates: T, value: C, ) -> Result<C, CoordinatesOutOfBoundsError>
Set a certain cell’s value.
Coordinates should be row and column indices with respect to the source matrix.
Source§impl<C> MatrixRef<C> for Matrix<C>
impl<C> MatrixRef<C> for Matrix<C>
Source§fn get<T: Into<MatrixCoordinates>>(
&self,
coordinates: T,
) -> Result<&C, CoordinatesOutOfBoundsError>
fn get<T: Into<MatrixCoordinates>>( &self, coordinates: T, ) -> Result<&C, CoordinatesOutOfBoundsError>
Get a matrix value at these coordinates.
Coordinates should be row and column indices with respect to the source matrix.
impl<C> StructuralPartialEq for Matrix<C>
Auto Trait Implementations§
impl<C> Freeze for Matrix<C>
impl<C> RefUnwindSafe for Matrix<C>where
C: RefUnwindSafe,
impl<C> Send for Matrix<C>where
C: Send,
impl<C> Sync for Matrix<C>where
C: Sync,
impl<C> Unpin for Matrix<C>where
C: Unpin,
impl<C> UnwindSafe for Matrix<C>where
C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<D, T> Contains2D<D> for T
impl<D, T> Contains2D<D> for T
Source§impl<T> Contains2D<MatrixCoordinates> for Twhere
T: Domain2D,
impl<T> Contains2D<MatrixCoordinates> for Twhere
T: Domain2D,
Source§impl<D> Dimensions2D for Dwhere
D: Domain2D,
impl<D> Dimensions2D for Dwhere
D: Domain2D,
Source§fn dimensions(&self) -> MatrixDimensions
fn dimensions(&self) -> MatrixDimensions
Dimensions of the output as a dimensions object.