|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Precomputed transition table for (self, neighbours...).
More...
#include <tpl_ca_rule.H>
Public Types | |
| using | table_type = std::array< std::size_t, table_size_v > |
| Transition table type storing next states for every input tuple. | |
Public Member Functions | |
| constexpr | Lookup_Rule ()=default |
| Build a zero-initialised lookup rule. | |
| constexpr | Lookup_Rule (table_type t) |
| Build a lookup rule from a precomputed transition table. | |
| constexpr const table_type & | raw_table () const noexcept |
| Return the underlying transition table. | |
| template<typename State > | |
| State | operator() (const State ¤t, Neighbor_View< State > neighbours) const |
| Compute the next state using the precomputed table. | |
Static Public Attributes | |
| static constexpr std::size_t | num_states_v = NumStates |
| Number of distinct cell states accepted by this rule. | |
| static constexpr std::size_t | num_neighbours_v = NumNeighbors |
Number of neighbour entries required by operator(). | |
| static constexpr std::size_t | table_size_v = ca_rule_detail::static_pow_rule(NumStates, NumNeighbors + 1) |
| Number of entries in the transition table. | |
Private Attributes | |
| table_type | table_ {} |
Precomputed transition table for (self, neighbours...).
For S states and K neighbours, the table size is S^(K+1). The index used to look up the next state is
idx = self * S^K + neighbours[0] * S^(K-1) + ... + neighbours[K-1]
which matches the canonical "self-major" convention. The factory make_wolfram_elementary_rule(rule_no) translates the standard Wolfram code (which uses a different bit layout) into a table for this convention assuming the neighbourhood used at the call site is Custom_Neighborhood<1, 2>{ {-1, +1} } — i.e. left first, right second.
| NumStates | number of distinct cell states. |
| NumNeighbors | number of neighbours seen by the rule. |
Definition at line 212 of file tpl_ca_rule.H.
| using Aleph::CA::Lookup_Rule< NumStates, NumNeighbors >::table_type = std::array<std::size_t, table_size_v> |
Transition table type storing next states for every input tuple.
Definition at line 226 of file tpl_ca_rule.H.
|
constexprdefault |
Build a zero-initialised lookup rule.
Every transition maps to state 0.
|
inlineexplicitconstexpr |
Build a lookup rule from a precomputed transition table.
| [in] | t | transition table indexed by (self, neighbours...). |
| Any | exception thrown while copying/moving the table. |
Definition at line 243 of file tpl_ca_rule.H.
|
inline |
Compute the next state using the precomputed table.
| State | cell state type convertible to std::size_t. |
| [in] | current | current centre-cell state. |
| [in] | neighbours | read-only neighbour values. |
| std::length_error | if neighbours.size() != NumNeighbors. |
| std::domain_error | if current or a neighbour is outside [0, NumStates). |
Definition at line 266 of file tpl_ca_rule.H.
References ah_domain_error_if, ah_length_error_if, Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Lookup_Rule< NumStates, NumNeighbors >::table_, and value.
|
inlineconstexprnoexcept |
Return the underlying transition table.
| This | function does not throw. |
Definition at line 250 of file tpl_ca_rule.H.
References Aleph::CA::Lookup_Rule< NumStates, NumNeighbors >::table_.
|
staticconstexpr |
Number of neighbour entries required by operator().
Definition at line 219 of file tpl_ca_rule.H.
|
staticconstexpr |
Number of distinct cell states accepted by this rule.
Definition at line 216 of file tpl_ca_rule.H.
|
private |
Definition at line 229 of file tpl_ca_rule.H.
Referenced by Aleph::CA::Lookup_Rule< NumStates, NumNeighbors >::operator()(), and Aleph::CA::Lookup_Rule< NumStates, NumNeighbors >::raw_table().
|
staticconstexpr |
Number of entries in the transition table.
Definition at line 222 of file tpl_ca_rule.H.