5#include <initializer_list>
7#include <stratax/core/dtypes/Concepts.hpp>
8#include <stratax/core/ArrayBase.hpp>
9#include <stratax/core/Shape.hpp>
10#include <stratax/core/validation/Validation.hpp>
11#include <stratax/exceptions/Exceptions.hpp>
13namespace stratax::container {
81 std::initializer_list<std::initializer_list<value_type>> list)
86 for (
const auto& row : list)
88 if (row.size() !=
cols)
91 "Matrix initializer rows must all have the same number of columns.");
109 "Matrix shape must be rank 2.");
121 using core::ArrayBase<T>
::at;
183 Matrix(std::initializer_list<std::initializer_list<value_type>> list)
184 : core::
ArrayBase<T>(initializer_shape(list))
188 for (
const auto& row : list)
190 for (
const auto& value : row)
192 (*this)[index++] = value;
Matrix(size_type rows, size_type cols)
Constructs a value-initialized matrix with the requested dimensions.
typename core::ArrayBase< T >::pointer pointer
Mutable element pointer type.
friend void swap(Matrix &lhs, Matrix &rhs) noexcept
Exchanges two matrices using argument-dependent lookup.
typename core::ArrayBase< T >::const_pointer const_pointer
Read-only element pointer type.
typename core::ArrayBase< T >::const_iterator const_iterator
Read-only contiguous random-access iterator type.
typename core::ArrayBase< T >::difference_type difference_type
Signed type used for checked indices and iterator distances.
Matrix()
Constructs an empty matrix with shape {0, 0}.
typename core::ArrayBase< T >::const_reverse_iterator const_reverse_iterator
Read-only reverse iterator type.
typename core::ArrayBase< T >::value_type value_type
Stored element type inherited from ArrayBase.
typename core::ArrayBase< T >::iterator iterator
Mutable contiguous random-access iterator type.
typename core::ArrayBase< T >::reference reference
Mutable element reference type.
Matrix(std::initializer_list< std::initializer_list< value_type > > list)
Constructs a matrix by copying a rectangular nested initializer.
size_type rows() const noexcept
Returns the number of rows.
size_type cols() const noexcept
Returns the number of columns.
Matrix(const core::Shape &shape)
Constructs a value-initialized matrix from a rank-two shape.
typename core::ArrayBase< T >::size_type size_type
Unsigned type used for element counts and indices.
void swap(Matrix &other) noexcept
Exchanges storage and layout metadata with other.
const_reference operator()(size_type row, size_type col) const
Returns an element using unchecked row and column indices.
const_reference at(difference_type row, difference_type col) const
Returns an element using checked, Python-style indices.
typename core::ArrayBase< T >::reverse_iterator reverse_iterator
Mutable reverse iterator type.
typename core::ArrayBase< T >::const_reference const_reference
Read-only element reference type.
reference at(difference_type row, difference_type col)
Returns an element using checked, Python-style indices.
Matrix(size_type rows, size_type cols, const_reference value)
Constructs a matrix filled with copies of value.
reference operator()(size_type row, size_type col)
Returns an element using unchecked row and column indices.
Shared owning storage and layout base for Stratax array containers.
typename Buffer< T >::value_type value_type
Stored element type.
typename Buffer< value_type >::pointer pointer
Mutable element pointer type.
typename Buffer< value_type >::const_reference const_reference
Read-only element reference type.
ArrayBase(const Shape &shape)
Constructs value-initialized storage for shape.
const Shape & shape() const noexcept
Returns the logical shape metadata.
typename Buffer< value_type >::reverse_iterator reverse_iterator
Mutable reverse iterator type.
typename Buffer< value_type >::const_reverse_iterator const_reverse_iterator
Read-only reverse iterator type.
size_type normalized_flat_offset(const IndexContainer &raw_indices, const char *rank_mismatch_message="Multi-index rank must match array rank.", const char *component_oob_message=nullptr) const
Converts checked signed multidimensional indices to a flat offset.
typename Buffer< value_type >::const_pointer const_pointer
Read-only element pointer type.
typename Buffer< value_type >::difference_type difference_type
Signed type used for checked indices and iterator distances.
typename Buffer< value_type >::iterator iterator
Mutable contiguous random-access iterator type.
typename Buffer< value_type >::const_iterator const_iterator
Read-only contiguous random-access iterator type.
typename Buffer< value_type >::reference reference
Mutable element reference type.
void swap(ArrayBase &other) noexcept
Exchanges storage and layout metadata with other.
typename Buffer< value_type >::size_type size_type
Unsigned type used for element counts and indices.
Stores the dimensions of a multidimensional array.
size_type rank() const noexcept
Returns the number of dimensions.