Expand description
The matrix crate provides a generic multidimensional tensor, and the matrix concrete implementation of that type, along with various quality-of-life methods and accessors for the matrix type. It was initially developed for use implementing solutions for the annual advent-of-code challenges, and was heavily inspired and adapted from https://github.com/Daedelus1/RustTensors
Structs§
- Column
- Column is a quality-of-life assistant to ease processing matrices in a column-major fashion.
- Dense
Matrix - DenseMatrix pre-allocates storage for every storage cell.
- Error
- Error is a simple type to prevent Result<T, String> in our signatures.
- Format
Options - FormatOptions controls the parsing and string formatting of matrices.
- Matrix
Address - MatrixAddress references a cell in a matrix by its row and column. Rows are numbered from zero at the top, and columns are numbered from zero at the left. Thus (0, 0), the origin, is positioned at the upper-left of the matrix. Any built in numeric or character type that fits in usize can be used as the index (thus in practice up to i16 / u16).
- Matrix
Column Iterator - Matrix
Columns Iterator - Matrix
Forward Indexed Iterator - MatrixForwardIndexedIterator returns (address, value) tuples for a matrix in row-major order, starting at the upper left origin (0,0).
- Matrix
Forward Iterator - MatrixForwardIterator returns the available addresses in a matrix in row-major format starting at the origin, or upper left (0, 0) address.
- Matrix
RowIterator - Matrix
Rows Iterator - Matrix
Value Iterator - MatrixValueIterator returns the values in a matrix in row-major order, starting at the upper left origin (0, 0).
- Row
- Row is a quality-of-life assistant to ease processing matrices in a row-major fashion.
Enums§
- Logical
Dimension - LogicalDimension lets you refer to the address dimensions of a matrix conceptually, rather than numerically.
Traits§
- Address
- Addresses must be convertible to and from a slice containing one V for each of the (fixed number) of dimensions for that Tensor.
- Checked
Mul - CheckedMul is a trait to capture the built-in checked_mul behavior provided for all intrinsic integer types in Rust, casting to usize. This is intended for computing matrix bounds for storage in a contiguous vector, whose upper-bound size is limited by usize.
- Coordinate
- Coordinate is the traits required to act as a dimensional index in a Matrix. All the built-in integral types should satisfy these.
- Matrix
- Matrix is a rectangular store of type T, providing a variety of useful iterator patterns.
- Matrix
Map - MatrixMap provides convenience functions to transform one matrix into another.
- Tensor
- Tensor is a generic multidimensional data store trait. Think of it as a shared interface for a vector, a matrix, a cube, and a hypercube.
- Unit
- Unit returns the natural “one” value for a given type. This in turn is used to increment and decrement values within a range to provide an iterator.
Functions§
- new_
default_ matrix - new_default_matrix creates a matrix of type T where all cells contain T::default() (typically a zero value).
- new_
matrix - new_matrix creates a matrix from a vector of values in row-major order. The length of data must be a multiple of rows, and that multiple will become the column_count.
- new_
transposed_ matrix
Type Aliases§
- Dimension
- Dimension is an axis of the storage. In a vector there’s a single Dimension (0) and it’s the horizontal position within the vector. For a matrix, there are two Dimensions, x and y (0 and 1, but whether 0 is x or 1 is an implementation detail).
- Result
- Result is a convenience placeholder for methods that use Error and the error result type.