P99

◆ P99_CDIM

#define P99_CDIM (   NAME,
  ... 
)    P00_CDIM(P99_NARG(__VA_ARGS__), NAME, __VA_ARGS__)

Compute an absolute index in a multidimensional array in the same way as C.

If we have N arguments after NAME, NAME must be an array of type

size_t NAME[N];

that hold the side lengths of an N dimensional cube. E.g

size_t const D[] = { 3, 4, 7 };

corresponds to a cube of side length 3 in dimension 0, 4 in dimension 1 and 7 in dimension 2, with in total 84 elements. With that, we get

P99_CDIM(D, 1, 2, 3) => ((3) + ((D)[2] * ((2) + ((D)[1] * (1)))))
P99_CDIM(D, k0, k1, k2) => ((k2) + ((D)[2] * ((k1) + ((D)[1] * (k0)))))
Warning
argument 0 may be evaluated multiple times

Definition at line 580 of file p99_for.h.

P99_CDIM
#define P99_CDIM(NAME,...)
Compute an absolute index in a multidimensional array in the same way as C.
Definition: p99_for.h:580