I would like to perform a certain operation on every 2x2 non-overlapping subset of a very large 2D array with a single attribute. The operation updates the values of each element in the subset based on the current values of the other elements in that subset. For example, suppose I have:

## a1 b1 | a2 b2

c1 d1 | c2 d2

a3 b3 | a4 b4

c3 d3 | c4 d4

The update operation would need to complete simple arithmetic operations on each element that would involve access to the other members of the subset (where i = 1, 2, 3 or 4).

ai = foo1(ai, bi, ci, di)

bi = foo2(bi, ci, di)

ci = foo3(ai, ci, di)

di = foo4(ai, bi, ci, di)

I am new to scidb and have implemented this in a way that involves (1) using thin to split a, b, c and d values into separate arrays, (2) performing the update on each array with select statements, and (3) reconstruction of the original grid layout via a convoluted process using xgrid and filter on each split array, and putting them together with some insert statements.

I would really like to perform the operation in place, or at least more efficiently, in a manner perhaps similar to using a user defined function aggregate operation (minus the aggregation) on non-overlapping chunks, but I don’t know how to do this or if implementing a UDF is even the correct line of thought.

Any help would be much appreciated