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

Moore (Chebyshev) neighborhood of radius R in N dimensions. More...

#include <tpl_ca_neighborhood.H>

Collaboration diagram for Aleph::CA::Moore< N, R >:
[legend]

Public Types

using coord_type = Coord_Vec< N >
 Coordinate type accepted by for_each_offset.
 

Public Member Functions

constexpr std::size_t size () const noexcept
 Return the number of neighbours in the neighborhood.
 
template<typename F >
constexpr void for_each_offset (const Coord_Vec< N > &center, F &&f) const
 Apply a functor to each offset in the neighborhood.
 

Static Public Member Functions

static constexpr std::size_t radius () noexcept
 Return the Chebyshev radius of the neighborhood.
 

Static Public Attributes

static constexpr std::size_t rank_v = N
 Lattice dimension.
 
static constexpr std::size_t radius_v = R
 Chebyshev radius.
 
static constexpr std::size_t size_v = ca_neighborhood_detail::static_pow(2 * R + 1, N) - 1
 Number of neighbours (excluding center).
 
static constexpr std::array< Offset_Vec< N >, size_v > offsets = ca_neighborhood_detail::compute_moore_offsets<N, R>()
 Compile-time, canonical-ordered offsets array.
 

Detailed Description

template<std::size_t N, std::size_t R = 1>
class Aleph::CA::Moore< N, R >

Moore (Chebyshev) neighborhood of radius R in N dimensions.

Enumerates every offset whose components lie in [-R, R], except the origin. Total: (2R+1)^N - 1. For 2D radius 1 this is the classic 8-neighbour pattern used by Conway's Game of Life.

Definition at line 228 of file tpl_ca_neighborhood.H.

Member Typedef Documentation

◆ coord_type

template<std::size_t N, std::size_t R = 1>
using Aleph::CA::Moore< N, R >::coord_type = Coord_Vec<N>

Coordinate type accepted by for_each_offset.

Definition at line 241 of file tpl_ca_neighborhood.H.

Member Function Documentation

◆ for_each_offset()

template<std::size_t N, std::size_t R = 1>
template<typename F >
constexpr void Aleph::CA::Moore< N, R >::for_each_offset ( const Coord_Vec< N > &  center,
F &&  f 
) const
inlineconstexpr

Apply a functor to each offset in the neighborhood.

Template Parameters
Ffunctor type.
Parameters
[in]centerthe coordinate of the center cell.
[in]ffunctor to apply.

Definition at line 272 of file tpl_ca_neighborhood.H.

References Aleph::blossom_maximum_cardinality_matching(), Aleph::CA::Moore< N, R >::offsets, and Aleph::CA::Moore< N, R >::size_v.

Referenced by TEST().

◆ radius()

template<std::size_t N, std::size_t R = 1>
static constexpr std::size_t Aleph::CA::Moore< N, R >::radius ( )
inlinestaticconstexprnoexcept

Return the Chebyshev radius of the neighborhood.

Returns
the template parameter R.

Definition at line 253 of file tpl_ca_neighborhood.H.

References Aleph::CA::R.

◆ size()

template<std::size_t N, std::size_t R = 1>
constexpr std::size_t Aleph::CA::Moore< N, R >::size ( ) const
inlineconstexprnoexcept

Return the number of neighbours in the neighborhood.

Returns
size_v, equal to (2R+1)^N - 1.

Definition at line 261 of file tpl_ca_neighborhood.H.

References Aleph::CA::Moore< N, R >::size_v.

Member Data Documentation

◆ offsets

template<std::size_t N, std::size_t R = 1>
constexpr std::array<Offset_Vec<N>, size_v> Aleph::CA::Moore< N, R >::offsets = ca_neighborhood_detail::compute_moore_offsets<N, R>()
staticconstexpr

Compile-time, canonical-ordered offsets array.

Contains all size_v offsets sorted in lexicographic order.

Definition at line 247 of file tpl_ca_neighborhood.H.

Referenced by Aleph::CA::Moore< N, R >::for_each_offset().

◆ radius_v

template<std::size_t N, std::size_t R = 1>
constexpr std::size_t Aleph::CA::Moore< N, R >::radius_v = R
staticconstexpr

Chebyshev radius.

Definition at line 237 of file tpl_ca_neighborhood.H.

◆ rank_v

template<std::size_t N, std::size_t R = 1>
constexpr std::size_t Aleph::CA::Moore< N, R >::rank_v = N
staticconstexpr

Lattice dimension.

Definition at line 235 of file tpl_ca_neighborhood.H.

◆ size_v

template<std::size_t N, std::size_t R = 1>
constexpr std::size_t Aleph::CA::Moore< N, R >::size_v = ca_neighborhood_detail::static_pow(2 * R + 1, N) - 1
staticconstexpr

Number of neighbours (excluding center).

Definition at line 239 of file tpl_ca_neighborhood.H.

Referenced by Aleph::CA::Moore< N, R >::for_each_offset(), and Aleph::CA::Moore< N, R >::size().


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