Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA Namespace Reference

Namespaces

namespace  Bench
 
namespace  ca_async_engine_detail
 
namespace  ca_block_rule_detail
 
namespace  ca_checkpoint_detail
 
namespace  ca_checkpoint_flags
 Bitset values used in Checkpoint_Header::flags (v2+).
 
namespace  ca_continuous_detail
 
namespace  ca_dot_detail
 
namespace  ca_engine_detail
 
namespace  ca_ffmpeg_detail
 
namespace  ca_frame_stream_detail
 
namespace  ca_ghost_detail
 
namespace  ca_gif_detail
 
namespace  ca_hashlife_detail
 
namespace  ca_html_detail
 
namespace  ca_io_detail
 
namespace  ca_ising_detail
 
namespace  ca_lattice_detail
 
namespace  ca_metrics_detail
 
namespace  ca_mf_detail
 
namespace  ca_mf_engine_detail
 
namespace  ca_mf_rule_detail
 
namespace  ca_neighborhood_detail
 
namespace  ca_npy_detail
 
namespace  ca_parallel_detail
 
namespace  ca_png_detail
 
namespace  ca_rule_detail
 
namespace  ca_scheme_detail
 
namespace  ca_stream_detail
 
namespace  ca_svg_detail
 
namespace  ca_tikz_detail
 
namespace  ca_tiling_detail
 
namespace  ca_vtk_detail
 
namespace  Reproductions
 

Classes

class  Activity_Observer
 Records the number of cells that changed across each step. More...
 
class  Ascii_Frame_Sink
 Stream sink that writes textual frames to an output stream. More...
 
struct  Ascii_Render_Options
 Options for textual CA rendering. More...
 
class  Async_Checkpoint_Writer
 Background writer pumping snapshots onto a dedicated thread. More...
 
class  Async_Engine
 Update-scheme aware engine. More...
 
class  BBM_Rule
 Fredkin–Toffoli Billiard Ball Machine block rule. More...
 
class  Bench_Timer
 Tiny start/stop wall-clock timer. More...
 
struct  Binary_ANSI24_Palette
 ANSI 24-bit colour palette for binary frames. More...
 
struct  Binary_ASCII_Palette
 Default binary text palette. More...
 
struct  Binary_Cell_Pattern
 Binary pattern shared by RLE, plaintext and Life formats. More...
 
struct  Binary_DOT_Palette
 Default binary DOT fill-colour palette. More...
 
struct  Binary_Gray_Mapper
 Default binary grayscale mapper. More...
 
struct  Binary_RGB_Mapper
 Default binary RGB mapper. More...
 
struct  Binary_Tikz_Palette
 Default binary TikZ palette. More...
 
class  Bit_Cell_Storage
 Bit-packed row-major storage for N-dimensional binary CAs. More...
 
struct  Block_Partition_2D
 2D blocked partitioning into a grid of parts_y x parts_x. More...
 
struct  Block_Synchronous_Update
 Synchronous update over rotating sub-blocks. More...
 
struct  Cell_Context
 Per-cell context handed to rules that need to know "where" and "when" they are firing. More...
 
class  Cell_Rule_As_Block_Rule
 Adapt a regular cell rule (with empty neighborhood) to a block rule. More...
 
struct  Checkpoint_Header
 Public on-disk header surfaced by inspect_checkpoint. More...
 
struct  Checkpoint_Options
 User-tunable knobs for save_checkpoint. More...
 
struct  Column_Partition
 Column partitioning along the last axis. More...
 
struct  ColumnMajor
 Iterate the lattice in column-major (Fortran) order. More...
 
class  Composite_Frame_Sink
 Fan-out sink that forwards every frame to several sinks. More...
 
class  Composite_Observer
 Variadic adaptor that fan-outs notifications to many observers. More...
 
class  Composite_Rule
 Sequential composition of one or more rules. More...
 
struct  ConstantBoundary
 Constant-value boundary. More...
 
class  Continuous_Rule
 Scalar continuous rule driven by a real convolution kernel. More...
 
class  Critters_Rule
 Critters reversible CA block rule. More...
 
struct  CSV_Options
 Options controlling CSV output and input. More...
 
class  Custom_Neighborhood
 User-supplied list of offsets for arbitrary connectivity. More...
 
class  Dense_Cell_Storage
 Row-major dense storage for N-dimensional cellular automata. More...
 
class  Density_Observer
 Records the count of cells in tracked_state per step. More...
 
class  Directory_Frame_Sink
 Directory-backed sink for CA frames. More...
 
class  Dot_Frame_Sink
 Path-pattern sink that writes GraphViz DOT frames. More...
 
struct  DOT_Render_Options
 DOT rendering options. More...
 
class  Entropy_Observer
 Records the Shannon entropy of the state distribution. More...
 
class  Ffmpeg_Frame_Sink
 Frame sink that streams PPM frames into ffmpeg. More...
 
struct  Ffmpeg_Options
 Options for Ffmpeg_Frame_Sink. More...
 
class  Field_Slice_Rule
 Adaptor: apply a mono-field rule to field I, leave the other fields unchanged. More...
 
class  FitzHugh_Nagumo_Rule
 FitzHugh-Nagumo excitable-media rule. More...
 
class  Forest_Fire_Rule
 Forest-fire rule (Drossel & Schwabl, 1992). More...
 
struct  Frame_Stream_Options
 Options for directory-backed frame streams. More...
 
struct  Game_Of_Life_Functor
 Functor implementing Conway's Game of Life canonical rule (B3/S23). More...
 
class  Ghost_Lattice
 Lattice with Halo ghost layers around the user-visible cells. More...
 
class  Gif_Frame_Sink
 Sink that buffers frames and writes an animated GIF on flush. More...
 
struct  GIF_Write_Options
 Options for animated GIF output. More...
 
class  Graph_Lattice
 Graph lattice: one cell per node + precomputed adjacency. More...
 
class  Graph_Synchronous_Engine
 Synchronous double-buffered engine for graph CAs. More...
 
class  Gray_Scott_Rule
 Gray-Scott reaction-diffusion rule. More...
 
struct  Grid_Snapshot
 Dense numeric snapshot used by CSV and JSON readers. More...
 
class  Hashlife_Engine
 Hashlife engine for outer-totalistic binary cellular automata. More...
 
struct  Hex_Axial
 Axial integer coordinates (q, r) of a hex cell. More...
 
struct  Hex_Cube
 Cube coordinates (x, y, z) with the constraint x+y+z = 0. More...
 
class  Hex_Lattice
 Hexagonal lattice with axial accessors over a 2D storage. More...
 
class  Hex_Neighborhood
 Six-neighbour hex pattern in axial coordinates over a 2D lattice. More...
 
struct  Hex_Offset
 Offset coordinates (col, row) for visualisation. More...
 
class  History_Cell
 Cell state carrying a fixed-depth ring buffer of past values. More...
 
class  History_Rule
 Rule adapter for History_Cell<State, Depth>. More...
 
class  HTML_Player_Frame_Sink
 Sink that writes a self-contained HTML playback file. More...
 
struct  HTML_Player_Options
 Options for generated HTML players. More...
 
class  Ising_Glauber_Rule
 Ising rule with Glauber single-spin-flip dynamics. More...
 
class  Ising_Metropolis_Rule
 Ising rule with Metropolis–Hastings single-spin-flip dynamics. More...
 
class  JSON_Frame_Stream_Writer
 Streaming JSON writer for CA trajectories. More...
 
struct  JSON_Write_Options
 Options controlling JSON snapshot output. More...
 
class  Kernel2D
 Dense odd-sized 2-D convolution kernel. More...
 
class  Lattice
 Lattice that adds boundary-aware access on top of a storage. More...
 
struct  Layout_AoS
 Layout tag: each cell is a std::tuple<Fields...> inside a single contiguous storage. More...
 
struct  Layout_SoA
 Layout tag: one contiguous storage per field. More...
 
class  Lookup_Rule
 Precomputed transition table for (self, neighbours...). More...
 
struct  Margolus_Update
 Margolus 2×2 partition update for reversible CAs. More...
 
class  Moore
 Moore (Chebyshev) neighborhood of radius R in N dimensions. More...
 
class  Multi_Field_Engine
 Synchronous double-buffered engine for multi-field lattices. More...
 
class  Multi_Field_Lattice
 Multi-field lattice with selectable storage layout. More...
 
struct  NetPBM_Write_Options
 Options controlling NetPBM output. More...
 
struct  NeumannBoundary
 Zero-gradient (Neumann) boundary. More...
 
class  Npy_Frame_Sink
 Path-pattern sink that writes one .npy file per frame. More...
 
class  Null_Neighborhood
 Placeholder neighbourhood for engines that drive block rules. More...
 
struct  OpenBoundary
 Out-of-range neighbours behave as if the lattice ended. More...
 
struct  Outer_Totalistic_Binary_Rule
 Outer-totalistic binary rule encoded as two 9-bit bitmasks. More...
 
class  Outer_Totalistic_Rule
 Rule whose next state depends on (current, alive_count). More...
 
struct  Parallel_Engine_Config
 Configuration for Parallel_Synchronous_Engine. More...
 
class  Parallel_Synchronous_Engine
 Parallel synchronous double-buffered engine. More...
 
class  Per_Thread_RNG
 Master seed dispenser for stochastic CA rules. More...
 
class  Periodic_Checkpoint_Observer
 Observer that auto-saves the engine state every every steps to a templated path. More...
 
struct  Plaintext_Write_Options
 Options controlling Life plaintext output. More...
 
class  Png_Frame_Sink
 Path-pattern sink that writes one PNG file per accepted frame. More...
 
class  Probabilistic_Rule
 Reproducible stochastic rule wrapper (Phase 8). More...
 
struct  Random_Asynchronous_Update
 Pick one cell at random per sub-step, update it in place. More...
 
struct  Range1D
 Half-open integer interval [begin, end). More...
 
struct  Reaction_Diffusion_Cell
 Two-field state for reaction-diffusion cellular automata. More...
 
struct  Rect_Tikz_Options
 TikZ rendering options for rectangular frames. More...
 
struct  ReflectiveBoundary
 Out-of-range coordinates mirror back into the lattice. More...
 
struct  Resume_Token
 Resume handle returned by load_checkpoint_into. More...
 
struct  RGB8
 RGB byte triplet used by PPM exporters. More...
 
struct  RLE_Write_Options
 Options controlling Conway RLE output. More...
 
struct  Row_Partition
 Row partitioning along axis 0. More...
 
struct  RowMajor
 Iterate the lattice in row-major (C) order. More...
 
class  Sampling_Observer
 Snapshots the lattice every period steps. More...
 
class  Schelling_Rule
 Local approximation of the Schelling segregation model. More...
 
struct  Sequential_Update
 In-place sequential update (no double buffer). More...
 
class  SIR_Rule
 SIR epidemic transition rule. More...
 
class  Stationary_Detector
 Detects fixed points and short cycles via frame hashing. More...
 
class  Svg_Frame_Sink
 Path-pattern sink that writes one SVG file per accepted frame. More...
 
struct  SVG_Render_Options
 SVG rendering options. More...
 
class  Synchronous_Engine
 Synchronous double-buffered engine. More...
 
struct  Synchronous_Update
 Classical double-buffer synchronous update. More...
 
struct  Tile
 Iterate a 2D lattice in W x H tiles. More...
 
struct  Tile2D_Range
 2D tile descriptor: a rectangle in axis-0 / axis-1 coordinates. More...
 
class  Tile_Cache
 Out-of-core 2D tile cache with LRU eviction. More...
 
struct  Tile_Cache_Stats
 Statistics surfaced by Tile_Cache::stats(). More...
 
class  TM_Gas_Rule
 Toffoli–Margolus (TM) lattice-gas block rule. More...
 
struct  ToroidalBoundary
 The lattice wraps around on every axis. More...
 
class  Totalistic_Rule
 Rule whose next state depends on the sum of every cell in the neighbourhood (including the centre). More...
 
struct  Tri_Coord
 Coordinates of a triangular cell as (i, j) integers. More...
 
class  Triangular_Lattice
 Triangular lattice with parity helpers over a 2D storage. More...
 
class  Triangular_Neighborhood
 Three edge-neighbours over a 2D lattice with parity coupling. More...
 
class  Von_Neumann
 Von Neumann (L1) neighborhood of radius R in N dimensions. More...
 
class  VTK_Frame_Sink
 Path-pattern sink that writes VTK legacy frames. More...
 
struct  VTK_Write_Options
 Options for VTK legacy output. More...
 
class  X11_Frame_Sink
 Live X11 frame sink. More...
 
struct  X11_Viewer_Options
 Options for the live X11 viewer. More...
 

Concepts

concept  Has_Master_Seed
 Concept: rule type that exposes a master RNG seed.
 
concept  Checkpointable_Lattice
 Concept: lattice exposing the standard CA layout interface.
 
concept  Checkpointable_Engine
 Concept: engine that exposes the minimum surface needed by checkpoint save/load.
 
concept  Frame_Sink
 Concept implemented by sinks that consume CA frames.
 
concept  ObserverLike
 Concept satisfied by any cellular-automaton observer.
 
concept  Block_Rule_2x2
 A rule that maps a 2×2 block to a 2×2 block.
 
concept  CellState
 A type usable as the value stored inside a cell.
 
concept  Coord
 A coordinate type with N integral components.
 
concept  LatticeLike
 Storage + topology that carries the cell values.
 
concept  NeighborhoodLike
 Connectivity pattern around a coordinate.
 
concept  BasicRuleLike
 Pure local transition function (Phase 0–7 signature).
 
concept  ContextualRuleLike
 Context-aware local transition function (Phase 8).
 
concept  RuleLike
 Local transition function (any supported signature).
 
concept  HasRefreshHalo
 Detect whether a lattice exposes a refresh_halo() method (the hallmark of a Ghost_Lattice or any other halo-aware variant).
 
concept  HexRenderable
 Detect whether a lattice exposes the hexagonal-grid query interface (rows(), cols(), at_axial(Hex_Axial)) used by the SVG and TikZ hex renderers.
 
concept  TriRenderable
 Detect whether a lattice exposes the triangular-grid query interface (rows(), cols(), at_tri(Tri_Coord)) used by the SVG and TikZ triangular renderers.
 
concept  GraphRuleLike
 Concept satisfied by graph rules.
 
concept  MultiFieldLatticeLike
 Concept: a lattice that exposes the multi-field interface.
 
concept  BasicMultiFieldRule
 Concept: a pure multi-field rule.
 
concept  ContextualMultiFieldRule
 Concept: a contextual multi-field rule.
 
concept  MultiFieldRuleLike
 Concept: any supported multi-field rule signature.
 

Typedefs

using Game_Of_Life_Engine = Synchronous_Engine< Lattice< Dense_Cell_Storage< int, 2 >, ToroidalBoundary >, Game_Of_Life_Rule, Moore< 2, 1 > >
 Game-of-Life engine type alias (toroidal, integer cells).
 
using Wolfram_1D_Engine = Synchronous_Engine< Lattice< Dense_Cell_Storage< int, 1 >, OpenBoundary >, Lookup_Rule< 2, 2 >, Custom_Neighborhood< 1, 2 > >
 1D Wolfram engine type alias (open boundary, integer cells).
 
using RLE_Pattern = Binary_Cell_Pattern
 Backwards-readable alias for Conway RLE patterns.
 
using ca_index_t = std::ptrdiff_t
 Signed coordinate component used by lattices and neighborhoods.
 
using ca_size_t = std::size_t
 Unsigned size component used for extents and counts.
 
template<std::size_t N>
using Coord_Vec = std::array< ca_index_t, N >
 Default coordinate vector.
 
template<std::size_t N>
using Offset_Vec = Coord_Vec< N >
 Default offset vector (aliases Coord_Vec).
 
template<typename T >
using Neighbor_View = std::span< const T >
 Read-only view over a contiguous range of neighbour values.
 
using PeriodicBoundary = ToroidalBoundary
 Alias for ToroidalBoundary using the HPC "periodic" terminology.
 
template<typename T , T V>
using DirichletBoundary = ConstantBoundary< T, V >
 Alias for ConstantBoundary<T, V> using the "Dirichlet" name.
 
template<typename State >
using Block_2x2 = std::array< State, 4 >
 Fixed-size 2×2 block of cell values used by Margolus rules.
 
template<typename FieldsTuple >
using Field_Neighbor_Views_Tuple = typename ca_mf_rule_detail::neighbor_view_tuple< FieldsTuple >::type
 std::tuple<Neighbor_View<F>...> for the field tuple std::tuple<F...>.
 
using Game_Of_Life_Rule = Outer_Totalistic_Rule< Game_Of_Life_Functor >
 Outer-totalistic rule type implementing Conway's Game of Life.
 

Enumerations

enum class  Frame_Output_Format {
  PGM , PPM , RLE , CSV ,
  JSON , TikZ
}
 File format used by Directory_Frame_Sink. More...
 
enum class  Forest_Cell : std::uint8_t { EMPTY = 0 , TREE = 1 , BURNING = 2 }
 Discrete states of the forest-fire automaton. More...
 
enum class  SIR_Cell : std::uint8_t { S = 0 , I = 1 , R = 2 }
 Discrete states of the SIR automaton. More...
 
enum class  Schelling_Cell : std::uint8_t { EMPTY = 0 , TYPE_A = 1 , TYPE_B = 2 }
 Discrete states of the Schelling automaton. More...
 

Functions

template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
void render_ascii (std::ostream &out, const Lattice &frame, Palette &&palette, const Ascii_Render_Options &opts={})
 Render a rank-2 frame as text.
 
template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
std::string render_ascii_string (const Lattice &frame, Palette &&palette, const Ascii_Render_Options &opts={})
 Return the text rendering of a rank-2 frame.
 
template<typename Lattice >
void render_ascii (std::ostream &out, const Lattice &frame, const Ascii_Render_Options &opts={})
 Render using the default binary ASCII palette.
 
template<typename Lattice >
std::string render_ascii_string (const Lattice &frame, const Ascii_Render_Options &opts={})
 Return a default binary ASCII rendering.
 
template<typename Palette >
 Ascii_Frame_Sink (std::ostream &, Palette, Ascii_Render_Options={}, bool=true) -> Ascii_Frame_Sink< Palette >
 
template<typename F >
double bench_seconds (F &&f)
 Run f() once and return the wall-clock time it took, in seconds.
 
const char * format_throughput (double cells_per_second)
 Format a "cells per second" rate as "X.XX M cells/s".
 
Checkpoint_Header inspect_checkpoint (const std::filesystem::path &path)
 Read just the header from a checkpoint file.
 
template<typename Engine >
requires Checkpointable_Engine<Engine>
void save_checkpoint (Engine &engine, const std::filesystem::path &path, const Checkpoint_Options &options={})
 Write a complete engine snapshot to disk atomically.
 
template<typename Engine >
requires Checkpointable_Engine<Engine>
Resume_Token load_checkpoint_into (Engine &engine, const std::filesystem::path &path)
 Restore an engine's state in-place from a checkpoint file.
 
template<typename Engine >
requires Checkpointable_Engine<Engine>
void save_delta_checkpoint (Engine &engine, const std::vector< std::uint8_t > &baseline, const std::uint64_t base_step, const std::filesystem::path &path, const Checkpoint_Options &options={})
 Write a delta checkpoint relative to a previous payload.
 
template<typename Engine >
requires Checkpointable_Engine<Engine>
Resume_Token apply_delta_checkpoint (Engine &engine, const std::filesystem::path &path)
 Apply a delta checkpoint to the engine's current state.
 
template<typename Graph , typename Palette >
requires requires(const Graph &g, std::size_t n, Palette &&p, const typename Graph::state_type &v) { g.size(); g.neighbours(n); g.at_node(n); { p(v) } -> std::convertible_to<std::string>; }
void render_graph_lattice_dot (std::ostream &out, const Graph &graph, Palette &&palette, const DOT_Render_Options &opts={})
 Render a graph CA frame as GraphViz DOT.
 
template<typename Graph , typename Palette >
std::string render_graph_lattice_dot_string (const Graph &graph, Palette &&palette, const DOT_Render_Options &opts={})
 Return a graph frame rendered as DOT.
 
template<typename Palette >
 Dot_Frame_Sink (std::filesystem::path, Palette, DOT_Render_Options={}, std::size_t=6) -> Dot_Frame_Sink< Palette >
 
Game_Of_Life_Engine make_gol_engine (ca_size_t rows, ca_size_t cols)
 Build a Conway's Game of Life engine of the given shape.
 
Game_Of_Life_Engine make_gol_engine (Lattice< Dense_Cell_Storage< int, 2 >, ToroidalBoundary > initial)
 Build a Game of Life engine seeded with an explicit lattice.
 
Wolfram_1D_Engine make_wolfram_engine (std::uint8_t rule_no, ca_size_t width)
 Build a 1D elementary Wolfram engine of the given width.
 
Wolfram_1D_Engine make_wolfram_engine (std::uint8_t rule_no, Lattice< Dense_Cell_Storage< int, 1 >, OpenBoundary > initial)
 Build a 1D elementary Wolfram engine from an initial row.
 
template<typename Mapper >
 Ffmpeg_Frame_Sink (std::filesystem::path, Mapper, Ffmpeg_Options={}) -> Ffmpeg_Frame_Sink< Mapper >
 
std::filesystem::path format_step_path (const std::filesystem::path &pattern, const std::size_t step, const std::size_t zero_pad=6)
 Format a step-indexed file path.
 
void write_gif (std::ostream &out, const Array< ca_gif_detail::Frame > &frames, const GIF_Write_Options &opts={})
 Write a sequence of RGB frames as an animated GIF.
 
template<typename Mapper >
 Gif_Frame_Sink (std::filesystem::path, Mapper, GIF_Write_Options={}) -> Gif_Frame_Sink< Mapper >
 
template<typename Mapper >
 HTML_Player_Frame_Sink (std::filesystem::path, Mapper, HTML_Player_Options={}) -> HTML_Player_Frame_Sink< Mapper >
 
template<typename Lattice >
void write_rle (std::ostream &out, const Lattice &frame, const RLE_Write_Options &opts={}, const typename Lattice::state_type &dead=typename Lattice::state_type{})
 Write a 2D frame in Conway RLE format.
 
template<typename Lattice >
std::string write_rle_string (const Lattice &frame, const RLE_Write_Options &opts={}, const typename Lattice::state_type &dead=typename Lattice::state_type{})
 Return a frame encoded as Conway RLE.
 
RLE_Pattern read_rle (std::istream &in)
 Read a Conway RLE pattern.
 
RLE_Pattern read_rle_string (const std::string &s)
 Read a Conway RLE pattern from a string.
 
template<typename Lattice >
void load_binary_pattern (const Binary_Cell_Pattern &pattern, Lattice &frame, const typename Lattice::state_type &alive=static_cast< typename Lattice::state_type >(1), const typename Lattice::state_type &dead=typename Lattice::state_type{}, const ca_index_t origin_row=0, const ca_index_t origin_col=0)
 Fill a lattice from a binary pattern.
 
template<typename Lattice >
Lattice make_lattice_from_pattern (const Binary_Cell_Pattern &pattern, const typename Lattice::state_type &alive=static_cast< typename Lattice::state_type >(1), const typename Lattice::state_type &dead=typename Lattice::state_type{})
 Construct a lattice with the exact dimensions of a pattern.
 
template<typename Lattice >
void write_plaintext (std::ostream &out, const Lattice &frame, const Plaintext_Write_Options &opts={}, const typename Lattice::state_type &dead=typename Lattice::state_type{})
 Write a Life plaintext (.cells) pattern.
 
template<typename Lattice >
std::string write_plaintext_string (const Lattice &frame, const Plaintext_Write_Options &opts={}, const typename Lattice::state_type &dead=typename Lattice::state_type{})
 Return a Life plaintext document.
 
Binary_Cell_Pattern read_plaintext (std::istream &in)
 Read a Life plaintext (.cells) pattern.
 
Binary_Cell_Pattern read_plaintext_string (const std::string &s)
 Read a Life plaintext pattern from a string.
 
template<typename Lattice >
void write_life_106 (std::ostream &out, const Lattice &frame, const typename Lattice::state_type &dead=typename Lattice::state_type{})
 Write a Life 1.06 file.
 
Binary_Cell_Pattern read_life_106 (std::istream &in)
 Read a Life 1.06 pattern.
 
template<typename Lattice >
void write_life_105 (std::ostream &out, const Lattice &frame, const std::string &comment={}, const typename Lattice::state_type &dead=typename Lattice::state_type{})
 Write a Life 1.05 file.
 
Binary_Cell_Pattern read_life_105 (std::istream &in)
 Read a Life 1.05 pattern.
 
template<typename Lattice >
void write_csv (std::ostream &out, const Lattice &frame, const CSV_Options &opts={})
 Write a numeric CSV snapshot.
 
template<typename T >
Grid_Snapshot< T > read_csv_snapshot (std::istream &in, const CSV_Options &opts={})
 Read a numeric CSV snapshot.
 
template<typename Lattice , typename T >
Lattice make_lattice_from_snapshot (const Grid_Snapshot< T > &snap)
 Construct a lattice from a numeric snapshot.
 
template<typename Lattice >
void write_json (std::ostream &out, const Lattice &frame, const JSON_Write_Options &opts={})
 Write a JSON snapshot.
 
template<typename T >
Grid_Snapshot< T > read_json_snapshot (std::istream &in)
 Read a JSON numeric snapshot produced by write_json.
 
template<typename Lattice , typename Mapper >
requires requires(Mapper &&m, const typename Lattice::state_type &v) { { m(v) } -> std::convertible_to<std::uint8_t>; }
void write_pgm (std::ostream &out, const Lattice &frame, Mapper &&mapper, const NetPBM_Write_Options &opts={})
 Write a binary PGM (P5) image.
 
template<typename Lattice >
void write_pgm (std::ostream &out, const Lattice &frame, const NetPBM_Write_Options &opts={})
 Write a binary PGM (P5) image using the default binary mapper.
 
template<typename Lattice , typename Mapper >
requires requires(Mapper &&m, const typename Lattice::state_type &v) { { m(v) } -> std::convertible_to<RGB8>; }
void write_ppm (std::ostream &out, const Lattice &frame, Mapper &&mapper, const NetPBM_Write_Options &opts={})
 Write a binary PPM (P6) image.
 
template<typename Lattice >
void write_ppm (std::ostream &out, const Lattice &frame, const NetPBM_Write_Options &opts={})
 Write a binary PPM (P6) image using the default binary mapper.
 
expected< RLE_Pattern, std::string > try_read_rle (std::istream &in)
 Non-throwing variant of read_rle.
 
expected< RLE_Pattern, std::string > try_read_rle_string (const std::string &s)
 Non-throwing variant of read_rle_string.
 
expected< Binary_Cell_Pattern, std::string > try_read_plaintext (std::istream &in)
 Non-throwing variant of read_plaintext.
 
expected< Binary_Cell_Pattern, std::string > try_read_life_105 (std::istream &in)
 Non-throwing variant of read_life_105.
 
expected< Binary_Cell_Pattern, std::string > try_read_life_106 (std::istream &in)
 Non-throwing variant of read_life_106.
 
template<class T >
expected< Grid_Snapshot< T >, std::string > try_read_csv_snapshot (std::istream &in, const CSV_Options &opts={})
 Non-throwing variant of read_csv_snapshot.
 
template<typename T = double>
constexpr Kernel2D< T, 3, 3 > laplacian_5p_kernel () noexcept
 Return the 5-point discrete Laplacian kernel.
 
template<typename T = double>
constexpr Kernel2D< T, 3, 3 > laplacian_9p_kernel () noexcept
 Return the isotropic 9-point discrete Laplacian kernel.
 
template<typename T = double>
constexpr Kernel2D< T, 3, 3 > mean_3x3_kernel () noexcept
 Return a 3x3 mean filter.
 
template<typename T = double>
constexpr Kernel2D< T, 5, 5 > mean_5x5_kernel () noexcept
 Return a 5x5 mean filter.
 
template<typename T = double>
constexpr Kernel2D< T, 3, 3 > sobel_x_kernel () noexcept
 Return the horizontal Sobel gradient kernel.
 
template<typename T = double>
constexpr Kernel2D< T, 3, 3 > sobel_y_kernel () noexcept
 Return the vertical Sobel gradient kernel.
 
template<typename T = double>
constexpr Kernel2D< T, 3, 3 > gaussian_3x3_kernel () noexcept
 Return the separable 3x3 Gaussian blur kernel.
 
template<typename T = double>
constexpr Kernel2D< T, 5, 5 > gaussian_5x5_kernel () noexcept
 Return the separable 5x5 Gaussian blur kernel.
 
template<typename Lattice , typename F >
void for_each_cell (const Lattice &lat, F &&f)
 Visit every cell of a lattice in canonical row-major order.
 
template<typename Lattice >
ca_size_t count_state (const Lattice &lat, const typename Lattice::state_type &s)
 
template<typename Lattice >
ca_size_t count_alive (const Lattice &lat)
 
template<typename Lattice >
ca_size_t total_cells (const Lattice &lat) noexcept
 
template<typename Lattice >
double density (const Lattice &lat, const typename Lattice::state_type &s)
 
template<typename Lattice >
double alive_density (const Lattice &lat)
 
template<typename Lattice >
Array< ca_size_t > state_histogram (const Lattice &lat, std::size_t max_state)
 Count occurrences of every integer state in [0, max_state).
 
template<typename Lattice >
double shannon_entropy (const Lattice &lat, std::size_t max_state)
 Shannon entropy in nats of the [0, max_state) distribution.
 
template<typename Lattice >
std::uint64_t frame_hash (const Lattice &lat)
 Deterministic 64-bit FNV-1a hash of the lattice cells.
 
template<typename Lattice >
bool frames_equal (const Lattice &a, const Lattice &b)
 
template<typename Lattice >
ca_size_t cell_diff_count (const Lattice &a, const Lattice &b)
 
template<typename Lattice >
void write_npy (std::ostream &out, const Lattice &frame)
 Write a lattice frame as a NumPy .npy array.
 
template<typename... Observers>
auto make_composite_observer (Observers &&...observers)
 Build a Composite_Observer with deduced ownership semantics.
 
template<typename Engine , typename Observer >
void attach_observer (Engine &engine, Observer &observer)
 Plug an observer into an engine's pre/post-step hooks.
 
template<typename Engine , typename Observer >
void attach_observer_graph (Engine &engine, Observer &observer)
 Attach an observer to engines without a lattice_type alias.
 
template<typename Lattice , typename Mapper >
requires requires(Mapper &&m, const typename Lattice::state_type &v) { { m(v) } -> std::convertible_to<RGB8>; }
void write_png (std::ostream &out, const Lattice &frame, Mapper &&mapper)
 Write a rank-2 frame as an 8-bit RGB PNG image.
 
template<typename Lattice >
void write_png (std::ostream &out, const Lattice &frame)
 Write a frame as PNG using the default binary RGB mapper.
 
template<typename Mapper >
 Png_Frame_Sink (std::filesystem::path, Mapper, std::size_t=6) -> Png_Frame_Sink< Mapper >
 
constexpr std::uint64_t splitmix64 (std::uint64_t x) noexcept
 64-bit SplitMix hash.
 
constexpr std::uint64_t mix_seed (const std::uint64_t a, const std::uint64_t b) noexcept
 Combine two 64-bit values into a single deterministic hash.
 
template<std::size_t Rank>
constexpr std::uint64_t cell_key_from_coord (const Coord_Vec< Rank > &c) noexcept
 Hash a cell coordinate into a stable 64-bit key.
 
template<std::size_t Rank>
constexpr std::uint64_t cell_seed (const std::uint64_t master_seed, const std::size_t step, const Coord_Vec< Rank > &coord) noexcept
 Build a deterministic per-cell seed.
 
template<std::size_t Rank>
constexpr std::uint64_t cell_seed (const std::uint64_t master_seed, const Cell_Context< Rank > &ctx) noexcept
 Build a deterministic per-cell seed from a Cell_Context.
 
constexpr std::uint64_t thread_step_seed (const std::uint64_t master_seed, const std::size_t thread_id, const std::size_t step) noexcept
 Build a deterministic seed from (master, thread_id, step).
 
template<typename Engine >
double uniform_unit (Engine &eng)
 Map a 64-bit RNG output to a uniform value in [0, 1).
 
template<typename Engine >
std::size_t uniform_int (Engine &eng, const std::size_t lo, const std::size_t hi)
 Sample a uniform integer in [lo, hi] (inclusive).
 
template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<RGB8>; }
void render_lattice_svg (std::ostream &out, const Lattice &frame, Palette &&palette, const SVG_Render_Options &opts={}, const typename Lattice::state_type &dead_state=typename Lattice::state_type{})
 Render a supported rank-2 CA frame as SVG.
 
template<typename Lattice >
void render_lattice_svg (std::ostream &out, const Lattice &frame, const SVG_Render_Options &opts={}, const typename Lattice::state_type &dead_state=typename Lattice::state_type{})
 Render a frame as SVG using the default binary RGB mapper.
 
template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<RGB8>; }
std::string render_lattice_svg_string (const Lattice &frame, Palette &&palette, const SVG_Render_Options &opts={}, const typename Lattice::state_type &dead_state=typename Lattice::state_type{})
 Return a frame rendered as SVG.
 
template<typename Palette >
 Svg_Frame_Sink (std::filesystem::path, Palette, SVG_Render_Options={}, std::size_t=6) -> Svg_Frame_Sink< Palette >
 
template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
void render_rect_lattice_tikz (std::ostream &out, const Lattice &frame, Palette &&palette, const Rect_Tikz_Options &opts={})
 Render a rectangular 2D frame as a TikZ picture.
 
template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
std::string render_rect_lattice_tikz (const Lattice &frame, Palette &&palette, const Rect_Tikz_Options &opts={})
 Return a rectangular frame rendered as TikZ.
 
template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
void render_lattice_tikz (std::ostream &out, const Lattice &frame, Palette &&palette, const Rect_Tikz_Options &opts={})
 Render any supported 2D CA lattice as TikZ.
 
template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
std::string render_lattice_tikz (const Lattice &frame, Palette &&palette, const Rect_Tikz_Options &opts={})
 Return any supported 2D CA lattice rendered as TikZ.
 
template<typename Lattice >
void render_lattice_tikz (std::ostream &out, const Lattice &frame, const Rect_Tikz_Options &opts={})
 Render with the default binary palette.
 
template<typename Lattice >
std::string render_lattice_tikz (const Lattice &frame, const Rect_Tikz_Options &opts={})
 Return a TikZ picture using the default binary palette.
 
constexpr Range1D split_range_balanced (const ca_size_t n, const ca_size_t parts, const ca_size_t idx) noexcept
 Balanced split of [0, n) into parts contiguous ranges.
 
constexpr bool should_run_sequential (const ca_size_t cells, const ca_size_t num_partitions, const ca_size_t min_cells) noexcept
 Decide whether a workload should run sequentially.
 
constexpr std::uint64_t morton_encode_2d (const std::uint32_t x, const std::uint32_t y) noexcept
 Morton (Z-order) encoding of (x, y).
 
constexpr std::uint64_t morton_encode_3d (const std::uint32_t x, const std::uint32_t y, const std::uint32_t z) noexcept
 Morton (Z-order) encoding of (x, y, z).
 
template<typename Lattice >
void write_vtk_legacy (std::ostream &out, const Lattice &frame, const VTK_Write_Options &opts={})
 Write a 2D or 3D lattice as VTK legacy STRUCTURED_POINTS.
 
template<typename Mapper >
 X11_Frame_Sink (Mapper, X11_Viewer_Options={}) -> X11_Frame_Sink< Mapper >
 
template<std::size_t N>
void swap (Bit_Cell_Storage< N > &a, Bit_Cell_Storage< N > &b) noexcept
 Free-function swap so the storage plays nicely with std::swap.
 
template<typename Rule , typename State , std::size_t Rank>
State apply_rule (const Rule &r, const State &s, Neighbor_View< State > v, const Cell_Context< Rank > &ctx)
 Invoke a rule, optionally forwarding the per-cell context.
 
template<typename F , typename Kernel >
Continuous_Rule< F, Kernel > make_continuous_rule (F f, Kernel k, typename Kernel::value_type dt=typename Kernel::value_type{1}, typename Kernel::value_type min_value=-std::numeric_limits< typename Kernel::value_type >::infinity(), typename Kernel::value_type max_value=std::numeric_limits< typename Kernel::value_type >::infinity())
 Helper factory for Continuous_Rule.
 
template<std::size_t Depth, typename F >
History_Rule< Depth, F > make_history_rule (F f)
 Helper factory for History_Rule.
 
template<typename Storage , typename Boundary , std::size_t Halo>
void swap (Ghost_Lattice< Storage, Boundary, Halo > &a, Ghost_Lattice< Storage, Boundary, Halo > &b) noexcept(noexcept(a.swap(b)))
 Free-function swap so Ghost_Lattice works with std::swap.
 
template<typename T >
void swap (Graph_Lattice< T > &a, Graph_Lattice< T > &b) noexcept
 Free-function swap so the lattice plays nicely with std::swap.
 
Array< Array< std::size_t > > make_grid_graph_adjacency (std::size_t rows, std::size_t cols, bool periodic=false)
 Build the adjacency of a 2D 4-neighbour grid graph.
 
Array< Array< std::size_t > > make_path_graph_adjacency (std::size_t n, bool cycle=false)
 Build the adjacency of a path graph with n nodes.
 
std::string format_rule (const Outer_Totalistic_Binary_Rule &r)
 Format a rule as a Conway-style Bxxx/Sxxx string.
 
std::optional< Outer_Totalistic_Binary_Rule > parse_rule (const std::string &s)
 Parse a B.../S... (or Wolfram S/B) rule string.
 
constexpr Hex_Offset axial_to_offset_even_r (Hex_Axial a) noexcept
 Axial -> offset (even-r convention: even rows are shifted right).
 
constexpr Hex_Axial offset_to_axial_even_r (Hex_Offset o) noexcept
 Offset (even-r) -> axial.
 
constexpr Hex_Offset axial_to_offset_odd_r (Hex_Axial a) noexcept
 Axial -> offset (odd-r convention: odd rows are shifted right).
 
constexpr Hex_Axial offset_to_axial_odd_r (Hex_Offset o) noexcept
 Offset (odd-r) -> axial.
 
constexpr Hex_Cube axial_to_cube (Hex_Axial a) noexcept
 Axial -> cube.
 
constexpr Hex_Axial cube_to_axial (Hex_Cube c) noexcept
 Cube -> axial.
 
constexpr ca_size_t hex_distance (Hex_Axial a, Hex_Axial b) noexcept
 Hex distance between two axial coordinates.
 
std::array< double, 2 > axial_to_pixel_pointy (Hex_Axial a, double radius) noexcept
 Pointy-top pixel coordinates of an axial cell.
 
std::array< double, 2 > axial_to_pixel_flat (Hex_Axial a, double radius) noexcept
 Flat-top pixel coordinates of an axial cell.
 
template<typename Lattice , typename Palette >
void render_hex_lattice_tikz (std::ostream &os, const Lattice &lat, Palette &&palette, double radius=0.5, bool pointy_top=true)
 Render a hex frame as a stand-alone TikZ picture.
 
template<typename Lattice , typename Palette >
std::string render_hex_lattice_tikz (const Lattice &lat, Palette &&palette, double radius=0.5, bool pointy_top=true)
 Returns a std::string instead of writing to a stream.
 
template<typename Storage , typename Boundary >
void swap (Lattice< Storage, Boundary > &a, Lattice< Storage, Boundary > &b) noexcept(noexcept(a.swap(b)))
 Free-function swap so the lattice plays nicely with std::swap.
 
template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
void swap (Multi_Field_Lattice< Layout, Boundary, Rank, Fields... > &a, Multi_Field_Lattice< Layout, Boundary, Rank, Fields... > &b) noexcept
 Free-function swap so the lattice plays nicely with std::swap.
 
template<typename Rule , typename FieldsTuple , std::size_t Rank>
FieldsTuple apply_multi_field_rule (const Rule &r, const FieldsTuple &cur, const Field_Neighbor_Views_Tuple< FieldsTuple > &nb, const Cell_Context< Rank > &ctx)
 Invoke a multi-field rule with optional context forwarding.
 
template<typename Nbh , typename L , typename T >
void gather_neighbors (const Nbh &nh, const L &lat, const typename L::coord_type &center, std::span< T > out)
 Populate out[0..nh.size()) with neighbour values of center.
 
constexpr Lookup_Rule< 2, 2 > make_wolfram_elementary_rule (std::uint8_t rule_no) noexcept
 Build the elementary 1D Wolfram rule rule_no (0..255) as a Lookup_Rule<2, 2> over neighbourhood {-1, +1}.
 
constexpr Game_Of_Life_Rule make_game_of_life_rule () noexcept
 Build the canonical Game of Life rule.
 
template<typename T , std::size_t N>
void swap (Dense_Cell_Storage< T, N > &a, Dense_Cell_Storage< T, N > &b) noexcept
 Free-function swap so the storage plays nicely with std::swap.
 
constexpr int tri_parity (const Tri_Coord &c) noexcept
 
constexpr bool tri_is_up (const Tri_Coord &c) noexcept
 
constexpr bool tri_is_down (const Tri_Coord &c) noexcept
 
std::array< double, 2 > tri_pixel_centre (const Tri_Coord &c, const double side) noexcept
 Cartesian centre of a triangle in (i, j) units.
 
template<typename Lattice , typename Palette >
void render_triangular_lattice_tikz (std::ostream &os, const Lattice &lat, Palette &&palette, const double side=1.0)
 Render a triangular frame as a TikZ picture.
 
template<typename Lattice , typename Palette >
std::string render_triangular_lattice_tikz (const Lattice &lat, Palette &&palette, double side=1.0)
 Returns a std::string instead of writing to a stream.
 

Variables

constexpr Outer_Totalistic_Binary_Rule Conway_Life
 Conway's Game of Life: B3/S23.
 
constexpr Outer_Totalistic_Binary_Rule HighLife
 Nathan Thompson's HighLife: B36/S23 (replicators).
 
constexpr Outer_Totalistic_Binary_Rule Day_And_Night
 Bays' Day & Night: B3678/S34678 (self-complementary).
 
constexpr Outer_Totalistic_Binary_Rule Seeds
 Seeds: B2/S (every live cell dies, two neighbours produce a birth).
 

Typedef Documentation

◆ Block_2x2

template<typename State >
using Aleph::CA::Block_2x2 = typedef std::array<State, 4>

Fixed-size 2×2 block of cell values used by Margolus rules.

Layout: block[0] = NW, block[1] = NE, block[2] = SW, block[3] = SE.

Template Parameters
Statecell state type.

Definition at line 82 of file tpl_ca_block_rule.H.

◆ ca_index_t

Signed coordinate component used by lattices and neighborhoods.

Signed because neighborhoods produce negative offsets.

Definition at line 60 of file ca-traits.H.

◆ ca_size_t

Unsigned size component used for extents and counts.

Definition at line 63 of file ca-traits.H.

◆ Coord_Vec

template<std::size_t N>
using Aleph::CA::Coord_Vec = typedef std::array<ca_index_t, N>

Default coordinate vector.

Template Parameters
Nnumber of axes.

Definition at line 69 of file ca-traits.H.

◆ DirichletBoundary

Alias for ConstantBoundary<T, V> using the "Dirichlet" name.

Template Parameters
Tcell state type.
Vimposed value on the out-of-range cells.

Definition at line 170 of file ca-traits.H.

◆ Field_Neighbor_Views_Tuple

std::tuple<Neighbor_View<F>...> for the field tuple std::tuple<F...>.

Definition at line 98 of file tpl_ca_multi_field_rule.H.

◆ Game_Of_Life_Engine

Game-of-Life engine type alias (toroidal, integer cells).

Definition at line 67 of file ca-engine-utils.H.

◆ Game_Of_Life_Rule

Outer-totalistic rule type implementing Conway's Game of Life.

Definition at line 515 of file tpl_ca_rule.H.

◆ Neighbor_View

Read-only view over a contiguous range of neighbour values.

A Neighbor_View<T> is a thin std::span<const T> populated by gather_neighbors (see tpl_ca_neighborhood.H) on a stack buffer. Rules consume it without owning the underlying memory.

Template Parameters
Tcell state type.

Definition at line 90 of file ca-traits.H.

◆ Offset_Vec

template<std::size_t N>
using Aleph::CA::Offset_Vec = typedef Coord_Vec<N>

Default offset vector (aliases Coord_Vec).

Used by neighborhoods to express signed displacements that are added to a lattice coordinate. The type is identical to Coord_Vec<N>; the alias exists to make intent explicit at call sites.

Definition at line 79 of file ca-traits.H.

◆ PeriodicBoundary

Alias for ToroidalBoundary using the HPC "periodic" terminology.

Definition at line 163 of file ca-traits.H.

◆ RLE_Pattern

Backwards-readable alias for Conway RLE patterns.

Definition at line 116 of file ca-io.H.

◆ Wolfram_1D_Engine

1D Wolfram engine type alias (open boundary, integer cells).

Definition at line 106 of file ca-engine-utils.H.

Enumeration Type Documentation

◆ Forest_Cell

enum class Aleph::CA::Forest_Cell : std::uint8_t
strong

Discrete states of the forest-fire automaton.

Encoded as a small integer so that the rule plays nicely with any integral cell type (std::uint8_t, int, ...).

Enumerator
EMPTY 

Empty ground cell.

TREE 

Healthy tree.

BURNING 

Tree currently on fire (lasts exactly one step).

Definition at line 89 of file tpl_ca_stochastic_rules.H.

◆ Frame_Output_Format

File format used by Directory_Frame_Sink.

Complexity
O(1) storage.
Enumerator
PGM 

binary NetPBM grayscale (.pgm)

PPM 

binary NetPBM RGB (.ppm)

RLE 

Conway RLE (.rle)

CSV 

numeric CSV (.csv)

JSON 

JSON snapshot (.json)

TikZ 

TikZ picture (.tex)

Definition at line 91 of file ca-frame-stream.H.

◆ Schelling_Cell

enum class Aleph::CA::Schelling_Cell : std::uint8_t
strong

Discrete states of the Schelling automaton.

Enumerator
EMPTY 

Vacant cell.

TYPE_A 

Agent of type A.

TYPE_B 

Agent of type B.

Definition at line 572 of file tpl_ca_stochastic_rules.H.

◆ SIR_Cell

enum class Aleph::CA::SIR_Cell : std::uint8_t
strong

Discrete states of the SIR automaton.

Enumerator
S 

Susceptible.

I 

Infected (and infectious).

R 

Recovered (and immune).

Definition at line 218 of file tpl_ca_stochastic_rules.H.

Function Documentation

◆ alive_density()

template<typename Lattice >
double Aleph::CA::alive_density ( const Lattice &  lat)
inline
Returns
ratio in [0, 1] of cells whose value differs from state_type{}. Convenience for binary CAs.

Definition at line 223 of file ca-metrics.H.

References alive_density(), Aleph::blossom_maximum_cardinality_matching(), count_alive(), and total_cells().

Referenced by alive_density(), TEST(), and TEST().

◆ apply_delta_checkpoint()

template<typename Engine >
requires Checkpointable_Engine<Engine>
Resume_Token Aleph::CA::apply_delta_checkpoint ( Engine &  engine,
const std::filesystem::path &  path 
)

Apply a delta checkpoint to the engine's current state.

The caller must have already loaded the baseline snapshot (the one referenced by header.delta_base_step) into the engine, typically via load_checkpoint_into. This function then overlays the per-cell mutations recorded in the delta file.

Template Parameters
Engineengine type satisfying Checkpointable_Engine.
Parameters
[in,out]engineengine to mutate in place.
[in]pathdelta checkpoint path.
Returns
resume token with the delta header (note: step_count is the target step recorded in the delta file).
Exceptions
std::runtime_errorwhen the file is not a delta, when metadata disagrees with the engine, or on short reads.

Definition at line 1156 of file ca-checkpoint.H.

References ah_runtime_error_if, apply_delta_checkpoint(), Aleph::CA::Checkpoint_Header::cell_count, Aleph::diff(), engine, Aleph::CA::Checkpoint_Header::engine_type_hash, Aleph::CA::Checkpoint_Header::extents, Aleph::CA::Checkpoint_Header::flags, Aleph::CA::Checkpoint_Header::has_rng, Aleph::CA::Resume_Token::header, inspect_checkpoint(), k, Aleph::CA::Checkpoint_Header::master_seed, Aleph::CA::Checkpoint_Header::payload_size, Aleph::CA::Checkpoint_Header::rank, Aleph::CA::Resume_Token::source_path, Aleph::CA::Checkpoint_Header::state_type_size, Aleph::CA::Checkpoint_Header::step_count, and value.

Referenced by apply_delta_checkpoint(), and TEST().

◆ apply_multi_field_rule()

template<typename Rule , typename FieldsTuple , std::size_t Rank>
FieldsTuple Aleph::CA::apply_multi_field_rule ( const Rule &  r,
const FieldsTuple &  cur,
const Field_Neighbor_Views_Tuple< FieldsTuple > &  nb,
const Cell_Context< Rank > &  ctx 
)
inline

Invoke a multi-field rule with optional context forwarding.

Mirrors the role of apply_rule in the mono-field path: the contextual signature is preferred when supported; otherwise the pure signature is used.

Template Parameters
Rulerule type.
FieldsTuplefield tuple type.
Ranklattice rank.
Parameters
[in]rrule instance.
[in]curcurrent per-field values tuple.
[in]nbper-field neighbour views tuple.
[in]ctxper-cell context (forwarded to the rule when accepted).
Returns
new per-field values tuple.

Definition at line 153 of file tpl_ca_multi_field_rule.H.

References Aleph::blossom_maximum_cardinality_matching(), and r.

◆ apply_rule()

template<typename Rule , typename State , std::size_t Rank>
State Aleph::CA::apply_rule ( const Rule &  r,
const State &  s,
Neighbor_View< State >  v,
const Cell_Context< Rank > &  ctx 
)
inline

Invoke a rule, optionally forwarding the per-cell context.

When the rule supports the (state, neighbours, ctx) signature (ContextualRuleLike), the context is forwarded; otherwise the function falls back to the legacy (state, neighbours) form. This helper is the single dispatch point used by every CA engine in the module so adding new contextual rules never requires touching the engines.

Template Parameters
Rulerule type satisfying RuleLike.
Statecell state type.
Ranklattice dimension.
Parameters
[in]rrule instance.
[in]scurrent state of the centre cell.
[in]vneighbour view (gathered upstream).
[in]ctxper-cell context (step, coord).
Returns
the next state produced by the rule.
Exceptions
Anyexception thrown by the rule.

Definition at line 225 of file tpl_ca_concepts.H.

References r.

Referenced by Aleph::CA::Synchronous_Update< Order >::apply(), Aleph::CA::Sequential_Update< Order >::apply(), Aleph::CA::Random_Asynchronous_Update< Engine_Type >::apply(), Aleph::CA::Block_Synchronous_Update< BlockSize, Order >::apply(), Aleph::CA::Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::step(), Aleph::CA::Graph_Synchronous_Engine< Lattice, Rule >::step(), TEST(), TEST(), and Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::update_cell().

◆ Ascii_Frame_Sink()

template<typename Palette >
Aleph::CA::Ascii_Frame_Sink ( std::ostream &  ,
Palette  ,
Ascii_Render_Options  = {},
bool  = true 
) -> Ascii_Frame_Sink< Palette >

◆ attach_observer()

void Aleph::CA::attach_observer ( Engine &  engine,
Observer &  observer 
)
inline

Plug an observer into an engine's pre/post-step hooks.

Captures observer by reference: the caller owns the observer's lifetime, which must outlive the engine. The wiring uses the existing on_pre_step / on_post_step hooks, so the parallel engine and the graph engine are supported transparently.

Parameters
[in,out]engineengine instance.
[in,out]observerobserver instance to wire.
Exceptions
Anyexception thrown by engine hook registration.
Complexity
O(1) time and space.
Thread-safety
Not thread-safe if the engine is concurrently mutated. The observer is captured by reference and must outlive the engine callbacks.

Definition at line 262 of file ca-observer.H.

References Aleph::blossom_maximum_cardinality_matching(), and engine.

Referenced by main(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ attach_observer_graph()

void Aleph::CA::attach_observer_graph ( Engine &  engine,
Observer &  observer 
)
inline

Attach an observer to engines without a lattice_type alias.

This overload is intended for Graph_Synchronous_Engine; it captures the observer by reference and deduces the frame type in the hook lambdas.

Parameters
[in,out]engineengine instance.
[in,out]observerobserver instance; must outlive callbacks.
Exceptions
Anyexception thrown by engine hook registration.
Complexity
O(1) time and space.
Thread-safety
Not thread-safe if the engine is concurrently mutated.

Definition at line 292 of file ca-observer.H.

References Aleph::blossom_maximum_cardinality_matching(), and engine.

◆ axial_to_cube()

constexpr Hex_Cube Aleph::CA::axial_to_cube ( Hex_Axial  a)
inlineconstexprnoexcept

Axial -> cube.

Definition at line 180 of file tpl_ca_hex_lattice.H.

Referenced by hex_distance(), and TEST().

◆ axial_to_offset_even_r()

constexpr Hex_Offset Aleph::CA::axial_to_offset_even_r ( Hex_Axial  a)
inlineconstexprnoexcept

Axial -> offset (even-r convention: even rows are shifted right).

Definition at line 151 of file tpl_ca_hex_lattice.H.

References col.

Referenced by TEST().

◆ axial_to_offset_odd_r()

constexpr Hex_Offset Aleph::CA::axial_to_offset_odd_r ( Hex_Axial  a)
inlineconstexprnoexcept

Axial -> offset (odd-r convention: odd rows are shifted right).

Definition at line 166 of file tpl_ca_hex_lattice.H.

References col.

Referenced by TEST().

◆ axial_to_pixel_flat()

std::array< double, 2 > Aleph::CA::axial_to_pixel_flat ( Hex_Axial  a,
double  radius 
)
inlinenoexcept

Flat-top pixel coordinates of an axial cell.

Returns the centre of the hex assuming flat-top tiling.

Parameters
[in]aaxial coords.
[in]radiushex circumradius.
Returns
{x, y} Cartesian centre.

Definition at line 235 of file tpl_ca_hex_lattice.H.

References Aleph::blossom_maximum_cardinality_matching(), and y.

Referenced by render_hex_lattice_tikz().

◆ axial_to_pixel_pointy()

std::array< double, 2 > Aleph::CA::axial_to_pixel_pointy ( Hex_Axial  a,
double  radius 
)
inlinenoexcept

Pointy-top pixel coordinates of an axial cell.

Returns the centre of the hex with the given axial coords assuming pointy-top tiling and circumradius radius. Axis 0 (r) maps to Y growing downward; axis 1 (q) maps to X growing rightward.

Parameters
[in]aaxial coords.
[in]radiushex circumradius (centre-to-vertex distance).
Returns
{x, y} Cartesian centre, in the same units as radius.

Definition at line 217 of file tpl_ca_hex_lattice.H.

References Aleph::blossom_maximum_cardinality_matching(), and y.

Referenced by Aleph::CA::ca_svg_detail::hex_points(), render_hex_lattice_tikz(), and TEST().

◆ bench_seconds()

template<typename F >
double Aleph::CA::bench_seconds ( F &&  f)
inline

Run f() once and return the wall-clock time it took, in seconds.

The functor's return value is discarded. Use this when the work is large enough that a single sample is meaningful. For repeatable microbenches at the µs scale, average several invocations manually.

Template Parameters
Finvocable type, callable as f().
Parameters
[in]ffunctor to time.
Returns
seconds spent inside f().

Definition at line 111 of file ca-bench.H.

References Aleph::CA::Bench_Timer::elapsed_seconds().

Referenced by main().

◆ cell_diff_count()

◆ cell_key_from_coord()

template<std::size_t Rank>
constexpr std::uint64_t Aleph::CA::cell_key_from_coord ( const Coord_Vec< Rank > &  c)
inlineconstexprnoexcept

Hash a cell coordinate into a stable 64-bit key.

The hash depends only on the coordinate components; rank is folded into the avalanche through splitmix64. Two coordinates produce the same key iff every component matches.

Template Parameters
Rankcoordinate rank.
Parameters
[in]ccell coordinate.
Returns
deterministic 64-bit key.
Exceptions
Thisfunction does not throw.

Definition at line 115 of file ca-rng.H.

References Aleph::blossom_maximum_cardinality_matching(), h, and splitmix64().

◆ cell_seed() [1/2]

template<std::size_t Rank>
constexpr std::uint64_t Aleph::CA::cell_seed ( const std::uint64_t  master_seed,
const Cell_Context< Rank > &  ctx 
)
inlineconstexprnoexcept

Build a deterministic per-cell seed from a Cell_Context.

Template Parameters
Rankcoordinate rank (deduced from ctx).
Parameters
[in]master_seeduser-controlled root seed.
[in]ctxper-cell context produced by the engine.
Returns
per-cell seed.
Exceptions
Thisfunction does not throw.

Definition at line 160 of file ca-rng.H.

References Aleph::blossom_maximum_cardinality_matching().

◆ cell_seed() [2/2]

template<std::size_t Rank>
constexpr std::uint64_t Aleph::CA::cell_seed ( const std::uint64_t  master_seed,
const std::size_t  step,
const Coord_Vec< Rank > &  coord 
)
inlineconstexprnoexcept

Build a deterministic per-cell seed.

Given a master seed, a step index and a cell coordinate, returns a 64-bit value that uniquely identifies this (master, step, coord) triple. The mixing avalanche makes the output statistically independent across consecutive (step, coord) triples.

Template Parameters
Rankcoordinate rank.
Parameters
[in]master_seeduser-controlled root seed.
[in]stepstep index that is being evaluated.
[in]coordcell coordinate.
Returns
per-cell seed.
Exceptions
Thisfunction does not throw.

Definition at line 141 of file ca-rng.H.

References Aleph::blossom_maximum_cardinality_matching(), and splitmix64().

◆ count_alive()

template<typename Lattice >
ca_size_t Aleph::CA::count_alive ( const Lattice &  lat)
inline
Returns
number of cells whose value differs from state_type{}.

Definition at line 188 of file ca-metrics.H.

References Aleph::blossom_maximum_cardinality_matching(), count_alive(), and for_each_cell().

Referenced by alive_density(), count_alive(), TEST(), and TEST().

◆ count_state()

◆ cube_to_axial()

constexpr Hex_Axial Aleph::CA::cube_to_axial ( Hex_Cube  c)
inlineconstexprnoexcept

Cube -> axial.

Definition at line 188 of file tpl_ca_hex_lattice.H.

Referenced by TEST().

◆ density()

template<typename Lattice >
double Aleph::CA::density ( const Lattice &  lat,
const typename Lattice::state_type &  s 
)
inline
Returns
ratio in [0, 1] of cells in state s. Returns 0 for empty lattices.

Definition at line 212 of file ca-metrics.H.

References Aleph::blossom_maximum_cardinality_matching(), count_state(), density(), and total_cells().

Referenced by density(), Aleph::CA::Reproductions::fit_log_log_histogram(), seed_random(), TEST(), TEST(), and TEST().

◆ Dot_Frame_Sink()

template<typename Palette >
Aleph::CA::Dot_Frame_Sink ( std::filesystem::path  ,
Palette  ,
DOT_Render_Options  = {},
std::size_t  = 6 
) -> Dot_Frame_Sink< Palette >

◆ Ffmpeg_Frame_Sink()

template<typename Mapper >
Aleph::CA::Ffmpeg_Frame_Sink ( std::filesystem::path  ,
Mapper  ,
Ffmpeg_Options  = {} 
) -> Ffmpeg_Frame_Sink< Mapper >

◆ for_each_cell()

template<typename Lattice , typename F >
void Aleph::CA::for_each_cell ( const Lattice &  lat,
F &&  f 
)
inline

Visit every cell of a lattice in canonical row-major order.

Calls f(value) once per cell. Works for the rectangular ranks (1, 2, 3) and for graph lattices (any type that exposes at_node(size_t)).

Template Parameters
Latticelattice type satisfying LatticeLike.
Finvocable with the cell state_type.
Parameters
[in]latlattice to traverse.
[in]ffunctor applied to every cell value.
Complexity
O(N), where N is the cell count.

Definition at line 133 of file ca-metrics.H.

References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Lattice< Storage, Boundary >::rank, and Aleph::HTList::size().

Referenced by count_alive(), count_state(), frame_hash(), state_histogram(), and TEST().

◆ format_rule()

std::string Aleph::CA::format_rule ( const Outer_Totalistic_Binary_Rule &  r)
inline

Format a rule as a Conway-style Bxxx/Sxxx string.

Parameters
rthe rule to format.
Returns
human-readable rule string.

Definition at line 145 of file tpl_ca_hashlife.H.

References r.

Referenced by TEST().

◆ format_step_path()

std::filesystem::path Aleph::CA::format_step_path ( const std::filesystem::path &  pattern,
const std::size_t  step,
const std::size_t  zero_pad = 6 
)
inline

Format a step-indexed file path.

Replaces either {step} or {} in pattern with a zero-padded decimal representation of step. If no placeholder is present the pattern is returned unchanged, which is useful for single-file sinks.

Parameters
[in]patternpath pattern.
[in]stepsimulation step.
[in]zero_padminimum width of the step field.
Returns
formatted path.
Complexity
O(pattern length).

Definition at line 212 of file ca-frame-stream.H.

References Aleph::CA::ca_frame_stream_detail::format_step_path().

Referenced by Aleph::CA::Dot_Frame_Sink< Palette >::accept(), Aleph::CA::Npy_Frame_Sink::accept(), Aleph::CA::Png_Frame_Sink< Mapper >::accept(), Aleph::CA::VTK_Frame_Sink::accept(), and Aleph::CA::Svg_Frame_Sink< Palette >::accept().

◆ format_throughput()

const char * Aleph::CA::format_throughput ( double  cells_per_second)
inline

Format a "cells per second" rate as "X.XX M cells/s".

Helper used by the bench example to pretty-print throughput numbers in a small table. Rates above one giga-cell are reported as G.

Parameters
[in]cells_per_secondraw rate in cells / s.
Returns
a static-storage C string with the formatted value.

Definition at line 126 of file ca-bench.H.

References Aleph::blossom_maximum_cardinality_matching().

Referenced by main().

◆ frame_hash()

template<typename Lattice >
std::uint64_t Aleph::CA::frame_hash ( const Lattice &  lat)
inline

Deterministic 64-bit FNV-1a hash of the lattice cells.

Visits cells in canonical row-major order and folds their byte representation into a running FNV-1a 64-bit hash. The result is stable across runs, builds and machines with the same endianness for any trivially copyable state_type. The cell-by-cell layout guarantees that two lattices that compare equal hash to the same value.

Parameters
[in]latlattice to hash.
Returns
64-bit FNV-1a hash of the cell sequence.
Complexity
O(N) byte mixes, where N is the cell count.

Definition at line 311 of file ca-metrics.H.

References Aleph::blossom_maximum_cardinality_matching(), for_each_cell(), frame_hash(), and h.

Referenced by frame_hash(), Aleph::CA::Stationary_Detector::on_step_begin(), Aleph::CA::Stationary_Detector::on_step_end(), TEST(), TEST(), TEST(), and TEST().

◆ frames_equal()

◆ gather_neighbors()

template<typename Nbh , typename L , typename T >
void Aleph::CA::gather_neighbors ( const Nbh &  nh,
const L &  lat,
const typename L::coord_type &  center,
std::span< T >  out 
)
inline

Populate out[0..nh.size()) with neighbour values of center.

The caller owns the buffer (typically a std::array<T, N> on the stack). Order matches nh.for_each_offset. Out-of-range neighbours are resolved by the lattice's boundary policy via at_safe.

Parameters
[in]nhneighborhood instance.
[in]latlattice to read from.
[in]centercenter coordinate.
[out]outbuffer of at least nh.size() cells.
Exceptions
std::length_errorif out is smaller than nh.size().

Definition at line 569 of file tpl_ca_neighborhood.H.

References ah_length_error_if, Aleph::blossom_maximum_cardinality_matching(), and out.

Referenced by Aleph::CA::Synchronous_Update< Order >::apply(), Aleph::CA::Sequential_Update< Order >::apply(), Aleph::CA::Random_Asynchronous_Update< Engine_Type >::apply(), Aleph::CA::Block_Synchronous_Update< BlockSize, Order >::apply(), Aleph::CA::Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::step(), TEST(), TEST(), TEST(), and Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::update_cell().

◆ gaussian_3x3_kernel()

template<typename T = double>
constexpr Kernel2D< T, 3, 3 > Aleph::CA::gaussian_3x3_kernel ( )
constexprnoexcept

Return the separable 3x3 Gaussian blur kernel.

Template Parameters
Tnumeric weight type.
Returns
normalized Gaussian-like kernel with total mass 1.
Exceptions
Thisfunction does not throw.

Definition at line 408 of file ca-kernels.H.

References Aleph::blossom_maximum_cardinality_matching().

◆ gaussian_5x5_kernel()

template<typename T = double>
constexpr Kernel2D< T, 5, 5 > Aleph::CA::gaussian_5x5_kernel ( )
constexprnoexcept

Return the separable 5x5 Gaussian blur kernel.

Template Parameters
Tnumeric weight type.
Returns
normalized binomial kernel with total mass 1.
Exceptions
Thisfunction does not throw.

Definition at line 422 of file ca-kernels.H.

References Aleph::blossom_maximum_cardinality_matching().

◆ Gif_Frame_Sink()

template<typename Mapper >
Aleph::CA::Gif_Frame_Sink ( std::filesystem::path  ,
Mapper  ,
GIF_Write_Options  = {} 
) -> Gif_Frame_Sink< Mapper >

◆ hex_distance()

constexpr ca_size_t Aleph::CA::hex_distance ( Hex_Axial  a,
Hex_Axial  b 
)
inlineconstexprnoexcept

Hex distance between two axial coordinates.

Computed via the cube representation: (|dx| + |dy| + |dz|) / 2, which equals the minimum number of unit hex steps from a to b.

Definition at line 198 of file tpl_ca_hex_lattice.H.

References axial_to_cube(), and Aleph::blossom_maximum_cardinality_matching().

Referenced by main(), and TEST().

◆ HTML_Player_Frame_Sink()

template<typename Mapper >
Aleph::CA::HTML_Player_Frame_Sink ( std::filesystem::path  ,
Mapper  ,
HTML_Player_Options  = {} 
) -> HTML_Player_Frame_Sink< Mapper >

◆ inspect_checkpoint()

Checkpoint_Header Aleph::CA::inspect_checkpoint ( const std::filesystem::path &  path)
inline

Read just the header from a checkpoint file.

Accepts both format_version = 1 (Phase 15) and format_version = 2 (Phase 17). v1 readers see v2-only fields as zero; flags / payload metadata are then synthesised from the defaults (uncompressed, full snapshot).

Parameters
[in]pathcheckpoint file to inspect.
Returns
validated header.
Exceptions
std::runtime_erroron missing file, bad magic, version mismatch or short read.

Definition at line 515 of file ca-checkpoint.H.

References ah_runtime_error_if, Aleph::and, Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Checkpoint_Header::format_version, and h.

Referenced by apply_delta_checkpoint(), load_checkpoint_into(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ laplacian_5p_kernel()

template<typename T = double>
constexpr Kernel2D< T, 3, 3 > Aleph::CA::laplacian_5p_kernel ( )
constexprnoexcept

Return the 5-point discrete Laplacian kernel.

Stencil:

0 1 0
1 -4 1
0 1 0
Template Parameters
Tnumeric weight type.
Returns
Kernel2D<T, 3, 3> with zero total mass.
Exceptions
Thisfunction does not throw.

Definition at line 323 of file ca-kernels.H.

References Aleph::blossom_maximum_cardinality_matching().

◆ laplacian_9p_kernel()

template<typename T = double>
constexpr Kernel2D< T, 3, 3 > Aleph::CA::laplacian_9p_kernel ( )
constexprnoexcept

Return the isotropic 9-point discrete Laplacian kernel.

Stencil:

1 4 1
4 -20 4 * 1/6
1 4 1
Template Parameters
Tnumeric weight type.
Returns
Kernel2D<T, 3, 3> with zero total mass.
Exceptions
Thisfunction does not throw.

Definition at line 343 of file ca-kernels.H.

References Aleph::blossom_maximum_cardinality_matching().

◆ load_binary_pattern()

template<typename Lattice >
void Aleph::CA::load_binary_pattern ( const Binary_Cell_Pattern &  pattern,
Lattice &  frame,
const typename Lattice::state_type &  alive = static_cast<typename Lattice::state_type>(1),
const typename Lattice::state_type &  dead = typename Lattice::state_type{},
const ca_index_t  origin_row = 0,
const ca_index_t  origin_col = 0 
)
inline

Fill a lattice from a binary pattern.

The destination is cleared to dead, then all pattern live cells are stamped as alive at (origin_row, origin_col).

Template Parameters
Lattice2D lattice type.
Parameters
[in]patternsource binary pattern.
[in,out]framedestination lattice.
[in]alivestate assigned to live pattern cells.
[in]deadstate used to clear the frame.
[in]origin_rowrow offset in the destination.
[in]origin_colcolumn offset in the destination.
Exceptions
std::domain_errorif the pattern does not fit.
Complexity
O(frame cells + live cells).

Definition at line 809 of file ca-io.H.

References load_binary_pattern().

Referenced by load_binary_pattern().

◆ load_checkpoint_into()

template<typename Engine >
requires Checkpointable_Engine<Engine>
Resume_Token Aleph::CA::load_checkpoint_into ( Engine &  engine,
const std::filesystem::path &  path 
)

Restore an engine's state in-place from a checkpoint file.

Accepts both v1 (Phase 15) and v2 (Phase 17) files; compressed and uncompressed payloads are handled transparently. Delta files (flags & delta) are not accepted here — use apply_delta_checkpoint for those.

The engine must have been built with extents that match the snapshot. The function rebuilds the lattice contents cell-by-cell, restores the step counter and forwards the recorded master seed to the rule when both sides expose the Has_Master_Seed contract.

Template Parameters
Engineengine type satisfying Checkpointable_Engine.
Parameters
[in,out]engineengine to populate.
[in]pathcheckpoint file path.
Returns
resume token recording the file path and validated header.
Exceptions
std::runtime_erroron bad magic, version mismatch, type hash mismatch, extents mismatch, short read or attempts to load a delta file with this entry point.
Complexity
O(N) where N is the cell count.

Definition at line 998 of file ca-checkpoint.H.

References ah_runtime_error_if, engine, Aleph::CA::Checkpoint_Header::engine_type_hash, Aleph::CA::Checkpoint_Header::extents, Aleph::CA::Checkpoint_Header::flags, Aleph::CA::Checkpoint_Header::has_rng, Aleph::CA::Resume_Token::header, inspect_checkpoint(), load_checkpoint_into(), Aleph::CA::Checkpoint_Header::master_seed, Aleph::CA::Checkpoint_Header::rank, Aleph::CA::Resume_Token::source_path, Aleph::CA::Checkpoint_Header::state_type_size, and Aleph::CA::Checkpoint_Header::step_count.

Referenced by LLVMFuzzerTestOneInput(), load_checkpoint_into(), main(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ make_composite_observer()

template<typename... Observers>
auto Aleph::CA::make_composite_observer ( Observers &&...  observers)
inline

Build a Composite_Observer with deduced ownership semantics.

Lvalue arguments are stored as references, so later state changes remain visible through the original observer objects. Rvalue arguments are moved into and owned by the composite.

Template Parameters
Observersdeduced observer argument types.
Parameters
[in]observersobserver objects or references.
Returns
a composite observer preserving lvalue references.
Exceptions
Anyexception thrown while constructing the composite.
Complexity
O(number of observers) time and space.

Definition at line 234 of file ca-observer.H.

References Aleph::blossom_maximum_cardinality_matching().

Referenced by TEST().

◆ make_continuous_rule()

template<typename F , typename Kernel >
Continuous_Rule< F, Kernel > Aleph::CA::make_continuous_rule ( F  f,
Kernel  k,
typename Kernel::value_type  dt = typename Kernel::value_type{1},
typename Kernel::value_type  min_value = -std::numeric_limits<typename Kernel::value_type>::infinity(),
typename Kernel::value_type  max_value = std::numeric_limits<typename Kernel::value_type>::infinity() 
)

Helper factory for Continuous_Rule.

Template Parameters
Fcallable rule body.
Kernelkernel type.
Parameters
[in]ftransition functor.
[in]kconvolution kernel.
[in]dtexplicit Euler time step.
[in]min_valueminimum accepted next state.
[in]max_valuemaximum accepted next state.
Returns
configured Continuous_Rule.
Exceptions
Anyexception thrown by the constructor.

Definition at line 247 of file tpl_ca_continuous_rules.H.

Referenced by TEST(), and TEST().

◆ make_game_of_life_rule()

constexpr Game_Of_Life_Rule Aleph::CA::make_game_of_life_rule ( )
inlineconstexprnoexcept

Build the canonical Game of Life rule.

Returns
an outer-totalistic B3/S23 rule.
Exceptions
Thisfunction does not throw.

Definition at line 522 of file tpl_ca_rule.H.

Referenced by LLVMFuzzerTestOneInput(), main(), main(), main(), make_gol_engine(), make_gol_engine(), run_engine_equivalence(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ make_gol_engine() [1/2]

Game_Of_Life_Engine Aleph::CA::make_gol_engine ( ca_size_t  rows,
ca_size_t  cols 
)
inline

Build a Conway's Game of Life engine of the given shape.

All cells start dead. To stamp a pattern before stepping, build a Lattice initial(...) and pass it to the seeded overload.

Parameters
[in]rowsnumber of rows (axis 0).
[in]colsnumber of columns (axis 1).
Returns
a synchronous Game of Life engine with toroidal borders.
Complexity
O(rows * cols) for lattice allocation and initialisation.

Definition at line 82 of file ca-engine-utils.H.

References Aleph::blossom_maximum_cardinality_matching(), cols, make_game_of_life_rule(), and rows.

Referenced by aleph_ca_create_gol_engine_v1(), and main().

◆ make_gol_engine() [2/2]

Game_Of_Life_Engine Aleph::CA::make_gol_engine ( Lattice< Dense_Cell_Storage< int, 2 >, ToroidalBoundary >  initial)
inline

Build a Game of Life engine seeded with an explicit lattice.

Use this overload when the initial pattern must be stamped before the first step().

Parameters
[in]initiallattice that becomes the current frame.
Returns
a synchronous Game of Life engine with toroidal borders.
Complexity
O(initial.size()) for the next-buffer allocation.

Definition at line 99 of file ca-engine-utils.H.

References Aleph::blossom_maximum_cardinality_matching(), and make_game_of_life_rule().

◆ make_grid_graph_adjacency()

Array< Array< std::size_t > > Aleph::CA::make_grid_graph_adjacency ( std::size_t  rows,
std::size_t  cols,
bool  periodic = false 
)
inline

Build the adjacency of a 2D 4-neighbour grid graph.

Node id n = i * cols + j for cell (i, j). Each interior node has four neighbours (up, down, left, right). When periodic is set the boundaries wrap (every node has exactly four neighbours).

Parameters
[in]rowsgrid rows.
[in]colsgrid cols.
[in]periodictoroidal boundaries when true.
Returns
adjacency list with rows * cols entries.
Complexity
O(rows * cols).

Definition at line 445 of file tpl_ca_graph_automaton.H.

References Aleph::Array< T >::append(), Aleph::blossom_maximum_cardinality_matching(), cols, row, and rows.

Referenced by TEST(), TEST(), TEST(), TEST(), and TEST().

◆ make_history_rule()

template<std::size_t Depth, typename F >
History_Rule< Depth, F > Aleph::CA::make_history_rule ( F  f)

Helper factory for History_Rule.

Template Parameters
Depthhistory depth.
Ftransition functor type.
Parameters
[in]ftransition functor.
Returns
configured History_Rule.
Exceptions
Anyexception thrown by the constructor.

Definition at line 832 of file tpl_ca_continuous_rules.H.

References Aleph::blossom_maximum_cardinality_matching().

◆ make_lattice_from_pattern()

template<typename Lattice >
Lattice Aleph::CA::make_lattice_from_pattern ( const Binary_Cell_Pattern &  pattern,
const typename Lattice::state_type &  alive = static_cast<typename Lattice::state_type>(1),
const typename Lattice::state_type &  dead = typename Lattice::state_type{} 
)
inline

Construct a lattice with the exact dimensions of a pattern.

Template Parameters
Lattice2D lattice type constructible from extents and value.
Parameters
[in]patternsource binary pattern.
[in]alivestate assigned to live cells.
[in]deadstate assigned to dead cells.
Returns
lattice containing the pattern at the top-left corner.
Complexity
O(pattern area + live cells).

Definition at line 843 of file ca-io.H.

References make_lattice_from_pattern().

Referenced by make_lattice_from_pattern().

◆ make_lattice_from_snapshot()

template<typename Lattice , typename T >
Lattice Aleph::CA::make_lattice_from_snapshot ( const Grid_Snapshot< T > &  snap)
inline

Construct a lattice from a numeric snapshot.

Template Parameters
Lattice2D lattice type.
Tsnapshot scalar type.
Parameters
[in]snapsource snapshot.
Returns
lattice with static_cast<state_type> converted cells.
Complexity
O(snapshot cells).

Definition at line 1283 of file ca-io.H.

References Aleph::blossom_maximum_cardinality_matching(), make_lattice_from_snapshot(), r, and Aleph::CA::Lattice< Storage, Boundary >::set().

Referenced by make_lattice_from_snapshot().

◆ make_path_graph_adjacency()

Array< Array< std::size_t > > Aleph::CA::make_path_graph_adjacency ( std::size_t  n,
bool  cycle = false 
)
inline

Build the adjacency of a path graph with n nodes.

Node k is adjacent to k-1 and k+1 (when those exist). When cycle is true, the path closes into a ring (every node has exactly two neighbours).

Parameters
[in]nnumber of nodes.
[in]cycleclose into a cycle when true.
Returns
adjacency list with n entries.

Definition at line 488 of file tpl_ca_graph_automaton.H.

References Aleph::and, Aleph::Array< T >::append(), and Aleph::blossom_maximum_cardinality_matching().

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ make_wolfram_elementary_rule()

constexpr Lookup_Rule< 2, 2 > Aleph::CA::make_wolfram_elementary_rule ( std::uint8_t  rule_no)
inlineconstexprnoexcept

Build the elementary 1D Wolfram rule rule_no (0..255) as a Lookup_Rule<2, 2> over neighbourhood {-1, +1}.

The standard Wolfram code orders patterns as (left, self, right) with bit weight (left << 2) | (self << 1) | (right << 0) and packs the next-state bits into rule_no. Our Lookup_Rule uses (self, left, right) with weight (self << 2) | (left << 1) | right. This factory rewrites the table accordingly.

Parameters
[in]rule_noWolfram rule number, in [0, 255].
Returns
lookup rule equivalent to the requested elementary rule.
Exceptions
Thisfunction does not throw.

Definition at line 304 of file tpl_ca_rule.H.

References Aleph::blossom_maximum_cardinality_matching().

Referenced by make_wolfram_engine(), make_wolfram_engine(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ make_wolfram_engine() [1/2]

Wolfram_1D_Engine Aleph::CA::make_wolfram_engine ( std::uint8_t  rule_no,
ca_size_t  width 
)
inline

Build a 1D elementary Wolfram engine of the given width.

The lattice starts at zero everywhere. Stamp the impulse(s) before invoking step() through the second overload, or by building the initial lattice yourself and using the Synchronous_Engine constructor directly.

Parameters
[in]rule_noWolfram elementary rule number, [0, 255].
[in]widthnumber of cells along the single axis.
Returns
a synchronous elementary Wolfram engine with open borders.
Complexity
O(width) for lattice allocation and initialisation.

Definition at line 124 of file ca-engine-utils.H.

References Aleph::blossom_maximum_cardinality_matching(), and make_wolfram_elementary_rule().

Referenced by main(), and TEST().

◆ make_wolfram_engine() [2/2]

Wolfram_1D_Engine Aleph::CA::make_wolfram_engine ( std::uint8_t  rule_no,
Lattice< Dense_Cell_Storage< int, 1 >, OpenBoundary >  initial 
)
inline

Build a 1D elementary Wolfram engine from an initial row.

Parameters
[in]rule_noWolfram elementary rule number, [0, 255].
[in]initiallattice that becomes the current frame.
Returns
a synchronous elementary Wolfram engine with open borders.
Complexity
O(initial.size()) for the next-buffer allocation.

Definition at line 140 of file ca-engine-utils.H.

References Aleph::blossom_maximum_cardinality_matching(), and make_wolfram_elementary_rule().

◆ mean_3x3_kernel()

template<typename T = double>
constexpr Kernel2D< T, 3, 3 > Aleph::CA::mean_3x3_kernel ( )
constexprnoexcept

Return a 3x3 mean filter.

Template Parameters
Tnumeric weight type.
Returns
kernel whose weights all equal 1/9.
Exceptions
Thisfunction does not throw.

Definition at line 357 of file ca-kernels.H.

References Aleph::blossom_maximum_cardinality_matching(), and w.

◆ mean_5x5_kernel()

template<typename T = double>
constexpr Kernel2D< T, 5, 5 > Aleph::CA::mean_5x5_kernel ( )
constexprnoexcept

Return a 5x5 mean filter.

Template Parameters
Tnumeric weight type.
Returns
kernel whose weights all equal 1/25.
Exceptions
Thisfunction does not throw.

Definition at line 370 of file ca-kernels.H.

References Aleph::blossom_maximum_cardinality_matching(), and w.

◆ mix_seed()

constexpr std::uint64_t Aleph::CA::mix_seed ( const std::uint64_t  a,
const std::uint64_t  b 
)
inlineconstexprnoexcept

Combine two 64-bit values into a single deterministic hash.

Parameters
[in]afirst input.
[in]bsecond input.
Returns
a value that is sensitive to both inputs.
Exceptions
Thisfunction does not throw.

Definition at line 97 of file ca-rng.H.

References splitmix64().

Referenced by Aleph::CA::Random_Asynchronous_Update< Engine_Type >::apply().

◆ morton_encode_2d()

constexpr std::uint64_t Aleph::CA::morton_encode_2d ( const std::uint32_t  x,
const std::uint32_t  y 
)
inlineconstexprnoexcept

Morton (Z-order) encoding of (x, y).

Interleaves the bits of x and y. Useful as a sort key for visiting 2D cells in a cache-friendly order (cells close in Euclidean distance map to close indices). Phase-5 leaves the engine using row partitioning by default; this helper is exposed as a building block for higher-dimensional schedulers.

Parameters
[in]xfirst coordinate (axis 0).
[in]ysecond coordinate (axis 1).
Returns
interleaved 64-bit Morton code.

Definition at line 375 of file ca-tiling.H.

References Aleph::CA::ca_tiling_detail::spread_bits_2(), and y.

Referenced by TEST().

◆ morton_encode_3d()

constexpr std::uint64_t Aleph::CA::morton_encode_3d ( const std::uint32_t  x,
const std::uint32_t  y,
const std::uint32_t  z 
)
inlineconstexprnoexcept

Morton (Z-order) encoding of (x, y, z).

Same idea as morton_encode_2d but interleaving three streams of bits, suitable for 3D CAs. Inputs are clamped to 21 bits each so the result fits in std::uint64_t.

Parameters
[in]xfirst coordinate.
[in]ysecond coordinate.
[in]zthird coordinate.
Returns
interleaved 64-bit Morton code.

Definition at line 392 of file ca-tiling.H.

References Aleph::CA::ca_tiling_detail::spread_bits_3(), and y.

◆ offset_to_axial_even_r()

constexpr Hex_Axial Aleph::CA::offset_to_axial_even_r ( Hex_Offset  o)
inlineconstexprnoexcept

◆ offset_to_axial_odd_r()

constexpr Hex_Axial Aleph::CA::offset_to_axial_odd_r ( Hex_Offset  o)
inlineconstexprnoexcept

Offset (odd-r) -> axial.

Definition at line 173 of file tpl_ca_hex_lattice.H.

References Aleph::blossom_maximum_cardinality_matching().

Referenced by TEST().

◆ parse_rule()

std::optional< Outer_Totalistic_Binary_Rule > Aleph::CA::parse_rule ( const std::string &  s)
inline

Parse a B.../S... (or Wolfram S/B) rule string.

Accepts mixed case and tolerates surrounding whitespace.

Parameters
srule string (e.g. "B3/S23" or "23/3").
Returns
the parsed rule, or std::nullopt on syntactic error.

Definition at line 168 of file tpl_ca_hashlife.H.

References Aleph::and, and Aleph::blossom_maximum_cardinality_matching().

Referenced by Aleph::CA::Hashlife_Engine::parse_rule_field(), and TEST().

◆ Png_Frame_Sink()

template<typename Mapper >
Aleph::CA::Png_Frame_Sink ( std::filesystem::path  ,
Mapper  ,
std::size_t  = 6 
) -> Png_Frame_Sink< Mapper >

◆ read_csv_snapshot()

template<typename T >
Grid_Snapshot< T > Aleph::CA::read_csv_snapshot ( std::istream &  in,
const CSV_Options &  opts = {} 
)
inline

Read a numeric CSV snapshot.

The reader supports rectangular, delimiter-separated numeric matrices. Quoting is intentionally not implemented because CA snapshots are plain numeric grids.

Template Parameters
Ttarget scalar type.
Parameters
[in,out]ininput stream.
[in]optsCSV options.
Returns
row-major snapshot.
Exceptions
std::domain_errorif rows have inconsistent widths or a scalar cannot be parsed.
Complexity
O(input cells).

Definition at line 1242 of file ca-io.H.

References read_csv_snapshot().

Referenced by read_csv_snapshot().

◆ read_json_snapshot()

template<typename T >
Grid_Snapshot< T > Aleph::CA::read_json_snapshot ( std::istream &  in)
inline

Read a JSON numeric snapshot produced by write_json.

This intentionally small parser handles the deterministic schema emitted by this header. It supports integer and floating-point numeric cell values, but not arbitrary user JSON.

Template Parameters
Ttarget scalar type.
Parameters
[in,out]ininput stream.
Returns
row-major snapshot.
Exceptions
std::domain_erroron malformed JSON or shape mismatch.
Complexity
O(input characters + cells).

Definition at line 1370 of file ca-io.H.

References ah_domain_error_if, Aleph::and, Aleph::blossom_maximum_cardinality_matching(), cols, Aleph::CA::Grid_Snapshot< T >::height, read_json_snapshot(), and rows.

Referenced by read_json_snapshot().

◆ read_life_105()

Binary_Cell_Pattern Aleph::CA::read_life_105 ( std::istream &  in)
inline

Read a Life 1.05 pattern.

Supports the common #P x y block dialect with * or O live cells and . dead cells. Multiple blocks are merged and then normalised.

Parameters
[in,out]ininput stream.
Returns
parsed binary pattern.
Exceptions
std::domain_erroron malformed input.
Complexity
O(input characters + live cells).

Definition at line 1106 of file ca-io.H.

References ah_domain_error_if, ah_domain_error_unless, Aleph::and, Aleph::Array< T >::append(), Aleph::blossom_maximum_cardinality_matching(), col, Aleph::CA::Binary_Cell_Pattern::comments, read_life_105(), and row.

Referenced by LLVMFuzzerTestOneInput(), read_life_105(), TEST(), TEST(), TEST(), and try_read_life_105().

◆ read_life_106()

Binary_Cell_Pattern Aleph::CA::read_life_106 ( std::istream &  in)
inline

Read a Life 1.06 pattern.

Coordinates may be negative; the returned pattern is normalised while preserving the original minimum coordinate in origin_row/col.

Parameters
[in,out]ininput stream.
Returns
parsed binary pattern.
Exceptions
std::domain_erroron malformed input.
Complexity
O(live cells).

Definition at line 1007 of file ca-io.H.

References ah_domain_error_if, ah_domain_error_unless, Aleph::and, Aleph::Array< T >::append(), Aleph::blossom_maximum_cardinality_matching(), col, Aleph::CA::Binary_Cell_Pattern::comments, read_life_106(), and row.

Referenced by LLVMFuzzerTestOneInput(), read_life_106(), TEST(), TEST(), TEST(), and try_read_life_106().

◆ read_plaintext()

Binary_Cell_Pattern Aleph::CA::read_plaintext ( std::istream &  in)
inline

Read a Life plaintext (.cells) pattern.

Lines beginning with ! are comments. O, o and * are live; . is dead. Whitespace inside rows is ignored.

Parameters
[in,out]ininput stream.
Returns
parsed binary pattern.
Exceptions
std::domain_erroron invalid row characters.
Complexity
O(input characters + live cells).

Definition at line 919 of file ca-io.H.

References ah_domain_error_unless, Aleph::CA::Binary_Cell_Pattern::alive, Aleph::Array< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Binary_Cell_Pattern::comments, Aleph::CA::Binary_Cell_Pattern::height, r, read_plaintext(), row, rows, and Aleph::CA::Binary_Cell_Pattern::width.

Referenced by read_plaintext(), read_plaintext_string(), TEST(), and try_read_plaintext().

◆ read_plaintext_string()

Binary_Cell_Pattern Aleph::CA::read_plaintext_string ( const std::string &  s)
inline

Read a Life plaintext pattern from a string.

Parameters
[in]splaintext document.
Returns
parsed pattern.

Definition at line 961 of file ca-io.H.

References Aleph::blossom_maximum_cardinality_matching(), read_plaintext(), and read_plaintext_string().

Referenced by read_plaintext_string(), TEST(), and TEST().

◆ read_rle()

RLE_Pattern Aleph::CA::read_rle ( std::istream &  in)
inline

Read a Conway RLE pattern.

Accepts comments, mixed whitespace, b/. dead cells and o/A live cells. Dimensions come from the required x = ..., y = ... header.

Parameters
[in,out]ininput stream.
Returns
parsed binary pattern.
Exceptions
std::domain_erroron malformed RLE.
Complexity
O(number of RLE tokens + live cells).

Definition at line 691 of file ca-io.H.

References ah_domain_error_if, ah_domain_error_unless, ah_overflow_error_if, Aleph::CA::Binary_Cell_Pattern::alive, Aleph::and, Aleph::Array< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Binary_Cell_Pattern::comments, Aleph::CA::Binary_Cell_Pattern::height, k, Aleph::CA::Binary_Cell_Pattern::name, read_rle(), Aleph::CA::Binary_Cell_Pattern::rule, Aleph::CA::Binary_Cell_Pattern::width, and y.

Referenced by read_rle(), read_rle_string(), and try_read_rle().

◆ read_rle_string()

RLE_Pattern Aleph::CA::read_rle_string ( const std::string &  s)
inline

Read a Conway RLE pattern from a string.

Parameters
[in]sRLE document.
Returns
parsed pattern.

Definition at line 785 of file ca-io.H.

References Aleph::blossom_maximum_cardinality_matching(), read_rle(), and read_rle_string().

Referenced by LLVMFuzzerTestOneInput(), read_rle_string(), TEST(), TEST(), TEST(), TEST(), TEST(), and try_read_rle_string().

◆ render_ascii() [1/2]

template<typename Lattice >
void Aleph::CA::render_ascii ( std::ostream &  out,
const Lattice &  frame,
const Ascii_Render_Options &  opts = {} 
)
inline

Render using the default binary ASCII palette.

Template Parameters
Lattice2D lattice type.
Parameters
[in,out]outoutput stream.
[in]frameframe to render.
[in]optsrendering options.

Definition at line 257 of file ca-ascii.H.

◆ render_ascii() [2/2]

template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
void Aleph::CA::render_ascii ( std::ostream &  out,
const Lattice &  frame,
Palette &&  palette,
const Ascii_Render_Options &  opts = {} 
)
inline

Render a rank-2 frame as text.

palette(cell) must return a string glyph. Coordinates are emitted in row-major order.

Template Parameters
Lattice2D lattice type.
Paletteinvocable state_type -> std::string.
Parameters
[in,out]outoutput stream.
[in]frameframe to render.
[in]palettestate-to-text mapper.
[in]optsrendering options.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).

Definition at line 168 of file ca-ascii.H.

Referenced by Aleph::CA::Ascii_Frame_Sink< Palette >::accept(), and main().

◆ render_ascii_string() [1/2]

template<typename Lattice >
std::string Aleph::CA::render_ascii_string ( const Lattice &  frame,
const Ascii_Render_Options &  opts = {} 
)
inline

Return a default binary ASCII rendering.

Template Parameters
Lattice2D lattice type.
Parameters
[in]frameframe to render.
[in]optsrendering options.
Returns
rendered text.

Definition at line 270 of file ca-ascii.H.

◆ render_ascii_string() [2/2]

template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
std::string Aleph::CA::render_ascii_string ( const Lattice &  frame,
Palette &&  palette,
const Ascii_Render_Options &  opts = {} 
)
inline

Return the text rendering of a rank-2 frame.

Template Parameters
Lattice2D lattice type.
Paletteinvocable state_type -> std::string.
Parameters
[in]frameframe to render.
[in]palettestate-to-text mapper.
[in]optsrendering options.
Returns
rendered text.

Definition at line 237 of file ca-ascii.H.

Referenced by TEST().

◆ render_graph_lattice_dot()

template<typename Graph , typename Palette >
requires requires(const Graph &g, std::size_t n, Palette &&p, const typename Graph::state_type &v) { g.size(); g.neighbours(n); g.at_node(n); { p(v) } -> std::convertible_to<std::string>; }
void Aleph::CA::render_graph_lattice_dot ( std::ostream &  out,
const Graph &  graph,
Palette &&  palette,
const DOT_Render_Options &  opts = {} 
)
inline

Render a graph CA frame as GraphViz DOT.

Template Parameters
Graphgraph lattice type.
Paletteinvocable state_type -> std::string.
Parameters
[in,out]outoutput stream.
[in]graphgraph lattice frame.
[in]palettestate-to-fill-colour mapper.
[in]optsrendering options.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(nodes + edges).

Definition at line 146 of file ca-dot.H.

Referenced by Aleph::CA::Dot_Frame_Sink< Palette >::accept(), and main().

◆ render_graph_lattice_dot_string()

std::string Aleph::CA::render_graph_lattice_dot_string ( const Graph &  graph,
Palette &&  palette,
const DOT_Render_Options &  opts = {} 
)
inline

Return a graph frame rendered as DOT.

Template Parameters
Graphgraph lattice type.
Paletteinvocable state_type -> std::string.
Parameters
[in]graphgraph lattice frame.
[in]palettestate-to-fill-colour mapper.
[in]optsrendering options.
Returns
DOT document.
Exceptions
Anyexception propagated by the underlying render_graph_lattice_dot call (e.g. std::runtime_error on stringstream write failure, or exceptions thrown by the palette).
Complexity
O(nodes + edges).

Definition at line 207 of file ca-dot.H.

Referenced by TEST().

◆ render_hex_lattice_tikz() [1/2]

std::string Aleph::CA::render_hex_lattice_tikz ( const Lattice &  lat,
Palette &&  palette,
double  radius = 0.5,
bool  pointy_top = true 
)
inline

Returns a std::string instead of writing to a stream.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 357 of file tpl_ca_hex_lattice.H.

References Aleph::blossom_maximum_cardinality_matching(), and render_hex_lattice_tikz().

◆ render_hex_lattice_tikz() [2/2]

void Aleph::CA::render_hex_lattice_tikz ( std::ostream &  os,
const Lattice &  lat,
Palette &&  palette,
double  radius = 0.5,
bool  pointy_top = true 
)
inline

Render a hex frame as a stand-alone TikZ picture.

Produces a TikZ tikzpicture body with one filled hexagon per cell, coloured according to a user-supplied palette functor that maps a state_type to a TikZ colour (LaTeX colour name).

The output is appended to os. The caller is responsible for wrapping the LaTeX preamble (\documentclass, \usepackage{tikz}) if a stand-alone document is desired.

Template Parameters
Latticehex lattice type.
Paletteinvocable state_type -> std::string palette.
Parameters
[in,out]osstream to write to.
[in]lathex lattice.
[in]palettecolour mapping.
[in]radiushex circumradius (default 0.5cm).
[in]pointy_topuse pointy-top orientation (default true).

Definition at line 330 of file tpl_ca_hex_lattice.H.

References axial_to_pixel_flat(), axial_to_pixel_pointy(), Aleph::blossom_maximum_cardinality_matching(), and r.

Referenced by main(), render_hex_lattice_tikz(), and TEST().

◆ render_lattice_svg() [1/2]

template<typename Lattice >
void Aleph::CA::render_lattice_svg ( std::ostream &  out,
const Lattice &  frame,
const SVG_Render_Options &  opts = {},
const typename Lattice::state_type &  dead_state = typename Lattice::state_type{} 
)
inline

Render a frame as SVG using the default binary RGB mapper.

Template Parameters
Latticelattice type.
Parameters
[in,out]outoutput stream.
[in]frameframe to render.
[in]optsrendering options.
[in]dead_statestate skipped when opts.omit_dead_cells is true.
Exceptions
Anyexception propagated by render_lattice_svg.

Definition at line 322 of file ca-svg.H.

◆ render_lattice_svg() [2/2]

template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<RGB8>; }
void Aleph::CA::render_lattice_svg ( std::ostream &  out,
const Lattice &  frame,
Palette &&  palette,
const SVG_Render_Options &  opts = {},
const typename Lattice::state_type &  dead_state = typename Lattice::state_type{} 
)
inline

Render a supported rank-2 CA frame as SVG.

Rectangular frames produce <rect> cells. Hex_Lattice and Triangular_Lattice frames produce exact <polygon> cells.

Template Parameters
Latticelattice type.
Paletteinvocable state_type -> RGB8.
Parameters
[in,out]outoutput stream.
[in]frameframe to render.
[in]palettestate-to-colour mapper.
[in]optsrendering options.
[in]dead_statestate skipped when omit_dead_cells is true.
Exceptions
std::domain_errorif cell_size <= 0.
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).

Definition at line 205 of file ca-svg.H.

Referenced by Aleph::CA::Svg_Frame_Sink< Palette >::accept(), and main().

◆ render_lattice_svg_string()

template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<RGB8>; }
std::string Aleph::CA::render_lattice_svg_string ( const Lattice &  frame,
Palette &&  palette,
const SVG_Render_Options &  opts = {},
const typename Lattice::state_type &  dead_state = typename Lattice::state_type{} 
)
inline

Return a frame rendered as SVG.

Template Parameters
Latticelattice type.
Paletteinvocable state_type -> RGB8.
Parameters
[in]frameframe to render.
[in]palettestate-to-colour mapper.
[in]optsrendering options.
[in]dead_statestate skipped when opts.omit_dead_cells is true.
Returns
SVG document.
Exceptions
Anyexception propagated by render_lattice_svg.

Definition at line 344 of file ca-svg.H.

Referenced by TEST().

◆ render_lattice_tikz() [1/4]

template<typename Lattice >
std::string Aleph::CA::render_lattice_tikz ( const Lattice &  frame,
const Rect_Tikz_Options &  opts = {} 
)
inline

Return a TikZ picture using the default binary palette.

Template Parameters
Latticelattice type.
Parameters
[in]framelattice frame.
[in]optsrectangular options used for rectangular frames.
Returns
TikZ picture.

Definition at line 289 of file ca-tikz.H.

◆ render_lattice_tikz() [2/4]

template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
std::string Aleph::CA::render_lattice_tikz ( const Lattice &  frame,
Palette &&  palette,
const Rect_Tikz_Options &  opts = {} 
)
inline

Return any supported 2D CA lattice rendered as TikZ.

Template Parameters
Latticelattice type.
Paletteinvocable state_type -> std::string.
Parameters
[in]framelattice frame.
[in]palettestate-to-colour mapper.
[in]optsrectangular options used for rectangular frames.
Returns
TikZ picture.

Definition at line 251 of file ca-tikz.H.

◆ render_lattice_tikz() [3/4]

template<typename Lattice >
void Aleph::CA::render_lattice_tikz ( std::ostream &  out,
const Lattice &  frame,
const Rect_Tikz_Options &  opts = {} 
)
inline

Render with the default binary palette.

Template Parameters
Latticelattice type.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]optsrectangular options used for rectangular frames.
Complexity
O(rows * cols).

Definition at line 274 of file ca-tikz.H.

◆ render_lattice_tikz() [4/4]

template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
void Aleph::CA::render_lattice_tikz ( std::ostream &  out,
const Lattice &  frame,
Palette &&  palette,
const Rect_Tikz_Options &  opts = {} 
)
inline

Render any supported 2D CA lattice as TikZ.

Hexagonal and triangular lattice wrappers reuse their specialised renderers. All other rank-2 lattices use the rectangular renderer.

Template Parameters
Latticelattice type.
Paletteinvocable state_type -> std::string.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]palettestate-to-colour mapper.
[in]optsrectangular options used for rectangular frames.
Complexity
O(rows * cols).

Definition at line 225 of file ca-tikz.H.

Referenced by TEST(), and Aleph::CA::Directory_Frame_Sink::write_one().

◆ render_rect_lattice_tikz() [1/2]

template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
std::string Aleph::CA::render_rect_lattice_tikz ( const Lattice &  frame,
Palette &&  palette,
const Rect_Tikz_Options &  opts = {} 
)
inline

Return a rectangular frame rendered as TikZ.

Template Parameters
Lattice2D lattice type.
Paletteinvocable state_type -> std::string.
Parameters
[in]framelattice frame.
[in]palettestate-to-colour mapper.
[in]optsrendering options.
Returns
TikZ picture.

Definition at line 197 of file ca-tikz.H.

◆ render_rect_lattice_tikz() [2/2]

template<typename Lattice , typename Palette >
requires requires(Palette &&p, const typename Lattice::state_type &v) { { p(v) } -> std::convertible_to<std::string>; }
void Aleph::CA::render_rect_lattice_tikz ( std::ostream &  out,
const Lattice &  frame,
Palette &&  palette,
const Rect_Tikz_Options &  opts = {} 
)
inline

Render a rectangular 2D frame as a TikZ picture.

palette(cell) must return a TikZ colour expression. Coordinates are rendered with row 0 at the top (y=-1cm in the picture options).

Template Parameters
Lattice2D lattice type.
Paletteinvocable state_type -> std::string.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]palettestate-to-colour mapper.
[in]optsrendering options.
Exceptions
std::domain_errorif cell_size <= 0.
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).
Thread-safety
Reentrant, except for concurrent writes to the same stream.

Definition at line 139 of file ca-tikz.H.

Referenced by TEST(), and TEST().

◆ render_triangular_lattice_tikz() [1/2]

std::string Aleph::CA::render_triangular_lattice_tikz ( const Lattice &  lat,
Palette &&  palette,
double  side = 1.0 
)
inline

Returns a std::string instead of writing to a stream.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 227 of file tpl_ca_triangular_lattice.H.

References Aleph::blossom_maximum_cardinality_matching(), and render_triangular_lattice_tikz().

◆ render_triangular_lattice_tikz() [2/2]

void Aleph::CA::render_triangular_lattice_tikz ( std::ostream &  os,
const Lattice &  lat,
Palette &&  palette,
const double  side = 1.0 
)
inline

Render a triangular frame as a TikZ picture.

Each triangle is drawn as a rotated equilateral polygon with side side, coloured by the user-supplied palette functor. The orientation is set automatically from the cell parity.

Template Parameters
Latticetriangular lattice type.
Palettestate_type -> std::string colour mapping.
Parameters
[in,out]osstream to write to.
[in]latlattice to render.
[in]palettecolour mapping.
[in]sidetriangle side length (default 1).

Definition at line 202 of file tpl_ca_triangular_lattice.H.

References Aleph::blossom_maximum_cardinality_matching(), tri_is_up(), and tri_pixel_centre().

Referenced by main(), render_triangular_lattice_tikz(), and TEST().

◆ save_checkpoint()

template<typename Engine >
requires Checkpointable_Engine<Engine>
void Aleph::CA::save_checkpoint ( Engine &  engine,
const std::filesystem::path &  path,
const Checkpoint_Options &  options = {} 
)

Write a complete engine snapshot to disk atomically.

The frame is serialised cell-by-cell in row-major order, then optionally DEFLATE-compressed (when options.compress). The file is first emitted to <path>.tmp.<pid>.<rand>, fsync'd and finally renamed onto path. A crash before the rename leaves any previous path intact.

Two checkpoints of the same engine state always produce identical bytes when the same options are used, so the format remains reproducible across runs.

Template Parameters
Engineengine type satisfying Checkpointable_Engine.
Parameters
[in]engineengine whose state is captured.
[in]pathdestination file path. Parent directories must already exist (the function does not mkdir -p).
[in]optionsoptional knobs (compression, dir-fsync). Defaults preserve Phase-15 raw output but keep sync_dir = true for crash safety.
Exceptions
std::runtime_erroron file open, stream write, fsync or rename failure.
Note
Requires Lattice::rank <= 3. Higher ranks fail at compile time via static_assert.
Complexity
O(N) where N is the cell count.

Definition at line 955 of file ca-checkpoint.H.

References save_checkpoint().

Referenced by Aleph::CA::Periodic_Checkpoint_Observer< Engine >::on_step_end(), save_checkpoint(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ save_delta_checkpoint()

template<typename Engine >
requires Checkpointable_Engine<Engine>
void Aleph::CA::save_delta_checkpoint ( Engine &  engine,
const std::vector< std::uint8_t > &  baseline,
const std::uint64_t  base_step,
const std::filesystem::path &  path,
const Checkpoint_Options &  options = {} 
)

Write a delta checkpoint relative to a previous payload.

Compares the current engine frame against the raw byte payload of the baseline snapshot and persists only the cells whose byte representation differs. The file references the baseline via its step number (base_step) so consumers know which file to load first.

Delta payload layout (uncompressed view, repeats n times):

[ uint64 linear_index ][ state_type_size bytes new_value ]
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466

When options.compress is set, the entire delta block is DEFLATE-compressed in one go (same as a full snapshot).

Template Parameters
Engineengine type satisfying Checkpointable_Engine.
Parameters
[in]engineengine whose state will be diffed.
[in]baselineraw byte payload of the previous snapshot (typically captured at the time the baseline was written). The size must equal cell_count * sizeof(state).
[in]base_stepstep number of the baseline checkpoint.
[in]pathdestination file path.
[in]optionsoptional knobs (compression, dir-fsync).
Exceptions
std::runtime_erroron size mismatch or write failure.
Complexity
O(N) cell scan; output is proportional to the number of changes.

Definition at line 1082 of file ca-checkpoint.H.

References save_delta_checkpoint().

Referenced by save_delta_checkpoint(), and TEST().

◆ shannon_entropy()

template<typename Lattice >
double Aleph::CA::shannon_entropy ( const Lattice &  lat,
std::size_t  max_state 
)
inline

Shannon entropy in nats of the [0, max_state) distribution.

Returns 0 when the lattice is empty or every cell holds the same state. Uses natural logarithms; multiply by 1 / log(2) to obtain bits.

Parameters
[in]latlattice to evaluate.
[in]max_stateexclusive upper bound on state values.
Returns
Shannon entropy H = -Σ p_i ln(p_i).

Definition at line 276 of file ca-metrics.H.

References Aleph::blossom_maximum_cardinality_matching(), h, shannon_entropy(), and state_histogram().

Referenced by Aleph::CA::Entropy_Observer< MaxState >::on_step_begin(), Aleph::CA::Entropy_Observer< MaxState >::on_step_end(), shannon_entropy(), TEST(), and TEST().

◆ should_run_sequential()

constexpr bool Aleph::CA::should_run_sequential ( const ca_size_t  cells,
const ca_size_t  num_partitions,
const ca_size_t  min_cells 
)
inlineconstexprnoexcept

Decide whether a workload should run sequentially.

Returns true when the workload is small enough that the cost of scheduling work onto a thread pool would dominate the actual cell updates. The heuristic is intentionally tunable from the call site rather than baked in: small grids on a deep pool benefit from this cutoff, and larger grids should always parallelise.

Parameters
[in]cellstotal cell count to update.
[in]num_partitionsnumber of partitions that would be spawned.
[in]min_cellsminimum work per partition before parallelisation pays off.
Returns
true when the workload should be executed sequentially.

Definition at line 163 of file ca-tiling.H.

References Aleph::blossom_maximum_cardinality_matching().

Referenced by Aleph::CA::Parallel_Synchronous_Engine< Lattice, Rule, Neighborhood, Order >::effective_partitions(), and TEST().

◆ sobel_x_kernel()

template<typename T = double>
constexpr Kernel2D< T, 3, 3 > Aleph::CA::sobel_x_kernel ( )
constexprnoexcept

Return the horizontal Sobel gradient kernel.

Template Parameters
Tnumeric weight type.
Returns
Kernel2D<T, 3, 3> detecting changes along the column axis.
Exceptions
Thisfunction does not throw.

Definition at line 384 of file ca-kernels.H.

References Aleph::blossom_maximum_cardinality_matching().

◆ sobel_y_kernel()

template<typename T = double>
constexpr Kernel2D< T, 3, 3 > Aleph::CA::sobel_y_kernel ( )
constexprnoexcept

Return the vertical Sobel gradient kernel.

Template Parameters
Tnumeric weight type.
Returns
Kernel2D<T, 3, 3> detecting changes along the row axis.
Exceptions
Thisfunction does not throw.

Definition at line 396 of file ca-kernels.H.

References Aleph::blossom_maximum_cardinality_matching().

◆ split_range_balanced()

constexpr Range1D Aleph::CA::split_range_balanced ( const ca_size_t  n,
const ca_size_t  parts,
const ca_size_t  idx 
)
inlineconstexprnoexcept

Balanced split of [0, n) into parts contiguous ranges.

The first n % parts ranges receive one extra index, so that the size disparity between any two ranges never exceeds 1. This is the classic "block-cyclic" balance used by OpenMP static. The function is total: passing parts == 0 yields the single full range and passing idx >= parts yields an empty range. This mirrors the default behaviour of std::partition_point-style helpers and is the cleanest way to handle pool-size-dependent loops at compile time.

Parameters
[in]ntotal number of indices to split.
[in]partsdesired number of partitions (0 is treated as 1).
[in]idxpartition index in [0, parts).
Returns
the half-open range owned by idx.
Complexity
O(1).

Definition at line 127 of file ca-tiling.H.

References Aleph::blossom_maximum_cardinality_matching().

Referenced by Aleph::CA::Row_Partition< Rank >::slab(), Aleph::CA::Column_Partition< Rank >::slab(), TEST(), TEST(), TEST(), and Aleph::CA::Block_Partition_2D::tile().

◆ splitmix64()

constexpr std::uint64_t Aleph::CA::splitmix64 ( std::uint64_t  x)
inlineconstexprnoexcept

64-bit SplitMix hash.

Stateless mixing function used as the building block for every deterministic seed derivation in the CA module. Identical to the reference SplitMix64 step of Vigna's xoroshiro family.

Parameters
[in]xinput value.
Returns
well-distributed 64-bit hash of x.
Exceptions
Thisfunction does not throw.

Definition at line 82 of file ca-rng.H.

Referenced by cell_key_from_coord(), cell_seed(), Aleph::CA::ca_scheme_detail::coord_from_hash(), mix_seed(), TEST(), thread_step_seed(), and Aleph::CA::ca_checkpoint_detail::type_hash().

◆ state_histogram()

template<typename Lattice >
Array< ca_size_t > Aleph::CA::state_histogram ( const Lattice &  lat,
std::size_t  max_state 
)
inline

Count occurrences of every integer state in [0, max_state).

Useful for non-binary CAs that work over a small discrete state set. Cells whose state is outside the range are silently ignored.

Parameters
[in]latlattice to inspect.
[in]max_stateexclusive upper bound on the state values.
Returns
array of size max_state with the count for each state.

Definition at line 241 of file ca-metrics.H.

References Aleph::and, Aleph::blossom_maximum_cardinality_matching(), for_each_cell(), S, and state_histogram().

Referenced by shannon_entropy(), state_histogram(), and TEST().

◆ Svg_Frame_Sink()

template<typename Palette >
Aleph::CA::Svg_Frame_Sink ( std::filesystem::path  ,
Palette  ,
SVG_Render_Options  = {},
std::size_t  = 6 
) -> Svg_Frame_Sink< Palette >

◆ swap() [1/6]

template<std::size_t N>
void Aleph::CA::swap ( Bit_Cell_Storage< N > &  a,
Bit_Cell_Storage< N > &  b 
)
inlinenoexcept

Free-function swap so the storage plays nicely with std::swap.

Parameters
[in,out]afirst storage.
[in,out]bsecond storage.
Template Parameters
Nnumber of axes.

Definition at line 291 of file tpl_ca_bit_storage.H.

◆ swap() [2/6]

template<typename T , std::size_t N>
void Aleph::CA::swap ( Dense_Cell_Storage< T, N > &  a,
Dense_Cell_Storage< T, N > &  b 
)
inlinenoexcept

Free-function swap so the storage plays nicely with std::swap.

Definition at line 333 of file tpl_ca_storage.H.

◆ swap() [3/6]

template<typename Storage , typename Boundary , std::size_t Halo>
void Aleph::CA::swap ( Ghost_Lattice< Storage, Boundary, Halo > &  a,
Ghost_Lattice< Storage, Boundary, Halo > &  b 
)
inlinenoexcept

Free-function swap so Ghost_Lattice works with std::swap.

Parameters
[in,out]afirst lattice.
[in,out]bsecond lattice.
Template Parameters
Storagebacking storage type.
Boundaryboundary tag.
Halohalo thickness.

Definition at line 562 of file tpl_ca_ghost_lattice.H.

◆ swap() [4/6]

template<typename T >
void Aleph::CA::swap ( Graph_Lattice< T > &  a,
Graph_Lattice< T > &  b 
)
inlinenoexcept

Free-function swap so the lattice plays nicely with std::swap.

Definition at line 269 of file tpl_ca_graph_automaton.H.

◆ swap() [5/6]

template<typename Storage , typename Boundary >
void Aleph::CA::swap ( Lattice< Storage, Boundary > &  a,
Lattice< Storage, Boundary > &  b 
)
inlinenoexcept

Free-function swap so the lattice plays nicely with std::swap.

Parameters
[in,out]afirst lattice.
[in,out]bsecond lattice.
Template Parameters
Storagestorage type.
Boundaryboundary tag type.

Definition at line 309 of file tpl_ca_lattice.H.

◆ swap() [6/6]

template<typename Layout , typename Boundary , std::size_t Rank, typename... Fields>
void Aleph::CA::swap ( Multi_Field_Lattice< Layout, Boundary, Rank, Fields... > &  a,
Multi_Field_Lattice< Layout, Boundary, Rank, Fields... > &  b 
)
inlinenoexcept

Free-function swap so the lattice plays nicely with std::swap.

Definition at line 433 of file tpl_ca_multi_field_lattice.H.

◆ thread_step_seed()

constexpr std::uint64_t Aleph::CA::thread_step_seed ( const std::uint64_t  master_seed,
const std::size_t  thread_id,
const std::size_t  step 
)
inlineconstexprnoexcept

Build a deterministic seed from (master, thread_id, step).

Useful for the alternative "per-thread substream" strategy in which the rule reuses the same engine for every cell visited by a single worker. This trades determinism across thread counts for raw speed; the per-cell strategy provided by cell_seed() should be preferred whenever cross-scheduling reproducibility is required.

Parameters
[in]master_seeduser-controlled root seed.
[in]thread_idstable identifier for the worker.
[in]stepstep index being evaluated.
Returns
per-thread sub-stream seed.
Exceptions
Thisfunction does not throw.

Definition at line 180 of file ca-rng.H.

References Aleph::blossom_maximum_cardinality_matching(), and splitmix64().

Referenced by Aleph::CA::Per_Thread_RNG< Engine >::for_thread_step().

◆ total_cells()

template<typename Lattice >
ca_size_t Aleph::CA::total_cells ( const Lattice &  lat)
inlinenoexcept
Returns
total cell count of the lattice (works for rectangular and graph lattices alike).

Definition at line 204 of file ca-metrics.H.

References Aleph::blossom_maximum_cardinality_matching(), and total_cells().

Referenced by alive_density(), density(), Aleph::CA::Density_Observer< State >::on_step_begin(), Aleph::CA::Density_Observer< State >::on_step_end(), and total_cells().

◆ tri_is_down()

constexpr bool Aleph::CA::tri_is_down ( const Tri_Coord &  c)
inlineconstexprnoexcept
Returns
true if c is a down triangle.

Definition at line 110 of file tpl_ca_triangular_lattice.H.

References tri_parity().

Referenced by TEST().

◆ tri_is_up()

constexpr bool Aleph::CA::tri_is_up ( const Tri_Coord &  c)
inlineconstexprnoexcept
Returns
true if c is an up triangle.

Definition at line 104 of file tpl_ca_triangular_lattice.H.

References tri_parity().

Referenced by render_triangular_lattice_tikz(), TEST(), tri_pixel_centre(), and Aleph::CA::ca_svg_detail::tri_points().

◆ tri_parity()

constexpr int Aleph::CA::tri_parity ( const Tri_Coord &  c)
inlineconstexprnoexcept
Returns
parity (0 = up triangle, 1 = down triangle).

Definition at line 97 of file tpl_ca_triangular_lattice.H.

References Aleph::blossom_maximum_cardinality_matching().

Referenced by TEST(), tri_is_down(), and tri_is_up().

◆ tri_pixel_centre()

std::array< double, 2 > Aleph::CA::tri_pixel_centre ( const Tri_Coord &  c,
const double  side 
)
inlinenoexcept

Cartesian centre of a triangle in (i, j) units.

Each row i is offset vertically by i * height, where height = side * sqrt(3) / 2. Columns are spaced horizontally by side / 2. Up and down triangles inside the same row share their y baseline; their centres are vertically displaced by ±height / 6 (the centroid offset of a unit triangle).

Parameters
[in]ctriangle coords.
[in]sidetriangle side length.
Returns
{x, y} Cartesian centroid.

Definition at line 127 of file tpl_ca_triangular_lattice.H.

References Aleph::blossom_maximum_cardinality_matching(), tri_is_up(), and y.

Referenced by render_triangular_lattice_tikz(), TEST(), and Aleph::CA::ca_svg_detail::tri_points().

◆ try_read_csv_snapshot()

template<class T >
expected< Grid_Snapshot< T >, std::string > Aleph::CA::try_read_csv_snapshot ( std::istream &  in,
const CSV_Options &  opts = {} 
)
inline

Non-throwing variant of read_csv_snapshot.

Reads a numeric CSV snapshot from the stream. Returns the parsed snapshot on success or an error message on failure. Unlike read_csv_snapshot, this function never throws.

Template Parameters
Ttarget scalar type.
Parameters
[in,out]ininput stream.
[in]optsCSV parsing options.
Returns
expected<Grid_Snapshot<T>, std::string>: snapshot on success, error message on failure.
Complexity
O(input cells).
Thread-safety
Reentrant.

Definition at line 1793 of file ca-io.H.

References try_read_csv_snapshot().

Referenced by try_read_csv_snapshot().

◆ try_read_life_105()

expected< Binary_Cell_Pattern, std::string > Aleph::CA::try_read_life_105 ( std::istream &  in)
inline

Non-throwing variant of read_life_105.

Reads a Life 1.05 pattern from the stream. Returns the parsed pattern on success or an error message on failure. Unlike read_life_105, this function never throws.

Parameters
[in,out]ininput stream.
Returns
expected<Binary_Cell_Pattern, std::string>: pattern on success, error message on failure.
Complexity
O(input characters + live cells).
Thread-safety
Reentrant.

Definition at line 1746 of file ca-io.H.

References Aleph::blossom_maximum_cardinality_matching(), read_life_105(), and try_read_life_105().

Referenced by TEST(), TEST(), and try_read_life_105().

◆ try_read_life_106()

expected< Binary_Cell_Pattern, std::string > Aleph::CA::try_read_life_106 ( std::istream &  in)
inline

Non-throwing variant of read_life_106.

Reads a Life 1.06 pattern from the stream. Returns the parsed pattern on success or an error message on failure. Unlike read_life_106, this function never throws.

Parameters
[in,out]ininput stream.
Returns
expected<Binary_Cell_Pattern, std::string>: pattern on success, error message on failure.
Complexity
O(live cells).
Thread-safety
Reentrant.

Definition at line 1768 of file ca-io.H.

References Aleph::blossom_maximum_cardinality_matching(), read_life_106(), and try_read_life_106().

Referenced by main(), TEST(), TEST(), and try_read_life_106().

◆ try_read_plaintext()

expected< Binary_Cell_Pattern, std::string > Aleph::CA::try_read_plaintext ( std::istream &  in)
inline

Non-throwing variant of read_plaintext.

Reads a Life plaintext pattern from the stream. Returns the parsed pattern on success or an error message on failure. Unlike read_plaintext, this function never throws.

Parameters
[in,out]ininput stream.
Returns
expected<Binary_Cell_Pattern, std::string>: pattern on success, error message on failure.
Complexity
O(input characters + live cells).
Thread-safety
Reentrant.

Definition at line 1724 of file ca-io.H.

References Aleph::blossom_maximum_cardinality_matching(), read_plaintext(), and try_read_plaintext().

Referenced by TEST(), and try_read_plaintext().

◆ try_read_rle()

expected< RLE_Pattern, std::string > Aleph::CA::try_read_rle ( std::istream &  in)
inline

Non-throwing variant of read_rle.

Reads a Conway RLE pattern from the stream. Returns the parsed pattern on success or an error message on failure. Unlike read_rle, this function never throws.

Parameters
[in,out]ininput stream.
Returns
expected<RLE_Pattern, std::string>: pattern on success, error message on failure.
Complexity
O(number of RLE tokens + live cells).
Thread-safety
Reentrant.

Definition at line 1680 of file ca-io.H.

References Aleph::blossom_maximum_cardinality_matching(), read_rle(), and try_read_rle().

Referenced by main(), TEST(), and try_read_rle().

◆ try_read_rle_string()

expected< RLE_Pattern, std::string > Aleph::CA::try_read_rle_string ( const std::string &  s)
inline

Non-throwing variant of read_rle_string.

Parses a Conway RLE pattern from a string. Returns the parsed pattern on success or an error message on failure. Unlike read_rle_string, this function never throws.

Parameters
[in]sRLE document.
Returns
expected<RLE_Pattern, std::string>: pattern on success, error message on failure.
Complexity
O(number of RLE tokens + live cells).
Thread-safety
Reentrant.

Definition at line 1702 of file ca-io.H.

References read_rle_string(), and try_read_rle_string().

Referenced by TEST(), TEST(), TEST(), and try_read_rle_string().

◆ uniform_int()

template<typename Engine >
std::size_t Aleph::CA::uniform_int ( Engine &  eng,
const std::size_t  lo,
const std::size_t  hi 
)
inline

Sample a uniform integer in [lo, hi] (inclusive).

Provided for portability of the stochastic rules; mirrors the semantics of std::uniform_int_distribution<std::size_t>(lo, hi) but uses our uniform_unit so the bit pattern is reproducible across vendors.

Template Parameters
EngineRNG engine type.
Parameters
[in,out]engRNG engine; advanced by one draw.
[in]lolower bound (inclusive).
[in]hiupper bound (inclusive); must satisfy lo <= hi.
Returns
uniform sample in [lo, hi].
Exceptions
Anyexception thrown by eng().

Definition at line 231 of file ca-rng.H.

References Aleph::blossom_maximum_cardinality_matching(), and uniform_unit().

Referenced by TEST(), and TEST().

◆ uniform_unit()

template<typename Engine >
double Aleph::CA::uniform_unit ( Engine &  eng)
inline

Map a 64-bit RNG output to a uniform value in [0, 1).

Implementation-defined components of std::uniform_real_distribution vary across standard library vendors, so we provide a small portable converter that uses the top 53 bits of eng(). The output is bit-exact across platforms when fed the same engine state.

Template Parameters
EngineRNG engine type whose result_type is at least 53 bits wide.
Parameters
[in,out]engRNG engine; advanced by one draw.
Returns
uniform value in [0, 1).
Exceptions
Anyexception thrown by eng().

Definition at line 206 of file ca-rng.H.

References Aleph::blossom_maximum_cardinality_matching().

Referenced by Aleph::CA::Forest_Fire_Rule< Engine >::operator()(), Aleph::CA::SIR_Rule< Engine >::operator()(), Aleph::CA::Ising_Glauber_Rule< Engine >::operator()(), Aleph::CA::Ising_Metropolis_Rule< Engine >::operator()(), Aleph::CA::Schelling_Rule< Engine >::operator()(), TEST(), and uniform_int().

◆ write_csv()

template<typename Lattice >
void Aleph::CA::write_csv ( std::ostream &  out,
const Lattice &  frame,
const CSV_Options &  opts = {} 
)
inline

Write a numeric CSV snapshot.

Each lattice row becomes one CSV record. Values are emitted with operator<<.

Template Parameters
Lattice2D lattice type.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]optsCSV options.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).

Definition at line 1207 of file ca-io.H.

References write_csv().

Referenced by TEST(), TEST(), write_csv(), and Aleph::CA::Directory_Frame_Sink::write_one().

◆ write_gif()

void Aleph::CA::write_gif ( std::ostream &  out,
const Array< ca_gif_detail::Frame > &  frames,
const GIF_Write_Options &  opts = {} 
)
inline

Write a sequence of RGB frames as an animated GIF.

Parameters
[in,out]outoutput stream.
[in]framesRGB frames, all with identical dimensions.
[in]optsGIF options.
Exceptions
std::domain_errorif no frames are supplied or dimensions differ.
std::runtime_erroron stream write failure.
Complexity
O(frames * width * height).

Definition at line 253 of file ca-gif.H.

Referenced by Aleph::CA::Gif_Frame_Sink< Mapper >::flush().

◆ write_json()

template<typename Lattice >
void Aleph::CA::write_json ( std::ostream &  out,
const Lattice &  frame,
const JSON_Write_Options &  opts = {} 
)
inline

Write a JSON snapshot.

Schema:

{"type":"Aleph::CA::frame","rank":2,"height":H,"width":W,"cells":[...]}
Template Parameters
Lattice2D lattice type.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]optsJSON options.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).

Definition at line 1314 of file ca-io.H.

References write_json().

Referenced by Aleph::CA::JSON_Frame_Stream_Writer::accept(), TEST(), TEST(), write_json(), and Aleph::CA::Directory_Frame_Sink::write_one().

◆ write_life_105()

template<typename Lattice >
void Aleph::CA::write_life_105 ( std::ostream &  out,
const Lattice &  frame,
const std::string &  comment = {},
const typename Lattice::state_type &  dead = typename Lattice::state_type{} 
)
inline

Write a Life 1.05 file.

The writer emits one #P 0 0 block that covers the full frame. Live cells use *; dead cells use ..

Template Parameters
Lattice2D lattice type.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]commentoptional #D comment text.
[in]deadstate considered dead.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).

Definition at line 1072 of file ca-io.H.

References write_life_105().

Referenced by TEST(), and write_life_105().

◆ write_life_106()

template<typename Lattice >
void Aleph::CA::write_life_106 ( std::ostream &  out,
const Lattice &  frame,
const typename Lattice::state_type &  dead = typename Lattice::state_type{} 
)
inline

Write a Life 1.06 file.

Live cells are emitted as col row integer coordinate pairs.

Template Parameters
Lattice2D lattice type.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]deadstate considered dead.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).

Definition at line 981 of file ca-io.H.

References write_life_106().

Referenced by TEST(), and write_life_106().

◆ write_npy()

template<typename Lattice >
void Aleph::CA::write_npy ( std::ostream &  out,
const Lattice &  frame 
)
inline

Write a lattice frame as a NumPy .npy array.

The lattice rank becomes the NumPy array rank and the payload is emitted in row-major order.

Template Parameters
Latticelattice type with an arithmetic state type.
Parameters
[in,out]outoutput stream.
[in]frameframe to write.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(frame.size()).

Definition at line 151 of file ca-npy.H.

References ah_domain_error_if, ah_runtime_error_if, Aleph::blossom_maximum_cardinality_matching(), out, and Aleph::CA::ca_npy_detail::shape_tuple().

Referenced by Aleph::CA::Npy_Frame_Sink::accept(), main(), and TEST().

◆ write_pgm() [1/2]

template<typename Lattice >
void Aleph::CA::write_pgm ( std::ostream &  out,
const Lattice &  frame,
const NetPBM_Write_Options &  opts = {} 
)
inline

Write a binary PGM (P5) image using the default binary mapper.

Template Parameters
Lattice2D lattice type.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]optsNetPBM options.

Definition at line 1475 of file ca-io.H.

References write_pgm().

◆ write_pgm() [2/2]

template<typename Lattice , typename Mapper >
requires requires(Mapper &&m, const typename Lattice::state_type &v) { { m(v) } -> std::convertible_to<std::uint8_t>; }
void Aleph::CA::write_pgm ( std::ostream &  out,
const Lattice &  frame,
Mapper &&  mapper,
const NetPBM_Write_Options &  opts = {} 
)
inline

Write a binary PGM (P5) image.

mapper(cell) must return a grayscale byte. The top lattice row is the first image row.

Template Parameters
Lattice2D lattice type.
Mapperinvocable state_type -> uint8_t.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]mappergrayscale mapper.
[in]optsNetPBM options.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).

Definition at line 1444 of file ca-io.H.

References write_pgm().

Referenced by TEST(), Aleph::CA::Directory_Frame_Sink::write_one(), write_pgm(), and write_pgm().

◆ write_plaintext()

template<typename Lattice >
void Aleph::CA::write_plaintext ( std::ostream &  out,
const Lattice &  frame,
const Plaintext_Write_Options &  opts = {},
const typename Lattice::state_type &  dead = typename Lattice::state_type{} 
)
inline

Write a Life plaintext (.cells) pattern.

Template Parameters
Lattice2D lattice type.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]optsplaintext options.
[in]deadstate considered dead.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).

Definition at line 867 of file ca-io.H.

References write_plaintext().

Referenced by write_plaintext().

◆ write_plaintext_string()

template<typename Lattice >
std::string Aleph::CA::write_plaintext_string ( const Lattice &  frame,
const Plaintext_Write_Options &  opts = {},
const typename Lattice::state_type &  dead = typename Lattice::state_type{} 
)
inline

Return a Life plaintext document.

Template Parameters
Lattice2D lattice type.
Parameters
[in]framelattice frame.
[in]optsplaintext options.
[in]deadstate considered dead.
Returns
plaintext document.

Definition at line 897 of file ca-io.H.

References write_plaintext_string().

Referenced by TEST(), and write_plaintext_string().

◆ write_png() [1/2]

template<typename Lattice >
void Aleph::CA::write_png ( std::ostream &  out,
const Lattice &  frame 
)
inline

Write a frame as PNG using the default binary RGB mapper.

Template Parameters
Lattice2D lattice type.
Parameters
[in,out]outoutput stream.
[in]frameframe to encode.

Definition at line 226 of file ca-png.H.

References out, and write_png().

◆ write_png() [2/2]

template<typename Lattice , typename Mapper >
requires requires(Mapper &&m, const typename Lattice::state_type &v) { { m(v) } -> std::convertible_to<RGB8>; }
void Aleph::CA::write_png ( std::ostream &  out,
const Lattice &  frame,
Mapper &&  mapper 
)
inline

Write a rank-2 frame as an 8-bit RGB PNG image.

mapper(cell) must return an RGB8 colour. The function writes a complete PNG stream to out without closing it.

Template Parameters
Lattice2D lattice type.
Mapperinvocable state_type -> RGB8.
Parameters
[in,out]outoutput stream.
[in]frameframe to encode.
[in]mapperstate-to-RGB mapper.
Exceptions
std::domain_errorif the frame has zero width or height.
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).

Definition at line 171 of file ca-png.H.

References m.

Referenced by Aleph::CA::Png_Frame_Sink< Mapper >::accept(), TEST(), TEST(), Aleph::CA::Reproductions::write_gray_scott_png(), and write_png().

◆ write_ppm() [1/2]

template<typename Lattice >
void Aleph::CA::write_ppm ( std::ostream &  out,
const Lattice &  frame,
const NetPBM_Write_Options &  opts = {} 
)
inline

Write a binary PPM (P6) image using the default binary mapper.

Template Parameters
Lattice2D lattice type.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]optsNetPBM options.

Definition at line 1529 of file ca-io.H.

References write_ppm().

◆ write_ppm() [2/2]

template<typename Lattice , typename Mapper >
requires requires(Mapper &&m, const typename Lattice::state_type &v) { { m(v) } -> std::convertible_to<RGB8>; }
void Aleph::CA::write_ppm ( std::ostream &  out,
const Lattice &  frame,
Mapper &&  mapper,
const NetPBM_Write_Options &  opts = {} 
)
inline

Write a binary PPM (P6) image.

mapper(cell) must return an RGB8 triplet.

Template Parameters
Lattice2D lattice type.
Mapperinvocable state_type -> RGB8.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]mapperRGB mapper.
[in]optsNetPBM options.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).

Definition at line 1496 of file ca-io.H.

References write_ppm().

Referenced by Aleph::CA::Ffmpeg_Frame_Sink< Mapper >::accept(), main(), TEST(), Aleph::CA::Directory_Frame_Sink::write_one(), write_ppm(), and write_ppm().

◆ write_rle()

template<typename Lattice >
void Aleph::CA::write_rle ( std::ostream &  out,
const Lattice &  frame,
const RLE_Write_Options &  opts = {},
const typename Lattice::state_type &  dead = typename Lattice::state_type{} 
)
inline

Write a 2D frame in Conway RLE format.

A cell is considered alive when it differs from dead. With the default options, the complete frame dimensions are preserved in the RLE header. Set opts.trim_dead_border for compact pattern output.

Template Parameters
Lattice2D lattice type.
Parameters
[in,out]outoutput stream.
[in]framelattice frame.
[in]optsRLE formatting options.
[in]deadstate considered dead.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(rows * cols).
Thread-safety
The function is reentrant. Concurrent writes to the same stream are not synchronised.

Definition at line 575 of file ca-io.H.

References write_rle().

Referenced by Aleph::CA::Directory_Frame_Sink::write_one(), and write_rle().

◆ write_rle_string()

template<typename Lattice >
std::string Aleph::CA::write_rle_string ( const Lattice &  frame,
const RLE_Write_Options &  opts = {},
const typename Lattice::state_type &  dead = typename Lattice::state_type{} 
)
inline

Return a frame encoded as Conway RLE.

Template Parameters
Lattice2D lattice type.
Parameters
[in]framelattice frame.
[in]optsRLE formatting options.
[in]deadstate considered dead.
Returns
RLE document.

Definition at line 668 of file ca-io.H.

References write_rle_string().

Referenced by TEST(), TEST(), and write_rle_string().

◆ write_vtk_legacy()

template<typename Lattice >
void Aleph::CA::write_vtk_legacy ( std::ostream &  out,
const Lattice &  frame,
const VTK_Write_Options &  opts = {} 
)
inline

Write a 2D or 3D lattice as VTK legacy STRUCTURED_POINTS.

Axis mapping follows VTK convention: CA axis 0 maps to Y in 2D and Z in 3D, while the last CA axis maps to X.

Template Parameters
Latticerank-2 or rank-3 lattice type with arithmetic state.
Parameters
[in,out]outoutput stream.
[in]frameframe to write.
[in]optsVTK options.
Exceptions
std::runtime_erroron stream write failure.
Complexity
O(frame.size()).

Definition at line 119 of file ca-vtk.H.

Referenced by Aleph::CA::VTK_Frame_Sink::accept(), main(), and TEST().

◆ X11_Frame_Sink()

Variable Documentation

◆ Conway_Life

constexpr Outer_Totalistic_Binary_Rule Aleph::CA::Conway_Life
inlineconstexpr
Initial value:
{
static_cast<std::uint16_t>(1u << 3), static_cast<std::uint16_t>((1u << 2) | (1u << 3))}

Conway's Game of Life: B3/S23.

Definition at line 123 of file tpl_ca_hashlife.H.

Referenced by INSTANTIATE_TEST_SUITE_P(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ Day_And_Night

constexpr Outer_Totalistic_Binary_Rule Aleph::CA::Day_And_Night
inlineconstexpr
Initial value:
{
static_cast<std::uint16_t>((1u << 3) | (1u << 6) | (1u << 7) | (1u << 8)),
static_cast<std::uint16_t>((1u << 3) | (1u << 4) | (1u << 6) | (1u << 7) | (1u << 8))}

Bays' Day & Night: B3678/S34678 (self-complementary).

Definition at line 132 of file tpl_ca_hashlife.H.

Referenced by TEST().

◆ HighLife

constexpr Outer_Totalistic_Binary_Rule Aleph::CA::HighLife
inlineconstexpr
Initial value:
{
static_cast<std::uint16_t>((1u << 3) | (1u << 6)),
static_cast<std::uint16_t>((1u << 2) | (1u << 3))}

Nathan Thompson's HighLife: B36/S23 (replicators).

Definition at line 127 of file tpl_ca_hashlife.H.

Referenced by TEST(), TEST(), and TEST().

◆ Seeds

constexpr Outer_Totalistic_Binary_Rule Aleph::CA::Seeds
inlineconstexpr
Initial value:
{static_cast<std::uint16_t>(1u << 2),
std::uint16_t{0}}

Seeds: B2/S (every live cell dies, two neighbours produce a birth).

Definition at line 137 of file tpl_ca_hashlife.H.

Referenced by TEST().