Struct ratio_matrix::Matrix

source ·
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>

source

pub fn index<T: Into<MatrixCoordinates>>( &self, coordinates: T, ) -> Result<usize, CoordinatesOutOfBoundsError>

Get the vector index based on a set of coordinates.

source

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<C: Clone> Clone for Matrix<C>

source§

fn clone(&self) -> Matrix<C>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<C: Debug> Debug for Matrix<C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<C: Default> Default for Matrix<C>

source§

fn default() -> Matrix<C>

Returns the “default value” for a type. Read more
source§

impl<'de, C> Deserialize<'de> for Matrix<C>
where Matrix<C>: Default, C: Deserialize<'de>,

source§

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>

source§

fn row_range(&self) -> Range<usize>

Range of rows included in this object’s domain.
source§

fn col_range(&self) -> Range<usize>

Range of columns included in this object’s domain.
source§

fn range(&self) -> MatrixRange

The area spanned by this domain.
source§

fn start(&self) -> MatrixCoordinates

Starting coordinate of this domain (inclusive).
source§

fn end(&self) -> MatrixCoordinates

Ending coordinate of this domain (exclusive).
source§

fn middle(&self) -> (f64, f64)

The middle point of this cluster as a tuple of (rows, columns), fractional.
source§

impl<C> Matrix2D<C> for Matrix<C>

source§

fn new(values: Vec<C>, n_cols: usize) -> Result<Self, MatrixDimensionError>

Create a new matrix from this value slice with the given number of columns in a row.
source§

impl<C> MatrixMut<C> for Matrix<C>

source§

fn set<T: Into<MatrixCoordinates>>( &mut self, coordinates: T, value: C, ) -> Result<C, CoordinatesOutOfBoundsError>

Set a certain cell’s value.
source§

impl<C> MatrixRef<C> for Matrix<C>

source§

fn get<T: Into<MatrixCoordinates>>( &self, coordinates: T, ) -> Result<&C, CoordinatesOutOfBoundsError>

Get a matrix value at this coordinate.
source§

impl<C: PartialEq> PartialEq for Matrix<C>

source§

fn eq(&self, other: &Matrix<C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<C> Serialize for Matrix<C>
where C: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<D, T> Contains2D<D> for T
where D: Domain2D, T: Domain2D,

source§

fn contains(&self, other: &D) -> bool

Whether this instance contains or covers the other.
source§

impl<T> Contains2D<MatrixCoordinates> for T
where T: Domain2D,

source§

fn contains(&self, other: &MatrixCoordinates) -> bool

Whether this instance contains or covers the other.
source§

impl<D> Dimensions2D for D
where D: Domain2D,

source§

fn n_rows(&self) -> usize

Number of rows in the output.
source§

fn n_cols(&self) -> usize

Number of columns in the output.
source§

fn dimensions(&self) -> MatrixDimensions

Dimensions of the output as a dimensions object.
source§

fn len(&self) -> usize

Length of these dimensions if it were a 1D vector.
source§

fn is_empty(&self) -> bool

Whether these dimensions are (0,0).
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,