8#include <initializer_list>
15namespace stratax::container {
83 std::initializer_list<std::initializer_list<value_type>> list)
88 for (
const auto& row : list)
90 if (row.size() !=
cols)
93 "Matrix initializer rows must have equal lengths.");
139 Matrix moved(std::move(other));
204 Matrix(std::initializer_list<std::initializer_list<value_type>> list)
205 : core::
ArrayBase<T>(initializer_shape(list))
209 for (
const auto& row : list)
211 for (
const auto& value : row)
213 (*this)[index++] = value;
Shared owning storage and row-major metadata for containers.
Dtype and array interface concepts.
Stratax exception types derived from std::runtime_error.
Immutable dimension metadata and checked row-major strides.
Number of axes or supplied multidimensional indices does not match the required rank.
Shape incompatible with the requested operation or container.
Two-dimensional owning array of supported dtype 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.
Matrix & operator=(const Matrix &)=default
Replaces values and metadata with a deep copy; allocation failure leaves this object unchanged.
typename core::ArrayBase< T >::iterator iterator
Mutable contiguous random-access iterator type.
Matrix(Matrix &&other)
Transfers storage and leaves the source with shape {0, 0}.
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.
Matrix(const Matrix &)=default
Copies values and metadata into independent storage.
const_reference operator()(size_type row, size_type col) const
Returns an element using unchecked row and column indices.
Matrix & operator=(Matrix &&other)
Transfers storage and preserves both matrices' rank invariants.
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.
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.
ArrayBase(const ArrayBase &)=default
Copies storage and layout into independent buffers.
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.
Supported numeric or boolean element dtype.