Trait smawk::Matrix

source ·
pub trait Matrix<T: Copy> {
    // Required methods
    fn nrows(&self) -> usize;
    fn ncols(&self) -> usize;
    fn index(&self, row: usize, column: usize) -> T;
}
Expand description

Minimal matrix trait for two-dimensional arrays.

This provides the functionality needed to represent a read-only numeric matrix. You can query the size of the matrix and access elements. Modeled after [ndarray::Array2] from the ndarray crate.

Enable the ndarray Cargo feature if you want to use it with ndarray::Array2.

Required Methods§

source

fn nrows(&self) -> usize

Return the number of rows.

source

fn ncols(&self) -> usize

Return the number of columns.

source

fn index(&self, row: usize, column: usize) -> T

Return a matrix element.

Implementations on Foreign Types§

source§

impl<T: Copy> Matrix<T> for Vec<Vec<T>>

Simple and inefficient matrix representation used for doctest examples and simple unit tests.

You should prefer implementing it yourself, or you can enable the ndarray Cargo feature and use the provided implementation for [ndarray::Array2].

source§

fn nrows(&self) -> usize

source§

fn ncols(&self) -> usize

source§

fn index(&self, row: usize, column: usize) -> T

Implementors§