getCoord

get coordinate in N-dim space by N-dim size and line index

size_t[]
getCoord
pure
(
A
)
(
in A[] size
,
size_t index
)
if (
isIntegral!A
)
in { assert (isAllCompPositive(size), "negative size"); auto maxindex = new A[](size.length); foreach (i, mi; maxindex) mi = size[i] - 1; assert (index <= getIndex(size, maxindex), "range violation"); }

Parameters

size
Type: A[]

N-dim array of sizes by each dimension

index
Type: size_t

index in 1-dim array

Retrurns: N-dim array of coordinates in N-dim space

Examples

assertEq( getCoord( [3,3,3], 13 ), [1,1,1] );
auto size = CrdVector!4( 10, 20, 30, 40 );
auto crd = CrdVector!4( 3, 5, 8, 10 );
assertEq( crd, getCoord( size, getIndex( size, crd ) ) );

Meta