Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::Lattice< Storage, Boundary > Class Template Reference

Lattice that adds boundary-aware access on top of a storage. More...

#include <tpl_ca_lattice.H>

Inheritance diagram for Aleph::CA::Lattice< Storage, Boundary >:
[legend]

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_
 

Detailed Description

template<typename Storage, typename Boundary = OpenBoundary>
class Aleph::CA::Lattice< Storage, Boundary >

Lattice that adds boundary-aware access on top of a storage.

Template Parameters
Storagestorage type satisfying CA::LatticeLike (e.g. Dense_Cell_Storage<T, N> or Bit_Cell_Storage<N>).
Boundaryboundary tag type (default OpenBoundary).
Complexity
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.

Member Typedef Documentation

◆ boundary_type

template<typename Storage , typename Boundary = OpenBoundary>
using Aleph::CA::Lattice< Storage, Boundary >::boundary_type = Boundary

Definition at line 152 of file tpl_ca_lattice.H.

◆ coord_type

template<typename Storage , typename Boundary = OpenBoundary>
using Aleph::CA::Lattice< Storage, Boundary >::coord_type = typename Storage::coord_type

Definition at line 154 of file tpl_ca_lattice.H.

◆ extents_type

template<typename Storage , typename Boundary = OpenBoundary>
using Aleph::CA::Lattice< Storage, Boundary >::extents_type = typename Storage::extents_type

Definition at line 155 of file tpl_ca_lattice.H.

◆ state_type

template<typename Storage , typename Boundary = OpenBoundary>
using Aleph::CA::Lattice< Storage, Boundary >::state_type = typename Storage::state_type

Definition at line 153 of file tpl_ca_lattice.H.

◆ storage_type

template<typename Storage , typename Boundary = OpenBoundary>
using Aleph::CA::Lattice< Storage, Boundary >::storage_type = Storage

Definition at line 151 of file tpl_ca_lattice.H.

Constructor & Destructor Documentation

◆ Lattice() [1/3]

template<typename Storage , typename Boundary = OpenBoundary>
Aleph::CA::Lattice< Storage, Boundary >::Lattice ( )
default

Construct an empty lattice (no cells allocated).

◆ Lattice() [2/3]

template<typename Storage , typename Boundary = OpenBoundary>
Aleph::CA::Lattice< Storage, Boundary >::Lattice ( const extents_type &  extents,
const state_type &  init = state_type{} 
)
inlineexplicit

Construct a lattice with the given extents and initial value.

Parameters
[in]extentsper-axis sizes.
[in]initinitial value for every cell.

Definition at line 217 of file tpl_ca_lattice.H.

◆ Lattice() [3/3]

template<typename Storage , typename Boundary = OpenBoundary>
Aleph::CA::Lattice< Storage, Boundary >::Lattice ( Storage &&  s)
inlineexplicitnoexcept

Wrap an existing storage by move.

Definition at line 222 of file tpl_ca_lattice.H.

Member Function Documentation

◆ at()

◆ at_safe()

template<typename Storage , typename Boundary = OpenBoundary>
state_type Aleph::CA::Lattice< Storage, Boundary >::at_safe ( coord_type  c) const
inline

Boundary-aware read.

Out-of-range coordinates are resolved according to Boundary:

Parameters
[in]cpossibly out-of-range coordinate.
Returns
the cell value resolved through the boundary policy.

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().

◆ dimension()

template<typename Storage , typename Boundary = OpenBoundary>
static constexpr std::size_t Aleph::CA::Lattice< Storage, Boundary >::dimension ( )
inlinestaticconstexprnoexcept

Definition at line 226 of file tpl_ca_lattice.H.

References Aleph::CA::Lattice< Storage, Boundary >::rank.

◆ extents()

◆ fill()

template<typename Storage , typename Boundary = OpenBoundary>
void Aleph::CA::Lattice< Storage, Boundary >::fill ( const state_type &  value)
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.

◆ fold_coord()

template<typename Storage , typename Boundary = OpenBoundary>
bool Aleph::CA::Lattice< Storage, Boundary >::fold_coord ( coord_type &  c) const
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().

◆ out_of_range_value()

template<typename Storage , typename Boundary = OpenBoundary>
state_type Aleph::CA::Lattice< Storage, Boundary >::out_of_range_value ( ) const
inlineprivate

Definition at line 162 of file tpl_ca_lattice.H.

Referenced by Aleph::CA::Lattice< Storage, Boundary >::at_safe().

◆ set()

◆ size() [1/2]

template<typename Storage , typename Boundary = OpenBoundary>
ca_size_t Aleph::CA::Lattice< Storage, Boundary >::size ( ) const
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().

◆ size() [2/2]

template<typename Storage , typename Boundary = OpenBoundary>
ca_size_t Aleph::CA::Lattice< Storage, Boundary >::size ( std::size_t  d) const
inline

Definition at line 235 of file tpl_ca_lattice.H.

References Aleph::CA::Lattice< Storage, Boundary >::store_.

◆ storage() [1/2]

template<typename Storage , typename Boundary = OpenBoundary>
const Storage & Aleph::CA::Lattice< Storage, Boundary >::storage ( ) const
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_.

◆ storage() [2/2]

template<typename Storage , typename Boundary = OpenBoundary>
Storage & Aleph::CA::Lattice< Storage, Boundary >::storage ( )
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_.

◆ swap()

Member Data Documentation

◆ rank

◆ store_


The documentation for this class was generated from the following file: