Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::Totalistic_Rule< F > Class Template Reference

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 &current, Neighbor_View< State > neighbours) const
 Compute the next state from the sum of centre and neighbours.
 

Private Attributes

F f_
 

Detailed Description

template<typename F>
class Aleph::CA::Totalistic_Rule< 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.

Template Parameters
Ffunctor type with signature (std::common_type_t<State, std::intmax_t>) -> State.

Definition at line 146 of file tpl_ca_rule.H.

Constructor & Destructor Documentation

◆ Totalistic_Rule()

template<typename F >
constexpr Aleph::CA::Totalistic_Rule< F >::Totalistic_Rule ( F  func)
inlineexplicitconstexpr

Construct a totalistic rule from a functor.

Parameters
[in]funccallable object receiving the accumulated sum.
Exceptions
Anyexception thrown while moving/copying func.

Definition at line 156 of file tpl_ca_rule.H.

Member Function Documentation

◆ operator()()

template<typename F >
template<typename State >
constexpr State Aleph::CA::Totalistic_Rule< F >::operator() ( const State &  current,
Neighbor_View< State >  neighbours 
) const
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.

Template Parameters
Statecell state type.
Parameters
[in]currentcurrent centre-cell state.
[in]neighboursread-only neighbour values.
Returns
next state produced by the wrapped functor.
Exceptions
Anyexception 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().

Member Data Documentation

◆ f_

template<typename F >
F Aleph::CA::Totalistic_Rule< F >::f_
private

Definition at line 148 of file tpl_ca_rule.H.

Referenced by Aleph::CA::Totalistic_Rule< F >::operator()().


The documentation for this class was generated from the following file: