Details
Each rule in rules must map between submatrices of fixed rectangular dimensions m×n, but m and n may vary across rules.
The replacement procedure groups
rules by submatrix dimension, and applies them to individual submatrices using
ReplaceAll.
When application of rules over all submatrices leads to two or more plausible image values for one particular matrix element, a collision is said to occur.
Collisions occur in two different cases:
Applying only one replacement rule may cause a collision within a region where two submatrices overlap.
Applying many distinct replacement rules may cause a collision within a region where two submatrices overlap.
Collisions do not occur in only one submatrix, because the underlying mechanism involves
ReplaceAll.
ResourceFunction["SubmatrixReplace"] takes the following options:
"Cyclic" | {True,True} | determines cyclic or terminal boundary conditions for row and columns |
CollisionFunction | First[#2]& | determines how to resolve collisions |
Method | "Structured" | specifies how to handle submatrices |
The CollisionFunction acts locally on elements by returning an output value from three sequential inputs:
#1 | a single initial value |
#2 | a list containing the stack of candidate replacement values |
#3 | a list containing row and column indices |
Choosing
Method "Structured" uses the resource function
BlockSubmatrices to build an optimized data structure.