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

Dense_Cell_Storage::view(): an Aleph::mdspan over a CA lattice. More...

#include <cassert>
#include <iostream>
#include <print_rule.H>
#include <tpl_ca_storage.H>
Include dependency graph for mdspan_ca_lattice_view_example.cc:

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Dense_Cell_Storage::view(): an Aleph::mdspan over a CA lattice.

Overview

CA::Dense_Cell_Storage<T, N> (tpl_ca_storage.H) already exposes at(coord)/set(coord, v) and 2D/3D shorthands at(i,j)/set(i,j,v). .view() (and the read-only .view() const) hands back an Aleph::mdspan over the same buffer — zero allocation, zero copy — so code that wants plain grid(i, j) indexing (e.g. porting a numerical kernel that was written against a raw 2D array) can have it without going through the checked at/set pair one call at a time.

  • [1] Same buffer, two ways to touch it: writes through .view() are immediately visible through .at(), and vice versa.
  • [2] A tiny stencil kernel over the view: sums each cell's 4 orthogonal neighbours directly through operator(), the kind of inner loop this view exists for.
  • [3] Read-only view: pass a const Dense_Cell_Storage& to a function that only needs to read it, and get a read-only mdspan.

Definition in file mdspan_ca_lattice_view_example.cc.

Function Documentation

◆ main()

int main ( void  )