49#ifndef TPL_CA_BIT_STORAGE_H
50#define TPL_CA_BIT_STORAGE_H
74template <std::
size_t N>
77 static_assert(
N >= 1,
"Bit_Cell_Storage requires N >= 1");
85 static constexpr std::size_t
rank =
N;
95 for (std::size_t d = 0; d <
N; ++d)
100 <<
"Bit_Cell_Storage::product: extents product overflows ca_size_t";
159 for (std::size_t d = 0; d <
N; ++d)
162 <<
"Bit_Cell_Storage::linear_index: coord[" << d <<
"]=" << c[d] <<
" out of [0, "
279 const unsigned int v =
value ? 1u : 0u;
290template <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.
Space-efficient bit array implementation.
size_t size_t int32_t value
Common typedefs and tag types for the Cellular Automata module.
Contiguous array of bits.
int read_bit(const size_t i) const
Read bit i.
void write_bit(const size_t i, const unsigned int value)
Write bit i with the value.
void swap(BitArray &array) noexcept
Bit-packed row-major storage for N-dimensional binary CAs.
Coord_Vec< N > coord_type
Bit_Cell_Storage(const extents_type &extents, const bool init=false)
Construct a storage with the given extents and initial value.
void fill(const bool value)
Set every cell to value.
bool at(ca_index_t i) const
Read 1D cell at index i.
static ca_size_t product(const extents_type &e)
ca_size_t total_cells_
product of ext
const extents_type & extents() const noexcept
Return the full extents array.
ca_size_t size() const noexcept
extents_type ext_
per-axis extents
static constexpr std::size_t dimension() noexcept
BitArray buffer_
bit-packed row-major storage
void swap(Bit_Cell_Storage &other) noexcept
Swap contents with another Bit_Cell_Storage instance.
bool at(ca_index_t i, ca_index_t j, ca_index_t k) const
Read 3D cell at (i, j, k).
static constexpr std::size_t rank
Number of axes known at compile time.
void set(ca_index_t i, bool v)
Write 1D cell at index i.
void set(ca_index_t i, ca_index_t j, const bool v)
Write 2D cell at (i, j).
void set(ca_index_t i, ca_index_t j, ca_index_t k, const bool v)
Write 3D cell at (i, j, k).
bool at(ca_index_t i, ca_index_t j) const
Read 2D cell at (i, j).
ca_size_t linear_index(const coord_type &c) const
Map a multi-index to a linear bit offset (row-major).
ca_size_t size(std::size_t d) const
Return the extent (number of cells) along axis d.
std::array< ca_size_t, N > extents_type
void set(const coord_type &c, bool v)
Write the cell at coordinate c.
Bit_Cell_Storage()=default
Construct an empty storage (zero extents).
bool at(const coord_type &c) const
Read the cell at coordinate c.
Shape (per-axis sizes) of an mdspan, mixing compile-time and run-time extents.
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.
static std::atomic< bool > init
C++20 concepts for the Cellular Automata module.