arraylib::EdgeWrap

Command: arraylib::EdgeWrap


Description

This function iterates through the given array indices and checks if
they lie inside the specified range [0 height) and [0 width)
respectively.

Indices are modified according to the following rules:

1. If both indices lie inside [0 height) and [0 width) respectively
they are left untouched.
2. If the row index lies outside [0 height) it is cyclicly wrapped
around. That is a suitable multiple of "height" is added or
substracted that makes the index fall inside [0 height).
3. If the column index lies outside [0 width) it is cyclicly wrapped
around. That is a suitable multiple of "width" is added or
substracted that makes the index fall inside [0 width).

Thus the indices are effectively wrapped around the array edges;
that is they are mapped onto a torus of dimensions height width.

Note that by NEST convention for index pairs the first index denotes
the row and the second index denotes the column.

Dimensions of the index array are preserved.

Author
Ruediger Kupper

Synopsis
[2d-indices] height width EdgeWrap -> [wrapped-2d-indices]

File
lib/sli/arraylib.sli
Diagnostics

The index array is expected to be a (nested) array of integer values
only. Code will break otherwise.

Remarks

The index array is expected to be a (nested) array of integer values only.

FirstVersion
14.3.2003 (Einstein's birthday)