|
Stratax 0.2.0
|
Stores a rank-2 Stratax array in row-major order. More...
#include <Matrix.hpp>
Public Types | |
| using | value_type = T |
| Element type stored by the matrix. | |
| using | iterator = typename core::Buffer<T>::iterator |
| Mutable iterator over matrix elements. | |
| using | const_iterator = typename core::Buffer<T>::const_iterator |
| Const iterator over matrix elements. | |
| using | reverse_iterator = typename core::Buffer<T>::reverse_iterator |
| Mutable reverse iterator over matrix elements. | |
| using | const_reverse_iterator = typename core::Buffer<T>::const_reverse_iterator |
| Const reverse iterator over matrix elements. | |
| template<typename U> | |
| using | rebind = Matrix<U> |
| Rebinds the matrix container to another element type. | |
Public Member Functions | |
| Matrix () | |
| Creates a default rank-2 empty matrix. | |
| Matrix (std::size_t rows, std::size_t cols) | |
| Creates a rank-2 matrix with the given number of rows and columns. | |
| Matrix (const core::Shape &shape) | |
| Creates a matrix from a validated rank-2 shape. | |
| Matrix (std::size_t rows, std::size_t cols, const T &value) | |
| Creates a matrix and fills it with a value. | |
| Matrix (std::initializer_list< std::initializer_list< T > > list) | |
| Creates a matrix from a nested initializer list. | |
| Matrix (const Matrix &)=default | |
| Creates a copy of another matrix. | |
| Matrix (Matrix &&) noexcept=default | |
| Transfers ownership from another matrix. | |
| Matrix & | operator= (const Matrix &)=default |
| Replaces this matrix with a copy of another matrix. | |
| Matrix & | operator= (Matrix &&) noexcept=default |
| Replaces this matrix by taking ownership from another matrix. | |
| ~Matrix ()=default | |
| Destroys the matrix. | |
| std::size_t | size () const noexcept |
| Returns the total number of elements in the matrix. | |
| bool | empty () const noexcept |
| Returns whether the matrix contains no elements. | |
| std::size_t | rows () const noexcept |
| Returns the number of rows. | |
| std::size_t | cols () const noexcept |
| Returns the number of columns. | |
| const stratax::core::Shape & | shape () const noexcept |
| Returns the matrix shape. | |
| const stratax::core::Strides & | strides () const noexcept |
| Returns the matrix strides. | |
| std::size_t | rank () const noexcept |
| Returns the matrix rank. | |
| T & | operator() (std::size_t row, std::size_t col) |
| Returns an element by row and column with bounds checking. | |
| const T & | operator() (std::size_t row, std::size_t col) const |
| Returns an element by row and column with bounds checking. | |
| T & | operator[] (std::size_t index) noexcept |
| Returns a flat element without bounds checking. | |
| const T & | operator[] (std::size_t index) const noexcept |
| Returns a flat element without bounds checking. | |
| T & | at (std::ptrdiff_t row, std::ptrdiff_t col) |
| Returns an element by row and column. | |
| const T & | at (std::ptrdiff_t row, std::ptrdiff_t col) const |
| Returns an element by row and column. | |
| T & | front () |
| Returns the first element. | |
| const T & | front () const |
| Returns the first element as a const reference. | |
| T & | back () |
| Returns the last element. | |
| const T & | back () const |
| Returns the last element as a const reference. | |
| T * | data () noexcept |
| Returns the raw data pointer. | |
| const T * | data () const noexcept |
| Returns the raw data pointer as a const pointer. | |
| iterator | begin () noexcept |
| Returns an iterator to the first element. | |
| const_iterator | begin () const noexcept |
| Returns a const iterator to the first element. | |
| const_iterator | cbegin () const noexcept |
| Returns a const iterator to the first element. | |
| iterator | end () noexcept |
| Returns an iterator one past the last element. | |
| const_iterator | end () const noexcept |
| Returns a const iterator one past the last element. | |
| const_iterator | cend () const noexcept |
| Returns a const iterator one past the last element. | |
| reverse_iterator | rbegin () noexcept |
| Returns a reverse iterator to the last element. | |
| const_reverse_iterator | rbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| const_reverse_iterator | crbegin () const noexcept |
| Returns a const reverse iterator to the last element. | |
| reverse_iterator | rend () noexcept |
| Returns a reverse iterator before the first element. | |
| const_reverse_iterator | rend () const noexcept |
| Returns a const reverse iterator before the first element. | |
| const_reverse_iterator | crend () const noexcept |
| Returns a const reverse iterator before the first element. | |
| void | fill (const T &value) |
| Fills every element with the same value. | |
| void | swap (Matrix &other) noexcept |
| Swaps the contents of two matrices. | |
Stores a rank-2 Stratax array in row-major order.
Matrix owns contiguous storage together with shape and stride metadata, making it suitable for generic array operations and two-dimensional indexing.
| T | Numeric element type. |
Definition at line 28 of file Matrix.hpp.
| using stratax::container::Matrix< T >::const_iterator = typename core::Buffer<T>::const_iterator |
Const iterator over matrix elements.
Definition at line 43 of file Matrix.hpp.
| using stratax::container::Matrix< T >::const_reverse_iterator = typename core::Buffer<T>::const_reverse_iterator |
Const reverse iterator over matrix elements.
Definition at line 49 of file Matrix.hpp.
| using stratax::container::Matrix< T >::iterator = typename core::Buffer<T>::iterator |
Mutable iterator over matrix elements.
Definition at line 40 of file Matrix.hpp.
Rebinds the matrix container to another element type.
Definition at line 53 of file Matrix.hpp.
| using stratax::container::Matrix< T >::reverse_iterator = typename core::Buffer<T>::reverse_iterator |
Mutable reverse iterator over matrix elements.
Definition at line 46 of file Matrix.hpp.
| using stratax::container::Matrix< T >::value_type = T |
Element type stored by the matrix.
Definition at line 37 of file Matrix.hpp.
|
inline |
Creates a default rank-2 empty matrix.
The default matrix has shape (0, 0) and owns no element storage.
Definition at line 60 of file Matrix.hpp.
|
inline |
Creates a rank-2 matrix with the given number of rows and columns.
| rows | Number of rows. |
| cols | Number of columns. |
Definition at line 68 of file Matrix.hpp.
|
inlineexplicit |
Creates a matrix from a validated rank-2 shape.
| shape | Source shape. |
| Exceptions::DimensionError | If the shape is not rank 2. |
Definition at line 82 of file Matrix.hpp.
|
inline |
Creates a matrix and fills it with a value.
| rows | Number of rows. |
| cols | Number of columns. |
| value | Value to copy into each element. |
Definition at line 99 of file Matrix.hpp.
|
inline |
Creates a matrix from a nested initializer list.
Rows are interpreted in row-major order and must all have the same length.
| list | Row-major source values. |
| Exceptions::StrataxError | If the rows are not rectangular. |
Definition at line 115 of file Matrix.hpp.
|
inline |
Returns an element by row and column.
| row | Row index. |
| col | Column index. |
| Exceptions::IndexError | If either index is out of bounds. |
Definition at line 307 of file Matrix.hpp.
|
inline |
Returns an element by row and column.
| row | Row index. |
| col | Column index. |
| Exceptions::IndexError | If either index is out of bounds. |
Definition at line 325 of file Matrix.hpp.
|
inline |
Returns the last element.
| Exceptions::IndexError | If the matrix is empty. |
Definition at line 372 of file Matrix.hpp.
|
inline |
Returns the last element as a const reference.
| Exceptions::IndexError | If the matrix is empty. |
Definition at line 388 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element.
Definition at line 433 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator to the first element.
Definition at line 423 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator to the first element.
Definition at line 443 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator one past the last element.
Definition at line 473 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Returns a const reverse iterator to the last element.
Definition at line 503 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator before the first element.
Definition at line 533 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns the raw data pointer as a const pointer.
Definition at line 413 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns the raw data pointer.
Definition at line 403 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns whether the matrix contains no elements.
Definition at line 185 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns a const iterator one past the last element.
Definition at line 463 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns an iterator one past the last element.
Definition at line 453 of file Matrix.hpp.
|
inline |
Fills every element with the same value.
| value | Value to assign to each element. |
Definition at line 543 of file Matrix.hpp.
|
inline |
Returns the first element.
| Exceptions::IndexError | If the matrix is empty. |
Definition at line 340 of file Matrix.hpp.
|
inline |
Returns the first element as a const reference.
| Exceptions::IndexError | If the matrix is empty. |
Definition at line 356 of file Matrix.hpp.
|
inline |
Returns an element by row and column with bounds checking.
| row | Row index. |
| col | Column index. |
| Exceptions::IndexError | If either index is out of bounds. |
Definition at line 249 of file Matrix.hpp.
|
inline |
Returns an element by row and column with bounds checking.
| row | Row index. |
| col | Column index. |
| Exceptions::IndexError | If either index is out of bounds. |
Definition at line 265 of file Matrix.hpp.
|
inlinenoexcept |
Returns a flat element without bounds checking.
| index | Flat element index. |
Definition at line 293 of file Matrix.hpp.
|
inlinenoexcept |
Returns a flat element without bounds checking.
| index | Flat element index. |
Definition at line 280 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns the matrix rank.
Definition at line 235 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator to the last element.
Definition at line 493 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns a reverse iterator to the last element.
Definition at line 483 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns a const reverse iterator before the first element.
Definition at line 523 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns a reverse iterator before the first element.
Definition at line 513 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
|
inlinenoexcept |
Returns the matrix shape.
Definition at line 215 of file Matrix.hpp.
|
inlinenodiscardnoexcept |
Returns the total number of elements in the matrix.
Definition at line 175 of file Matrix.hpp.
|
inlinenoexcept |
Returns the matrix strides.
Definition at line 225 of file Matrix.hpp.
|
inlinenoexcept |
Swaps the contents of two matrices.
| other | Matrix to exchange state with. |
Definition at line 553 of file Matrix.hpp.