37class Lotka_Volterra_Rule
39 double alpha_, beta_, delta_, gamma_, dt_, diff_;
42 Lotka_Volterra_Rule(
double alpha,
double beta,
double delta,
double gamma,
43 double dt,
double diffusion)
44 : alpha_(alpha), beta_(beta), delta_(
delta), gamma_(
gamma), dt_(dt),
48 std::tuple<double, double>
49 operator()(
const std::tuple<double, double> &cur,
52 const double x = std::get<0>(cur);
53 const double y = std::get<1>(cur);
54 double lap_x = -
static_cast<double>(std::get<0>(nb).size()) * x;
55 double lap_y = -
static_cast<double>(std::get<1>(nb).size()) *
y;
56 for (
const auto &p :
std::get<0>(nb)) lap_x += p;
57 for (
const auto &p :
std::get<1>(nb)) lap_y += p;
58 const double next_x = x + dt_ * (alpha_ * x - beta_ * x *
y + diff_ * lap_x);
59 const double next_y =
y + dt_ * (delta_ * x *
y - gamma_ *
y + diff_ * lap_y);
60 return {next_x < 0.0 ? 0.0 : next_x, next_y < 0.0 ? 0.0 : next_y};
70 Grid lat({side, side});
71 lat.fill(std::tuple{1.0, 0.5});
74 for (
ca_size_t i = cr - 1; i <= cr + 1; ++i)
75 for (
ca_size_t j = cc - 1; j <= cc + 1; ++j)
89 constexpr std::size_t
steps = 500;
90 const double processed_cells
91 =
static_cast<double>(side) *
static_cast<double>(side) *
static_cast<double>(
steps);
97 Lotka_Volterra_Rule{1.0, 0.5, 0.4,
Shared harness for the cellular-automata performance-gate anchors.
Common typedefs and tag types for the Cellular Automata module.
Synchronous double-buffered engine for multi-field lattices.
void run(const std::size_t steps)
Run several steps.
Multi-field lattice with selectable storage layout.
Von Neumann (L1) neighborhood of radius R in N dimensions.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_gamma_function > > gamma(const __gmp_expr< T, U > &expr)
std::size_t resolve_repeats(const std::size_t fallback)
Resolve the number of timed repetitions for one anchor.
void emit_json(const Bench_Result &result, std::ostream &out=std::cout)
Print one benchmark result as a single structured JSON object.
Bench_Result measure(std::string name, const double processed_cells, std::size_t repeats, Work &&work)
Time a kernel with one warmup pass plus a median of timed passes.
constexpr std::uint32_t delta
File contains only the cells that changed relative to a baseline.
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.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Outcome of one measured anchor benchmark.
Phase 14 synchronous double-buffered engine for multi-field cellular automata.
Phase 14 multi-field cellular automata lattice (AoS / SoA).
Neighborhoods catalogue for Aleph::CA.