Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ca-traits.H
Go to the documentation of this file.
1/*
2 Aleph_w
3
4 Data structures & Algorithms
5 version 2.0.0b
6 https://github.com/lrleon/Aleph-w
7
8 This file is part of Aleph-w library
9
10 Copyright (c) 2002-2026 Leandro Rabindranath Leon
11
12 Permission is hereby granted, free of charge, to any person obtaining a copy
13 of this software and associated documentation files (the "Software"), to deal
14 in the Software without restriction, including without limitation the rights
15 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 copies of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions:
18
19 The above copyright notice and this permission notice shall be included in all
20 copies or substantial portions of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 SOFTWARE.
29*/
30
48#ifndef CA_TRAITS_H
49#define CA_TRAITS_H
50
51#include <array>
52#include <cstddef>
53#include <span>
54
55namespace Aleph {
56namespace CA {
57
60using ca_index_t = std::ptrdiff_t;
61
63using ca_size_t = std::size_t;
64
68template <std::size_t N>
69using Coord_Vec = std::array<ca_index_t, N>;
70
78template <std::size_t N>
80
89template <typename T>
90using Neighbor_View = std::span<const T>;
91
104template <std::size_t Rank>
106{
108 std::size_t step = 0;
111};
112
113// -----------------------------------------------------------------------
114// Boundary policies
115// -----------------------------------------------------------------------
116
119{
120};
121
124{
125};
126
129{
130};
131
136template <typename T, T V>
138{
139 using state_type = T;
140 static constexpr T value = V;
141};
142
152{
153};
154
155// --- Phase 4 spelling aliases -----------------------------------------
156//
157// Phase 4 of the CA plan refers to the boundary policies as
158// `Periodic`, `Reflective`, `Dirichlet<...>` and `Neumann<...>`. The
159// underlying implementations are the Phase 1 tags; these aliases make
160// both naming conventions available without duplicating the logic.
161
164
169template <typename T, T V>
171
172// -----------------------------------------------------------------------
173// Iteration order tags
174// -----------------------------------------------------------------------
175
178{
179};
180
183{
184};
185
198template <std::size_t W, std::size_t H>
199struct Tile
200{
201 static_assert(W > 0 and H > 0, "Tile dimensions must be non-zero");
202
203 static constexpr std::size_t width = W;
204 static constexpr std::size_t height = H;
205};
206
207} // namespace CA
208} // namespace Aleph
209
210#endif // CA_TRAITS_H
std::span< const T > Neighbor_View
Read-only view over a contiguous range of neighbour values.
Definition ca-traits.H:90
std::ptrdiff_t ca_index_t
Signed coordinate component used by lattices and neighborhoods.
Definition ca-traits.H:60
std::array< ca_index_t, N > Coord_Vec
Default coordinate vector.
Definition ca-traits.H:69
std::size_t ca_size_t
Unsigned size component used for extents and counts.
Definition ca-traits.H:63
Coord_Vec< N > Offset_Vec
Default offset vector (aliases Coord_Vec).
Definition ca-traits.H:79
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
and
Check uniqueness with explicit hash + equality functors.
std::decay_t< typename HeadC::Item_Type > T
Definition ah-zip.H:105
Per-cell context handed to rules that need to know "where" and "when" they are firing.
Definition ca-traits.H:106
std::size_t step
Index of the step that is currently being computed (0-based).
Definition ca-traits.H:108
Coord_Vec< Rank > coord
Cell coordinate inside the current frame.
Definition ca-traits.H:110
Iterate the lattice in column-major (Fortran) order.
Definition ca-traits.H:183
Constant-value boundary.
Definition ca-traits.H:138
static constexpr T value
Definition ca-traits.H:140
Zero-gradient (Neumann) boundary.
Definition ca-traits.H:152
Out-of-range neighbours behave as if the lattice ended.
Definition ca-traits.H:119
Out-of-range coordinates mirror back into the lattice.
Definition ca-traits.H:129
Iterate the lattice in row-major (C) order.
Definition ca-traits.H:178
Iterate a 2D lattice in W x H tiles.
Definition ca-traits.H:200
static constexpr std::size_t width
Definition ca-traits.H:203
static constexpr std::size_t height
Definition ca-traits.H:204
The lattice wraps around on every axis.
Definition ca-traits.H:124
size_t V