66 const double unit =
static_cast<double>(
h >> 11)
67 * (1.0 / 9007199254740992.0);
76 const unsigned long value = std::strtoul(text, &end, 10);
77 if (end == text
or *end !=
'\0' or value == 0)
79 return static_cast<std::size_t
>(
value);
96 lat.set(c, Cell{0.50 + z, 0.25 - z});
100unsigned char to_byte(
const double x)
102 const double y = std::clamp(x, 0.0, 1.0);
103 return static_cast<unsigned char>(255.0 *
y + 0.5);
108 std::ofstream
out(path, std::ios::binary);
111 out <<
"P6\n" <<
lat.size(1) <<
' ' <<
lat.size(0) <<
"\n255\n";
117 const unsigned char r =
to_byte(2.2 * c.v);
118 const unsigned char g =
to_byte(1.2 * (1.0 - c.u));
119 const unsigned char b =
to_byte(1.0 - 1.8 * c.v);
120 out.put(
static_cast<char>(
r));
121 out.put(
static_cast<char>(g));
122 out.put(
static_cast<char>(b));
130 std::size_t peaks = 0;
143 if (c.v > stats.max_v)
148 stats.mean_v =
sum /
static_cast<double>(
lat.size(0) *
lat.size(1));
161 constexpr std::uint64_t master_seed = 0x5eed1234abcddcbaull;
163 std::cout <<
"Gray-Scott reaction-diffusion example\n";
164 std::cout <<
" grid : " << n <<
"x" << n <<
" Neumann boundary\n";
165 std::cout <<
" params : F=0.0367 K=0.0649 Du=0.16 Dv=0.08 dt=1\n";
166 std::cout <<
" seed : 0x" << std::hex << master_seed << std::dec <<
'\n';
167 std::cout <<
" steps : " <<
steps <<
'\n';
168 std::cout <<
" output : " <<
output <<
"\n\n";
181 for (std::size_t step = 0; step <
steps; ++step)
187 std::cout <<
" step " << std::setw(5) << (step + 1)
188 <<
" mean(v)=" << std::fixed << std::setprecision(5)
190 <<
" max(v)=" << stats.max_v
191 <<
" peaks(v>0.10)=" << stats.peaks <<
'\n';
196 std::cout <<
"\nWrote " <<
output <<
'\n';
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
size_t size_t int32_t value
size_t size_t int32_t * out
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.
Gray-Scott reaction-diffusion rule.
Lattice that adds boundary-aware access on top of a storage.
Moore (Chebyshev) neighborhood of radius R in N dimensions.
Synchronous double-buffered engine.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
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.
void write_ppm(std::ostream &out, const Lattice &frame, Mapper &&mapper, const NetPBM_Write_Options &opts={})
Write a binary PPM (P6) image.
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Main namespace for Aleph-w library functions.
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.
Container for comprehensive statistical results.
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).