|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Rule whose next state depends on the sum of every cell in the neighbourhood (including the centre). More...
#include <tpl_ca_rule.H>
Public Member Functions | |
| constexpr | Totalistic_Rule (F func) |
| Construct a totalistic rule from a functor. | |
| template<typename State > | |
| constexpr State | operator() (const State ¤t, Neighbor_View< State > neighbours) const |
| Compute the next state from the sum of centre and neighbours. | |
Private Attributes | |
| F | f_ |
Rule whose next state depends on the sum of every cell in the neighbourhood (including the centre).
Used by Wolfram's totalistic codes and by averaging-style updates. The functor receives the accumulated sum widened to std::common_type_t<State, std::intmax_t> to avoid overflow for bool and small integral states, and returns the next state.
| F | functor type with signature (std::common_type_t<State, std::intmax_t>) -> State. |
Definition at line 146 of file tpl_ca_rule.H.
|
inlineexplicitconstexpr |
Construct a totalistic rule from a functor.
| [in] | func | callable object receiving the accumulated sum. |
| Any | exception thrown while moving/copying func. |
Definition at line 156 of file tpl_ca_rule.H.
|
inlineconstexpr |
Compute the next state from the sum of centre and neighbours.
The sum is accumulated in a widened common type to avoid losing information for bool and small integral states.
| State | cell state type. |
| [in] | current | current centre-cell state. |
| [in] | neighbours | read-only neighbour values. |
| Any | exception thrown by the wrapped functor. |
Definition at line 170 of file tpl_ca_rule.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Totalistic_Rule< F >::f_, and Aleph::sum().
|
private |
Definition at line 148 of file tpl_ca_rule.H.
Referenced by Aleph::CA::Totalistic_Rule< F >::operator()().