hpcflow.sdk.core.utils.get_nested_indices#

hpcflow.sdk.core.utils.get_nested_indices(idx, size, nest_levels, raise_on_rollover=False)#

Generate the set of nested indices of length n that correspond to a global idx.

Examples

>>> for i in range(4**2): print(get_nest_index(i, nest_levels=2, size=4))
[0, 0]
[0, 1]
[0, 2]
[0, 3]
[1, 0]
[1, 1]
[1, 2]
[1, 3]
[2, 0]
[2, 1]
[2, 2]
[2, 3]
[3, 0]
[3, 1]
[3, 2]
[3, 3]
>>> for i in range(4**3): print(get_nested_indices(i, nest_levels=3, size=4))
[0, 0, 0]
[0, 0, 1]
[0, 0, 2]
[0, 0, 3]
[0, 1, 0]
   ...
[3, 2, 3]
[3, 3, 0]
[3, 3, 1]
[3, 3, 2]
[3, 3, 3]