|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Bit-packed row-major storage for N-dimensional binary CAs.
More...
#include <tpl_ca_bit_storage.H>
Public Types | |
| using | state_type = bool |
| using | coord_type = Coord_Vec< N > |
| using | extents_type = std::array< ca_size_t, N > |
Public Member Functions | |
| Bit_Cell_Storage ()=default | |
| Construct an empty storage (zero extents). | |
| Bit_Cell_Storage (const extents_type &extents, const bool init=false) | |
| Construct a storage with the given extents and initial value. | |
| ca_size_t | size () const noexcept |
| ca_size_t | size (std::size_t d) const |
Return the extent (number of cells) along axis d. | |
| const extents_type & | extents () const noexcept |
| Return the full extents array. | |
| ca_size_t | linear_index (const coord_type &c) const |
| Map a multi-index to a linear bit offset (row-major). | |
| bool | at (const coord_type &c) const |
Read the cell at coordinate c. | |
| void | set (const coord_type &c, bool v) |
Write the cell at coordinate c. | |
| bool | at (ca_index_t i) const |
Read 1D cell at index i. | |
| bool | at (ca_index_t i, ca_index_t j) const |
Read 2D cell at (i, j). | |
| bool | at (ca_index_t i, ca_index_t j, ca_index_t k) const |
Read 3D cell at (i, j, k). | |
| 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). | |
| void | swap (Bit_Cell_Storage &other) noexcept |
| Swap contents with another Bit_Cell_Storage instance. | |
| void | fill (const bool value) |
Set every cell to value. | |
Static Public Member Functions | |
| static constexpr std::size_t | dimension () noexcept |
Static Public Attributes | |
| static constexpr std::size_t | rank = N |
| Number of axes known at compile time. | |
Static Private Member Functions | |
| static ca_size_t | product (const extents_type &e) |
Private Attributes | |
| extents_type | ext_ {} |
| per-axis extents | |
| ca_size_t | total_cells_ = 0 |
product of ext | |
| BitArray | buffer_ |
| bit-packed row-major storage | |
Bit-packed row-major storage for N-dimensional binary CAs.
Stores cells as 1-bit values inside an Aleph::BitArray. Linear layout is row-major (axis N-1 varies fastest), identical to Dense_Cell_Storage<bool, N>. Reading and writing are done with bool to keep the API uniform.
| N | number of axes (1, 2 or 3 are the typical values). |
Definition at line 75 of file tpl_ca_bit_storage.H.
| using Aleph::CA::Bit_Cell_Storage< N >::coord_type = Coord_Vec<N> |
Definition at line 81 of file tpl_ca_bit_storage.H.
| using Aleph::CA::Bit_Cell_Storage< N >::extents_type = std::array<ca_size_t, N> |
Definition at line 82 of file tpl_ca_bit_storage.H.
| using Aleph::CA::Bit_Cell_Storage< N >::state_type = bool |
Definition at line 80 of file tpl_ca_bit_storage.H.
|
default |
Construct an empty storage (zero extents).
|
inlineexplicit |
Construct a storage with the given extents and initial value.
| [in] | extents | per-axis sizes. |
| [in] | init | initial value for every cell (default false). |
Definition at line 115 of file tpl_ca_bit_storage.H.
|
inline |
Read 1D cell at index i.
| i | the column coordinate. |
true if the cell is set, false otherwise. | std::out_of_range | if i is out of bounds. |
Definition at line 194 of file tpl_ca_bit_storage.H.
References Aleph::CA::Bit_Cell_Storage< N >::at().
|
inline |
Read 2D cell at (i, j).
| i | the row coordinate. |
| j | the column coordinate. |
true if the cell is set, false otherwise. | std::out_of_range | if the coordinate is out of bounds. |
Definition at line 206 of file tpl_ca_bit_storage.H.
References Aleph::CA::Bit_Cell_Storage< N >::at().
|
inline |
Read 3D cell at (i, j, k).
| i | the depth coordinate. |
| j | the row coordinate. |
| k | the column coordinate. |
true if the cell is set, false otherwise. | std::out_of_range | if the coordinate is out of bounds. |
Definition at line 219 of file tpl_ca_bit_storage.H.
References Aleph::CA::Bit_Cell_Storage< N >::at(), and k.
|
inline |
Read the cell at coordinate c.
| [in] | c | multi-dimensional coordinate. |
true if the cell is set, false otherwise. | std::out_of_range | if any component of c is out of range. |
Definition at line 174 of file tpl_ca_bit_storage.H.
References Aleph::CA::Bit_Cell_Storage< N >::buffer_, Aleph::CA::Bit_Cell_Storage< N >::linear_index(), and Aleph::BitArray::read_bit().
Referenced by Aleph::CA::Bit_Cell_Storage< N >::at(), Aleph::CA::Bit_Cell_Storage< N >::at(), and Aleph::CA::Bit_Cell_Storage< N >::at().
|
inlinestaticconstexprnoexcept |
Definition at line 120 of file tpl_ca_bit_storage.H.
References N.
Referenced by TEST().
|
inlinenoexcept |
Return the full extents array.
Definition at line 145 of file tpl_ca_bit_storage.H.
References Aleph::CA::Bit_Cell_Storage< N >::ext_.
|
inline |
Set every cell to value.
| value | the boolean value to set. |
Definition at line 277 of file tpl_ca_bit_storage.H.
References Aleph::CA::Bit_Cell_Storage< N >::buffer_, Aleph::CA::Bit_Cell_Storage< N >::total_cells_, value, and Aleph::BitArray::write_bit().
Referenced by TEST().
|
inline |
Map a multi-index to a linear bit offset (row-major).
| [in] | c | multi-dimensional coordinate; each component must satisfy 0 <= c[d] < size(d). |
[0, total cell count). | std::out_of_range | if any component is out of range. |
Definition at line 156 of file tpl_ca_bit_storage.H.
References ah_out_of_range_error_if, Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Bit_Cell_Storage< N >::ext_, and N.
Referenced by Aleph::CA::Bit_Cell_Storage< N >::at(), and Aleph::CA::Bit_Cell_Storage< N >::set().
|
inlinestaticprivate |
Definition at line 92 of file tpl_ca_bit_storage.H.
References ah_overflow_error_if, and N.
|
inline |
Write 1D cell at index i.
| i | the column coordinate. |
| v | the boolean value to write. |
| std::out_of_range | if i is out of bounds. |
Definition at line 230 of file tpl_ca_bit_storage.H.
References Aleph::CA::Bit_Cell_Storage< N >::set().
|
inline |
Write 3D cell at (i, j, k).
| i | the depth coordinate. |
| j | the row coordinate. |
| k | the column coordinate. |
| v | the boolean value to write. |
| std::out_of_range | if the coordinate is out of bounds. |
Definition at line 255 of file tpl_ca_bit_storage.H.
References k, and Aleph::CA::Bit_Cell_Storage< N >::set().
|
inline |
Write 2D cell at (i, j).
| i | the row coordinate. |
| j | the column coordinate. |
| v | the boolean value to write. |
| std::out_of_range | if the coordinate is out of bounds. |
Definition at line 242 of file tpl_ca_bit_storage.H.
References Aleph::CA::Bit_Cell_Storage< N >::set().
|
inline |
Write the cell at coordinate c.
| [in] | c | multi-dimensional coordinate. |
| [in] | v | boolean value to store. |
| std::out_of_range | if any component of c is out of range. |
Definition at line 184 of file tpl_ca_bit_storage.H.
References Aleph::CA::Bit_Cell_Storage< N >::buffer_, Aleph::CA::Bit_Cell_Storage< N >::linear_index(), and Aleph::BitArray::write_bit().
Referenced by Aleph::CA::Bit_Cell_Storage< N >::set(), Aleph::CA::Bit_Cell_Storage< N >::set(), Aleph::CA::Bit_Cell_Storage< N >::set(), TEST(), and TEST().
|
inlinenoexcept |
Definition at line 126 of file tpl_ca_bit_storage.H.
References Aleph::CA::Bit_Cell_Storage< N >::total_cells_.
Referenced by TEST().
|
inline |
Return the extent (number of cells) along axis d.
| d | axis index in [0, N). |
d. | std::out_of_range | if d >= N. |
Definition at line 136 of file tpl_ca_bit_storage.H.
References ah_out_of_range_error_if, Aleph::CA::Bit_Cell_Storage< N >::ext_, and N.
|
inlinenoexcept |
Swap contents with another Bit_Cell_Storage instance.
| other | the other storage to swap with. |
Definition at line 265 of file tpl_ca_bit_storage.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Bit_Cell_Storage< N >::buffer_, Aleph::CA::Bit_Cell_Storage< N >::ext_, Aleph::CA::Bit_Cell_Storage< N >::swap(), Aleph::BitArray::swap(), and Aleph::CA::Bit_Cell_Storage< N >::total_cells_.
Referenced by Aleph::CA::Bit_Cell_Storage< N >::swap(), and TEST().
|
private |
bit-packed row-major storage
Definition at line 90 of file tpl_ca_bit_storage.H.
Referenced by Aleph::CA::Bit_Cell_Storage< N >::at(), Aleph::CA::Bit_Cell_Storage< N >::fill(), Aleph::CA::Bit_Cell_Storage< N >::set(), and Aleph::CA::Bit_Cell_Storage< N >::swap().
|
private |
per-axis extents
Definition at line 88 of file tpl_ca_bit_storage.H.
Referenced by Aleph::CA::Bit_Cell_Storage< N >::extents(), Aleph::CA::Bit_Cell_Storage< N >::linear_index(), Aleph::CA::Bit_Cell_Storage< N >::size(), and Aleph::CA::Bit_Cell_Storage< N >::swap().
|
staticconstexpr |
Number of axes known at compile time.
Definition at line 85 of file tpl_ca_bit_storage.H.
|
private |
product of ext
Definition at line 89 of file tpl_ca_bit_storage.H.
Referenced by Aleph::CA::Bit_Cell_Storage< N >::fill(), Aleph::CA::Bit_Cell_Storage< N >::size(), and Aleph::CA::Bit_Cell_Storage< N >::swap().