67 std::cout <<
"[1] .view() aliases the storage's own buffer\n";
74 std::cout <<
"grid.at(1, 1) after v(1,1)=5: " <<
grid.
at(1, 1) <<
" (expect 5)\n";
77 std::cout <<
"v(0, 0) after grid.set(0,0,9): " << v(0, 0) <<
" (expect 9)\n\n";
85 return v(i - 1, j) + v(i + 1, j) + v(i, j - 1) + v(i, j + 1);
90 std::cout <<
"[2] A tiny stencil kernel driven directly through the view\n";
96 std::cout <<
"Sum of the 4 orthogonal neighbours of every interior cell\n"
97 "(each has value 1, so every sum should be 4):\n";
98 for (
size_t i = 1; i + 1 < v.extent(0); ++i)
100 for (
size_t j = 1; j + 1 < v.extent(1); ++j)
109 for (
size_t i = 0; i < v.
extent(0); ++i)
111 for (
size_t j = 0; j < v.
extent(1); ++j)
112 std::cout << v(i, j) <<
" ";
119 std::cout <<
"[3] Read-only view for a function that only reads the lattice\n";
124 for (
size_t i = 0; i < 2; ++i)
125 for (
size_t j = 0; j < 3; ++j)
135 std::cout <<
"\n=== Dense_Cell_Storage::view(): mdspan over a CA lattice ===\n\n";
141 std::cout <<
"Done.\n";
Row-major dense storage for N-dimensional cellular automata.
view_type view() noexcept
Return a mutable Aleph::mdspan view of this storage.
T at(const coord_type &c) const
Read access through a multi-index.
void set(const coord_type &c, const T &v)
Write access through a multi-index.
Non-owning view of a contiguous buffer as a multidimensional grid.
constexpr index_type extent(rank_type r) const noexcept
Run-time size of axis r.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
void print_rule()
Prints a horizontal rule for example output separation.
void next()
Advance all underlying iterators (bounds-checked).
Dense, contiguous storage for cellular automata cells (1D/2D/3D).