55#ifndef TPL_CA_STORAGE_H
56#define TPL_CA_STORAGE_H
96template <
typename T, std::
size_t N>
99 static_assert(
N >= 1,
"Dense_Cell_Storage requires N >= 1");
100 static_assert(
CellState<T>,
"Dense_Cell_Storage requires a CellState type");
108 static constexpr std::size_t
rank =
N;
118 for (std::size_t d = 0; d <
N; ++d)
122 const ca_size_t lim = std::numeric_limits<ca_size_t>::max();
124 <<
"Dense_Cell_Storage: extent product overflows ca_size_t at dimension " << d;
188 for (std::size_t d = 0; d <
N; ++d)
191 <<
"Dense_Cell_Storage::linear_index: coord[" << d <<
"]=" << c[d] <<
" out of [0, "
332template <
typename T, std::
size_t N>
Exception handling system with formatted messages for Aleph-w.
#define ah_out_of_range_error_if(C)
Throws std::out_of_range if condition holds.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
Non-owning multidimensional array view (Aleph::mdspan).
size_t size_t int32_t value
Common typedefs and tag types for the Cellular Automata module.
Simple dynamic array with automatic resizing and functional operations.
Row-major dense storage for N-dimensional cellular automata.
void set(ca_index_t i, ca_index_t j, ca_index_t k, const T &v)
3D shorthand for set({i, j, k}, v).
Dense_Cell_Storage(const extents_type &extents, const T &init=T{})
Construct a storage with the given extents and initial value.
Aleph::mdspan< const T, Aleph::dextents< ca_size_t, N > > const_view_type
Non-owning, zero-copy read-only N-dimensional view of this storage's buffer.
const_view_type view() const noexcept
T at(ca_index_t i) const
1D shorthand for at({i}).
static ca_size_t product(const extents_type &e)
Coord_Vec< N > coord_type
ca_size_t size() const noexcept
extents_type ext_
per-axis extents
void set(ca_index_t i, ca_index_t j, const T &v)
2D shorthand for set({i, j}, v).
void fill(const T &value)
Set every cell to value.
static constexpr std::size_t dimension() noexcept
ca_size_t size(std::size_t d) const
Extent of axis d.
ca_size_t linear_index(const coord_type &c) const
Map a multi-index to a linear offset.
void swap(Dense_Cell_Storage &other) noexcept
O(1) swap with another storage of the same type.
view_type view() noexcept
Return a mutable Aleph::mdspan view of this storage.
const extents_type & extents() const noexcept
void set(ca_index_t i, const T &v)
1D shorthand for set({i}, v).
Aleph::mdspan< T, Aleph::dextents< ca_size_t, N > > view_type
Non-owning, zero-copy N-dimensional view of this storage's buffer.
std::array< ca_size_t, N > extents_type
ca_size_t total_cells_
product of ext
T at(ca_index_t i, ca_index_t j, ca_index_t k) const
3D shorthand for at({i, j, k}).
T at(const coord_type &c) const
Read access through a multi-index.
void set(const coord_type &c, const T &v)
Write access through a multi-index.
T at(ca_index_t i, ca_index_t j) const
2D shorthand for at({i, j}).
Array< T > buffer_
contiguous row-major storage
static constexpr std::size_t rank
Number of axes known at compile time.
Dense_Cell_Storage()=default
Construct an empty storage (zero extents, no cells allocated).
const T * data() const noexcept
Shape (per-axis sizes) of an mdspan, mixing compile-time and run-time extents.
Non-owning view of a contiguous buffer as a multidimensional grid.
A type usable as the value stored inside a cell.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
std::array< ca_index_t, N > Coord_Vec
Default coordinate vector.
void swap(Bit_Cell_Storage< N > &a, Bit_Cell_Storage< N > &b) noexcept
Free-function swap so the storage plays nicely with std::swap.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
std::decay_t< typename HeadC::Item_Type > T
static std::atomic< bool > init
Dynamic array container with automatic resizing.
C++20 concepts for the Cellular Automata module.