Find the position within an array larger than 3D (New Features)

by Jim ⌂ @, Russell, KY, Wednesday, May 02, 2012, 02:52 (1967 days ago) @ lrcvs

M...

for 2 D assuming d1 and d0 as the dimensions and a1 and a0 are the array index

the formula i2d = (a1-1) * d0 + (a0-1) would convert to 1D

3d d2, d1, d0 and a2, a1, a0 would be

i3d = (a2-1) * d1 * d0 + (a1-1) * d0 + (a0-1) - or -
i3d = (a2-1) * d1 * d0 + i2d


4d d3, d2, d1, d0 and a3, a2, a1, a0 would be

i4d = (a3-1) * d2 * d1 * d0 + (a2-1) * d1 * d0 + (a1-1) * d0 + (a0-1) - or -
i4d = (a3-1) * d2 * d1 * d0 + i3d

I think this would be a general (recursive) definition (in my own screwy notation.

i{N}d = (a{N-1} - 1) * PRODUCT(d{N-2} ... d{0}) + i{n-1}d


Complete thread:

 RSS Feed of thread

powered by my little forum