MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / unravelIdx

Function unravelIdx

test/arrayfire_test.cpp:532–540  ·  view source on GitHub ↗

Calculate a linearized index's multi-dimensonal coordinates in an af::array, given its dimension sizes and strides

Source from the content-addressed store, hash-verified

530// af::array,
531// given its dimension sizes and strides
532af::dim4 unravelIdx(dim_t idx, af::dim4 dims, af::dim4 strides) {
533 af::dim4 coords;
534 coords[3] = idx / (strides[3]);
535 coords[2] = idx / (strides[2]) % dims[2];
536 coords[1] = idx / (strides[1]) % dims[1];
537 coords[0] = idx % dims[0];
538
539 return coords;
540}
541
542af::dim4 unravelIdx(dim_t idx, af::array arr) {
543 af::dim4 dims = arr.dims();

Callers 2

printContextFunction · 0.85
elemWiseEqFunction · 0.85

Calls 2

getStridesFunction · 0.85
dimsMethod · 0.45

Tested by

no test coverage detected