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/exceptions/Exceptions.hpp>
12namespace stratax::container {
80 std::initializer_list<std::initializer_list<value_type>> list)
85 for (
const auto& row : list)
87 if (row.size() !=
cols)
90 "Matrix initializer rows must have equal lengths.");
170 Matrix(std::initializer_list<std::initializer_list<value_type>> list)
171 : core::
ArrayBase<T>(initializer_shape(list))
175 for (
const auto& row : list)
177 for (
const auto& value : row)
179 (*this)[index++] = value;
Two-dimensional owning array of numeric values.
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.
typename Buffer< value_type >::const_pointer const_pointer
Read-only element pointer type.
size_type normalized_flat_offset(const IndexContainer &raw_indices) const
Converts checked signed multidimensional indices to a flat offset.
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.
const_iterator begin() const noexcept
Returns a const iterator to the first dimension.