Trait scirust::matrix::traits::Shape [] [src]

pub trait Shape<T: MagmaBase> {
    fn num_rows(&self) -> usize;
    fn num_cols(&self) -> usize;
    fn size(&self) -> (usize, usize);
    fn num_cells(&self) -> usize;
    unsafe fn get_unchecked(&self, r: usize, c: usize) -> T;
    fn set(&mut self, r: usize, c: usize, value: T);

    fn is_row(&self) -> bool { ... }
    fn is_col(&self) -> bool { ... }
    fn is_scalar(&self) -> bool { ... }
    fn is_vector(&self) -> bool { ... }
    fn is_empty(&self) -> bool { ... }
    fn is_square(&self) -> bool { ... }
    fn get(&self, r: usize, c: usize) -> Option<T> { ... }
    fn index_to_cell(&self, index: usize) -> (usize, usize) { ... }
    fn cell_to_index(&self, r: usize, c: usize) -> usize { ... }
    fn smaller_dim(&self) -> usize { ... }
    fn larger_dim(&self) -> usize { ... }
}

Defines the features which all matrix types must implement. This API focuses only on the shape of the matrix.

Required Methods

fn num_rows(&self) -> usize

Returns the number of rows

fn num_cols(&self) -> usize

Returns the number of columns

fn size(&self) -> (usize, usize)

Returns the size in an (r, c) tuple

fn num_cells(&self) -> usize

Returns the number of cells in matrix

unsafe fn get_unchecked(&self, r: usize, c: usize) -> T

Gets an element by its row and column number Assumes that the caller knows that (r, c) indices are proper

fn set(&mut self, r: usize, c: usize, value: T)

Sets an element in the view

Provided Methods

fn is_row(&self) -> bool

Indicates if the matrix is a row vector

fn is_col(&self) -> bool

Indicates if the matrix is a column vector

fn is_scalar(&self) -> bool

Indicates if the matrix is a scalar actually

fn is_vector(&self) -> bool

Indicates if the matrix is a vector

fn is_empty(&self) -> bool

Indicates if the matrix is empty

fn is_square(&self) -> bool

Indicates if the matrix is square

fn get(&self, r: usize, c: usize) -> Option<T>

Gets an element by its row and column number Returns data if array bounds are followed.

fn index_to_cell(&self, index: usize) -> (usize, usize)

Converts an index to cell address (row, column)

fn cell_to_index(&self, r: usize, c: usize) -> usize

Converts a cell address to an index (r, c) to index

fn smaller_dim(&self) -> usize

Returns the minimum of rows and columns

fn larger_dim(&self) -> usize

Returns the larger of rows and columns

Implementors