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:
|determines cyclic or terminal boundary conditions for row and columns
|determines how to resolve collisions
|specifies how to handle submatrices
The CollisionFunction acts locally on elements by returning an output value from three sequential inputs:
|a single initial value
|a list containing the stack of candidate replacement values
|a list containing row and column indices
Choosing Method "Structured"
uses the resource function BlockSubmatrices
to build an optimized data structure.