adjPairsWithId: Adjacent-pairs with id, used by spread2 hot loop

View source: R/RcppExports.R

adjPairsWithIdR Documentation

Adjacent-pairs with id, used by spread2 hot loop

Description

Computes 4- or 8-direction neighbour pairs (from, to, id) for every cell and filters out neighbours that fall off the raster top/bottom or wrap across left/right edges. Rows are emitted in the same direction-major order that adj() produces (topl, top, topr, lef, rig, botl, bot, botr for directions == 8) so that downstream seeded operations (e.g. R-side sample.int shuffle) consume RNG state and produce identical output to the original spread2 implementation. This replaces only the adj() call inside the spread2 main loop; the row-randomization step still happens in R afterwards.

Usage

adjPairsWithId(cells, id, numCol, numCell, directions)

Arguments

cells

integer vector of source cell indices (1-based)

id

integer vector of the same length as cells; the event id for each cell

numCol

integer; number of raster columns

numCell

integer; total number of raster cells

directions

integer; either 4 or 8

Value

A list with three integer vectors from, to, id.


SpaDES.tools documentation built on Aug. 29, 2026, 1:07 a.m.