Convert 3x3 array of 2x2 arrays to a 6x6 array maintaining position

I have a 3x3x4 array, each of the 3x3 subarrays (4-tuples, or 1x4 arrays) I want to map to a 2x2 array and stitch them together to form a 6x6 array. I'm having difficulty explaining this in words, so I hope the below illustration helps:

Here's a 3x3 array of 1x4 arrays, named 1 through 9:

1 2 3
4 5 6
7 8 9

Each 1x4 array above is enumerated below:

1 = [a, b, c, d]
2 = [e, f, g, h]
3 = [i, j, k, l]
4 = [m, n, o, p]
5 = [q, r, s, t]
6 = [u, v, w, x]
7 = [y, z, !, @]
8 = [#, $, %, ^]
9 = [&, *, (, )]

I want to convert this 3x3x4 array to a bigger 6x6 array:

a b e f i j
c d g h k l
m n q r u v
o p s t w x
y z # $ & *
! @ % ^ ( )

You'll see the top-left 2x2 corresponds to the 1st 1x4 array, the top-center 2x2 is the 2nd 1x4 array, and so on.

enter image description here

As in the image above, 1 became a b c d in a 2x2 sub-array, 2 became e f g h i in a 2x2 sub-array. These are part of the larger 6x6 array.

I'm not sure programmatically how to do this, any ideas?

I know some variables:

# original array is 3x3
old_width = 3
old_height = 3
# subarray size
sub_width = 2
sub_height = 2
# new array is function of the above four
new_width = old_width*sub_width
new_height = old_height*sub_height

If it makes a difference, this is for a self organizing map.



from Recent Questions - Stack Overflow https://ift.tt/3fkkbXV
https://ift.tt/39mgUDA

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations