16namespace stratax::core {
67 [[nodiscard]]
static constexpr std::string_view
dtype() noexcept
76 [[nodiscard]]
bool empty() const noexcept {
return buffer_.
empty();}
82 [[nodiscard]]
const Shape&
shape() const noexcept {
return shape_;}
85 [[nodiscard]]
const Shape&
strides() const noexcept {
return strides_;}
108 return buffer_.
front();
118 return buffer_.
front();
129 return buffer_.
back();
139 return buffer_.
back();
208 buffer_.
swap(other.buffer_);
209 shape_.
swap(other.shape_);
210 strides_.
swap(other.strides_);
248 : buffer_(
shape.elements()),
264 : buffer_(
shape.elements(), value),
285 : buffer_(std::move(buffer)),
292 "Buffer size does not match the shape's element count.");
309 template<
typename IndexContainer>
312 if (raw_indices.size() !=
rank())
315 "The number of indices must match the array rank.");
327 const size_type index = indexing::normalize_index(
328 raw_indices[i], shape_[i]);
329 offset += index * strides_[i];
Fixed-size aligned storage with element lifetime management.
Dtype and array interface concepts.
Compile-time metadata for supported dtypes.
Stratax exception types derived from std::runtime_error.
Checked signed index normalization.
Immutable dimension metadata and checked row-major strides.
Index or slice cannot be used for the requested access.
Number of axes or supplied multidimensional indices does not match the required rank.
Shape incompatible with the requested operation or container.
Shared owning storage and layout base for Stratax array containers.
reference back()
Returns the final element.
ArrayBase(const Shape &shape, const_reference value)
Constructs storage filled with value for shape.
reverse_iterator rend() noexcept
Returns the past-the-end mutable reverse iterator.
typename Buffer< T >::value_type value_type
Stored element type.
const_reverse_iterator crbegin() const noexcept
Returns a const reverse iterator to the final element.
const_iterator end() const noexcept
Returns a const iterator past the final element.
const_iterator begin() const noexcept
Returns a const iterator to the first element.
typename Buffer< value_type >::pointer pointer
Mutable element pointer type.
ArrayBase(const Shape &shape, Buffer< value_type > &&buffer)
Adopts an existing buffer for shape.
ArrayBase(ArrayBase &&) noexcept=default
Transfers storage and layout, leaving the source empty with rank zero.
typename Buffer< value_type >::const_reference const_reference
Read-only element reference type.
ArrayBase(const Shape &shape)
Constructs value-initialized storage for shape.
reference operator[](size_type index) noexcept
Returns an element without bounds checking.
const Shape & shape() const noexcept
Returns the logical shape metadata.
size_type size() const noexcept
Returns the number of stored elements.
typename Buffer< value_type >::reverse_iterator reverse_iterator
Mutable reverse iterator type.
bool empty() const noexcept
Reports whether no elements are stored.
const_iterator cbegin() const noexcept
Returns a const iterator to the first element.
void fill(const_reference value)
Assigns value to every stored element.
typename Buffer< value_type >::const_reverse_iterator const_reverse_iterator
Read-only reverse iterator type.
const_pointer data() const noexcept
Returns a pointer to contiguous read-only element storage.
const_iterator cend() const noexcept
Returns a const iterator past the final element.
pointer data() noexcept
Returns a pointer to contiguous mutable element storage.
typename Buffer< value_type >::const_pointer const_pointer
Read-only element pointer type.
size_type rank() const noexcept
Returns the number of logical dimensions.
const_reference operator[](size_type index) const noexcept
Returns an element without bounds checking.
iterator begin() noexcept
Returns a mutable iterator to the first element.
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.
const_reverse_iterator rbegin() const noexcept
Returns a const reverse iterator to the final element.
static constexpr std::string_view dtype() noexcept
Returns the canonical name of the stored element dtype.
reference front()
Returns the first element.
reference at(difference_type index)
Returns an element using checked, Python-style flat indexing.
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.
const_reverse_iterator crend() const noexcept
Returns the past-the-end const reverse iterator.
const_reference front() const
Returns the first element.
iterator end() noexcept
Returns a mutable iterator past the final element.
reverse_iterator rbegin() noexcept
Returns a mutable reverse iterator to the final element.
const_reference back() const
Returns the final element.
const_reverse_iterator rend() const noexcept
Returns the past-the-end const reverse iterator.
const_reference at(difference_type index) const
Returns an element using checked, Python-style flat indexing.
const Shape & strides() const noexcept
Returns the row-major stride metadata.
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.
Fixed-size owner of aligned, contiguous element storage.
const_pointer const_iterator
Read-only contiguous random-access iterator type.
std::reverse_iterator< iterator > reverse_iterator
Mutable iterator that traverses elements in reverse order.
reverse_iterator rend() noexcept
Returns the past-the-end iterator for mutable reverse traversal.
void swap(Buffer &other) noexcept
Swaps storage and size with another buffer.
T & reference
Mutable element reference type.
size_type size() const noexcept
Returns the number of stored elements.
T * pointer
Mutable pointer to an element.
const_reverse_iterator crend() const noexcept
Returns the past-the-end iterator for const reverse traversal.
std::ptrdiff_t difference_type
Signed type used for distances between iterators.
reference front()
Returns a reference to the first element.
const_iterator cend() const noexcept
Returns a const iterator one past the final element.
pointer iterator
Mutable contiguous random-access iterator type.
bool empty() const noexcept
Returns whether the buffer has no elements.
const_reverse_iterator crbegin() const noexcept
Returns a const reverse iterator to the final element.
std::size_t size_type
Unsigned type used for element counts and indices.
reverse_iterator rbegin() noexcept
Returns a mutable reverse iterator to the final element.
void fill(const_reference value)
Assigns a value to every element in the buffer.
pointer data() noexcept
Returns a pointer to the underlying contiguous storage.
iterator begin() noexcept
Returns a mutable iterator to the first element.
const_iterator cbegin() const noexcept
Returns a const iterator to the first element.
const T * const_pointer
Read-only pointer to an element.
reference back()
Returns a reference to the last element.
std::reverse_iterator< const_iterator > const_reverse_iterator
Read-only iterator that traverses elements in reverse order.
const T & const_reference
Read-only element reference type.
iterator end() noexcept
Returns a mutable iterator one past the final element.
T value_type
Type of each stored element.
Stores the dimensions of a multidimensional array.
size_type elements() const
Computes the total number of elements described by the shape.
size_type rank() const noexcept
Returns the number of dimensions.
void swap(Shape &other) noexcept
Exchanges dimension storage with another shape.
Provides compile-time metadata for a supported Stratax dtype.