|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Lattice that adds boundary-aware access on top of a storage. More...
#include <tpl_ca_lattice.H>
Public Types | |
| using | storage_type = Storage |
| using | boundary_type = Boundary |
| using | state_type = typename Storage::state_type |
| using | coord_type = typename Storage::coord_type |
| using | extents_type = typename Storage::extents_type |
Public Member Functions | |
| Lattice ()=default | |
| Construct an empty lattice (no cells allocated). | |
| Lattice (const extents_type &extents, const state_type &init=state_type{}) | |
| Construct a lattice with the given extents and initial value. | |
| Lattice (Storage &&s) noexcept(std::is_nothrow_move_constructible_v< Storage >) | |
| Wrap an existing storage by move. | |
| ca_size_t | size () const noexcept |
| ca_size_t | size (std::size_t d) const |
| const extents_type & | extents () const noexcept |
| state_type | at (const coord_type &c) const |
Strict access: throws if c is out of range. | |
| void | set (const coord_type &c, const state_type &v) |
Strict write: throws if c is out of range. | |
| state_type | at_safe (coord_type c) const |
| Boundary-aware read. | |
| const Storage & | storage () const noexcept |
| Direct read access to the underlying storage (read-only). | |
| Storage & | storage () noexcept |
| Direct read-write access to the underlying storage. | |
| void | fill (const state_type &value) |
Set every cell to value. | |
| void | swap (Lattice &other) noexcept(noexcept(store_.swap(other.store_))) |
| O(1) swap. | |
Static Public Member Functions | |
| static constexpr std::size_t | dimension () noexcept |
Static Public Attributes | |
| static constexpr std::size_t | rank = Storage::rank |
Private Member Functions | |
| state_type | out_of_range_value () const |
| bool | fold_coord (coord_type &c) const |
Try to fold c into a valid in-range coordinate using the boundary policy. | |
Private Attributes | |
| Storage | store_ |
Lattice that adds boundary-aware access on top of a storage.
| Storage | storage type satisfying CA::LatticeLike (e.g. Dense_Cell_Storage<T, N> or Bit_Cell_Storage<N>). |
| Boundary | boundary tag type (default OpenBoundary). |
at, set, at_safe are O(N) where N is the lattice rank (which is a small compile-time constant — 1, 2 or 3 in practice). Definition at line 148 of file tpl_ca_lattice.H.
| using Aleph::CA::Lattice< Storage, Boundary >::boundary_type = Boundary |
Definition at line 152 of file tpl_ca_lattice.H.
| using Aleph::CA::Lattice< Storage, Boundary >::coord_type = typename Storage::coord_type |
Definition at line 154 of file tpl_ca_lattice.H.
| using Aleph::CA::Lattice< Storage, Boundary >::extents_type = typename Storage::extents_type |
Definition at line 155 of file tpl_ca_lattice.H.
| using Aleph::CA::Lattice< Storage, Boundary >::state_type = typename Storage::state_type |
Definition at line 153 of file tpl_ca_lattice.H.
| using Aleph::CA::Lattice< Storage, Boundary >::storage_type = Storage |
Definition at line 151 of file tpl_ca_lattice.H.
|
default |
Construct an empty lattice (no cells allocated).
|
inlineexplicit |
Construct a lattice with the given extents and initial value.
| [in] | extents | per-axis sizes. |
| [in] | init | initial value for every cell. |
Definition at line 217 of file tpl_ca_lattice.H.
|
inlineexplicitnoexcept |
Wrap an existing storage by move.
Definition at line 222 of file tpl_ca_lattice.H.
|
inline |
Strict access: throws if c is out of range.
Definition at line 246 of file tpl_ca_lattice.H.
References Aleph::CA::Lattice< Storage, Boundary >::store_.
Referenced by Aleph::CA::Gif_Frame_Sink< Mapper >::accept(), Aleph::CA::HTML_Player_Frame_Sink< Mapper >::accept(), Aleph::CA::X11_Frame_Sink< Mapper >::accept(), Aleph::CA::Reproductions::BTW_Sandpile::add_if_inside(), Aleph::CA::Hex_Lattice< Storage, Boundary >::at_axial(), Aleph::CA::Triangular_Lattice< Storage, Boundary >::at_tri(), Aleph::CA::cell_diff_count(), Aleph::CA::Reproductions::BTW_Sandpile::drop_at(), Aleph::CA::frames_equal(), main(), Aleph::CA::Reproductions::morans_i_binary(), Aleph::CA::ca_checkpoint_detail::snapshot_frame_bytes(), Aleph::CA::Reproductions::BTW_Sandpile::stable(), Aleph::CA::Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::step(), Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::update_cell(), and Aleph::CA::ca_npy_detail::write_payload_rec().
|
inline |
Boundary-aware read.
Out-of-range coordinates are resolved according to Boundary:
OpenBoundary → returns state_type{}.ConstantBoundary<T, V> → returns V.ToroidalBoundary → wraps around.ReflectiveBoundary → mirrors back.NeumannBoundary → clamps to the nearest in-range cell.| [in] | c | possibly out-of-range coordinate. |
Definition at line 270 of file tpl_ca_lattice.H.
References Aleph::CA::Lattice< Storage, Boundary >::fold_coord(), Aleph::CA::Lattice< Storage, Boundary >::out_of_range_value(), and Aleph::CA::Lattice< Storage, Boundary >::store_.
Referenced by Aleph::CA::Hex_Lattice< Storage, Boundary >::at_axial_safe(), and Aleph::CA::Triangular_Lattice< Storage, Boundary >::at_tri_safe().
|
inlinestaticconstexprnoexcept |
Definition at line 226 of file tpl_ca_lattice.H.
References Aleph::CA::Lattice< Storage, Boundary >::rank.
|
inlinenoexcept |
Definition at line 240 of file tpl_ca_lattice.H.
References Aleph::CA::Lattice< Storage, Boundary >::store_.
Referenced by Aleph::CA::cell_diff_count(), Aleph::CA::Async_Engine< Lattice, Rule, Neighborhood, Update_Scheme >::extents(), Aleph::CA::Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::extents(), Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::extents(), Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::extents(), Aleph::CA::frames_equal(), and Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::step().
|
inline |
Set every cell to value.
Definition at line 290 of file tpl_ca_lattice.H.
References Aleph::CA::Lattice< Storage, Boundary >::store_, and value.
|
inlineprivate |
Try to fold c into a valid in-range coordinate using the boundary policy.
Returns false for OpenBoundary / ConstantBoundary when c is out of range, in which case the caller should return out_of_range_value() instead.
Definition at line 174 of file tpl_ca_lattice.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Lattice< Storage, Boundary >::rank, and Aleph::CA::Lattice< Storage, Boundary >::store_.
Referenced by Aleph::CA::Lattice< Storage, Boundary >::at_safe().
|
inlineprivate |
Definition at line 162 of file tpl_ca_lattice.H.
Referenced by Aleph::CA::Lattice< Storage, Boundary >::at_safe().
|
inline |
Strict write: throws if c is out of range.
Definition at line 252 of file tpl_ca_lattice.H.
References Aleph::CA::Lattice< Storage, Boundary >::store_.
Referenced by Aleph::CA::Reproductions::BTW_Sandpile::add_if_inside(), Aleph::CA::Reproductions::BTW_Sandpile::drop_at(), Aleph::CA::make_lattice_from_snapshot(), Aleph::CA::Hex_Lattice< Storage, Boundary >::set_axial(), Aleph::CA::Triangular_Lattice< Storage, Boundary >::set_tri(), Aleph::CA::Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::step(), TEST(), and Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::update_cell().
|
inlinenoexcept |
Definition at line 231 of file tpl_ca_lattice.H.
References Aleph::CA::Lattice< Storage, Boundary >::store_.
Referenced by Aleph::CA::Gif_Frame_Sink< Mapper >::accept(), Aleph::CA::HTML_Player_Frame_Sink< Mapper >::accept(), Aleph::CA::X11_Frame_Sink< Mapper >::accept(), Aleph::CA::Reproductions::BTW_Sandpile::add_if_inside(), Aleph::CA::cell_diff_count(), Aleph::CA::Hex_Lattice< Storage, Boundary >::cols(), Aleph::CA::Triangular_Lattice< Storage, Boundary >::cols(), Aleph::CA::Reproductions::BTW_Sandpile::drop_at(), Aleph::CA::Reproductions::BTW_Sandpile::drop_random(), Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::effective_partitions(), Aleph::CA::frames_equal(), Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::iterate_lattice(), Aleph::CA::Reproductions::morans_i_binary(), Aleph::CA::ca_checkpoint_detail::restore_frame_from_bytes(), Aleph::CA::Hex_Lattice< Storage, Boundary >::rows(), Aleph::CA::Triangular_Lattice< Storage, Boundary >::rows(), Aleph::CA::ca_npy_detail::shape_tuple(), Aleph::CA::ca_checkpoint_detail::snapshot_frame_bytes(), Aleph::CA::Reproductions::BTW_Sandpile::stable(), Aleph::CA::Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::step(), Aleph::CA::Graph_Synchronous_Engine< Lattice, Rule >::step(), Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::step(), Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::update_slab_2d_row_major(), Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::update_slab_2d_tile(), Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::update_slab_3d_row_major(), and Aleph::CA::ca_npy_detail::write_payload_rec().
|
inline |
Definition at line 235 of file tpl_ca_lattice.H.
References Aleph::CA::Lattice< Storage, Boundary >::store_.
|
inlinenoexcept |
Direct read access to the underlying storage (read-only).
Definition at line 278 of file tpl_ca_lattice.H.
References Aleph::CA::Lattice< Storage, Boundary >::store_.
|
inlinenoexcept |
Direct read-write access to the underlying storage.
Definition at line 284 of file tpl_ca_lattice.H.
References Aleph::CA::Lattice< Storage, Boundary >::store_.
|
inlinenoexcept |
O(1) swap.
Definition at line 296 of file tpl_ca_lattice.H.
References Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::Lattice< Storage, Boundary >::store_.
Referenced by Aleph::CA::Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::step(), Aleph::CA::Graph_Synchronous_Engine< Lattice, Rule >::step(), Aleph::CA::Multi_Field_Engine< Lattice, Rule, Neighborhood >::step(), Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::step(), and Aleph::CA::Async_Engine< Lattice, Rule, Neighborhood, Update_Scheme >::swap_buffers().
|
staticconstexpr |
Definition at line 157 of file tpl_ca_lattice.H.
Referenced by Aleph::CA::Gif_Frame_Sink< Mapper >::accept(), Aleph::CA::HTML_Player_Frame_Sink< Mapper >::accept(), Aleph::CA::X11_Frame_Sink< Mapper >::accept(), Aleph::CA::Block_Synchronous_Update< BlockSize, Order >::apply(), Aleph::CA::Margolus_Update::apply_with_origin(), Aleph::CA::ca_mf_engine_detail::build_views(), Aleph::CA::ca_scheme_detail::cell_count(), Aleph::CA::Lattice< Storage, Boundary >::dimension(), Aleph::CA::Lattice< Storage, Boundary >::fold_coord(), Aleph::CA::for_each_cell(), Aleph::CA::ca_scheme_detail::for_each_coord(), Aleph::CA::Reproductions::morans_i_binary(), Aleph::CA::ca_io_detail::require_rank2(), Aleph::CA::ca_tikz_detail::require_rank2_rect(), Aleph::CA::ca_npy_detail::shape_tuple(), Aleph::CA::ca_checkpoint_detail::snapshot_frame_bytes(), and Aleph::CA::ca_npy_detail::write_payload_rec().
|
private |
Definition at line 160 of file tpl_ca_lattice.H.
Referenced by Aleph::CA::Lattice< Storage, Boundary >::at(), Aleph::CA::Lattice< Storage, Boundary >::at_safe(), Aleph::CA::Lattice< Storage, Boundary >::extents(), Aleph::CA::Lattice< Storage, Boundary >::fill(), Aleph::CA::Lattice< Storage, Boundary >::fold_coord(), Aleph::CA::Lattice< Storage, Boundary >::set(), Aleph::CA::Lattice< Storage, Boundary >::size(), Aleph::CA::Lattice< Storage, Boundary >::size(), Aleph::CA::Lattice< Storage, Boundary >::storage(), Aleph::CA::Lattice< Storage, Boundary >::storage(), and Aleph::CA::Lattice< Storage, Boundary >::swap().