30#include <gtest/gtest.h>
47constexpr double eps = 1e-12;
55 const double unit =
static_cast<double>(
h >> 11)
56 * (1.0 / 9007199254740992.0);
61 const std::uint64_t
master)
82 std::size_t peaks = 0;
87 const double total =
static_cast<double>(
lat.size(0) *
lat.size(1));
91 std::size_t peaks = 0;
112 if (a.extents() != b.extents())
114 for (
ca_size_t i = 0; i < a.size(0); ++i)
115 for (
ca_size_t j = 0; j < a.size(1); ++j)
116 if (a.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)})
117 != b.at({static_cast<ca_index_t>(i), static_cast<ca_index_t>(j)}))
127 [](
double current,
double conv,
double dt)
129 return current + dt * (
conv - current);
136 const std::array<double, 8> neighbours{1.0, 1.0, 1.0, 1.0,
146 [](
double,
double,
double) {
return 0.0; },
152 [](
double,
double,
double) {
return 2.0; },
157 const std::array<double, 8> neighbours{};
163 [](
double,
double conv) {
return conv; },
186 const std::array<RD_Cell, 8> neighbours{
RD_Cell{1.0, 0.0},
205 const std::array<RD_Cell, 8> neighbours{
RD_Cell{1.0, 0.0},
224 constexpr std::uint64_t
master = 0x9E3779B97F4A7C15ull;
225 constexpr std::size_t
steps = 360;
229 a(make_gray_scott_seed(n,
master), rule);
231 b(make_gray_scott_seed(n,
master), rule);
242 EXPECT_LT(stats.peaks,
static_cast<std::size_t
>(n * n / 2));
253 const std::array<RD_Cell, 8> neighbours{};
270 const std::array<RD_Cell, 8> neighbours{};
302 int sum = current.current() + current.previous(1);
303 for (
const auto &n : neighbours)
308 const Cell current(2);
309 const std::array<Cell, 2> neighbours{Cell(3), Cell(5)};
323 [](
int current,
int previous) ->
int
325 return current + previous;
static int cell(const aleph_ca_engine_t *e, size_t r, size_t c)
Fixed 2-D convolution kernels for continuous cellular automata.
Reproducible random-number support for stochastic CA rules (Phase 8).
Common typedefs and tag types for the Cellular Automata module.
FitzHugh-Nagumo excitable-media rule.
Gray-Scott reaction-diffusion rule.
Cell state carrying a fixed-depth ring buffer of past values.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Synchronous double-buffered engine.
void run(const std::size_t steps)
Run several synchronous steps.
const Lattice & frame() const noexcept
Return the current frame.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Gray_Scott_Lattice make_gray_scott_seed(const ca_size_t side, const std::uint64_t master_seed)
Build the deterministic finite-amplitude Gray-Scott perturbation.
std::span< const T > Neighbor_View
Read-only view over a contiguous range of neighbour values.
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
std::array< ca_index_t, N > Coord_Vec
Default coordinate vector.
bool frames_equal(const Lattice &a, const Lattice &b)
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.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Main namespace for Aleph-w library functions.
auto variance(const Container &data, bool population=false) -> std::decay_t< decltype(*std::begin(data))>
Compute variance using Welford's numerically stable algorithm.
auto mean(const Container &data) -> std::decay_t< decltype(*std::begin(data))>
Compute the arithmetic mean.
void next()
Advance all underlying iterators (bounds-checked).
auto max_value(const Container &data) -> std::decay_t< decltype(*std::begin(data))>
Compute maximum value.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
Zero-gradient (Neumann) boundary.
Two-field state for reaction-diffusion cellular automata.
The lattice wraps around on every axis.
Continuous and memory-bearing CA rules (Phase 9).
Synchronous double-buffered engine for cellular automata.
Cellular automata lattice with pluggable boundary policies.
Neighborhoods catalogue for Aleph::CA.
Dense, contiguous storage for cellular automata cells (1D/2D/3D).