pub trait Matrix: VectorSpace + Index<usize, Output = Self::Column, Output = Self::Column> + IndexMut<usize> where
    Self::Scalar: Float
{ type Row: VectorSpace + Array
    where
        <Self::Row as VectorSpace>::Scalar == Self::Scalar,
        <Self::Row as Array>::Element == Self::Scalar
; type Column: VectorSpace + Array
    where
        <Self::Column as VectorSpace>::Scalar == Self::Scalar,
        <Self::Column as Array>::Element == Self::Scalar
; type Transpose: Matrix
    where
        <Self::Transpose as VectorSpace>::Scalar == Self::Scalar,
        <Self::Transpose as Matrix>::Row == Self::Column,
        <Self::Transpose as Matrix>::Column == Self::Row
; fn row(&self, r: usize) -> Self::Row; fn swap_rows(&mut self, a: usize, b: usize); fn swap_columns(&mut self, a: usize, b: usize); fn swap_elements(&mut self, a: (usize, usize), b: (usize, usize)); fn transpose(&self) -> Self::Transpose; fn as_ptr(&self) -> *const Self::Scalar { ... } fn as_mut_ptr(&mut self) -> *mut Self::Scalar { ... } fn replace_col(&mut self, c: usize, src: Self::Column) -> Self::Column { ... } }
Expand description

A column-major matrix of arbitrary dimensions.

Because this is constrained to the VectorSpace trait, this means that following operators are required to be implemented:

Matrix addition:

  • Add<Output = Self>
  • Sub<Output = Self>
  • Neg<Output = Self>

Scalar multiplication:

  • Mul<Self::Scalar, Output = Self>
  • Div<Self::Scalar, Output = Self>
  • Rem<Self::Scalar, Output = Self>

Note that matrix multiplication is not required for implementors of this trait. This is due to the complexities of implementing these operators with Rust’s current type system. For the multiplication of square matrices, see SquareMatrix.

Required Associated Types

The row vector of the matrix.

The column vector of the matrix.

The result of transposing the matrix

Required Methods

Get a row from this matrix by-value.

Swap two rows of this array.

Swap two columns of this array.

Swap the values at index a and b

Transpose this matrix, returning a new matrix.

Provided Methods

Get the pointer to the first element of the array.

Get a mutable pointer to the first element of the array.

Replace a column in the array.

Implementors