Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_ca_neighborhood.H File Reference

Neighborhoods catalogue for Aleph::CA. More...

#include <array>
#include <cstddef>
#include <span>
#include <utility>
#include <ah-errors.H>
#include <ca-traits.H>
#include <tpl_ca_concepts.H>
Include dependency graph for tpl_ca_neighborhood.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::CA::Moore< N, R >
 Moore (Chebyshev) neighborhood of radius R in N dimensions. More...
 
class  Aleph::CA::Von_Neumann< N, R >
 Von Neumann (L1) neighborhood of radius R in N dimensions. More...
 
class  Aleph::CA::Hex_Neighborhood
 Six-neighbour hex pattern in axial coordinates over a 2D lattice. More...
 
class  Aleph::CA::Triangular_Neighborhood
 Three edge-neighbours over a 2D lattice with parity coupling. More...
 
class  Aleph::CA::Custom_Neighborhood< N, K, Radius >
 User-supplied list of offsets for arbitrary connectivity. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::CA
 
namespace  Aleph::CA::ca_neighborhood_detail
 

Functions

constexpr std::size_t Aleph::CA::ca_neighborhood_detail::static_pow (std::size_t base, std::size_t exp) noexcept
 Compile-time integer power.
 
template<std::size_t N, std::size_t R>
constexpr std::size_t Aleph::CA::ca_neighborhood_detail::von_neumann_count () noexcept
 Number of integer points in the L1 ball of radius R in N dimensions, excluding the origin.
 
template<std::size_t N, std::size_t R>
constexpr auto Aleph::CA::ca_neighborhood_detail::compute_moore_offsets () noexcept
 Generate the canonical-ordered list of Moore offsets for N/R.
 
template<std::size_t N, std::size_t R>
constexpr auto Aleph::CA::ca_neighborhood_detail::compute_von_neumann_offsets () noexcept
 Generate the canonical-ordered list of Von Neumann offsets for N/R (L1 radius).
 
template<typename Nbh , typename L , typename T >
void Aleph::CA::gather_neighbors (const Nbh &nh, const L &lat, const typename L::coord_type &center, std::span< T > out)
 Populate out[0..nh.size()) with neighbour values of center.
 

Detailed Description

Neighborhoods catalogue for Aleph::CA.

Provides:

  • Moore<N, R> — Chebyshev-radius neighborhood ((2R+1)^N - 1).
  • Von_Neumann<N, R> — L1-radius neighborhood.
  • Hex_Neighborhood — 6 axial-coord neighbours over a 2D lattice.
  • Triangular_Neighborhood— 3 edge neighbours, parity-dependent.
  • Custom_Neighborhood<N, K, Radius> — explicit list of offsets supplied at runtime.

Every neighborhood satisfies the NeighborhoodLike concept and publishes a uniform compile-time API:

static constexpr std::size_t rank_v; // lattice dim
static constexpr std::size_t size_v; // neighbour count
static constexpr std::size_t radius_v; // Chebyshev radius
std::size_t radius() const;
std::size_t size() const;
template <typename F>
void for_each_offset(const Coord_Vec<rank_v> & center, F && f) const;

Plus a free function template:

template <class Nbh, class L, class T>
void gather_neighbors(const Nbh & nh, const L & lat,
const typename L::coord_type & center,
std::span<T> out);
size_t size_t int32_t * out
Definition ca-c-api.h:120

which fills the caller-supplied stack buffer with the values returned by lat.at_safe(center + offset) in canonical order. No heap.

Author
Leandro Rabindranath Leon

Definition in file tpl_ca_neighborhood.H.