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

Function trimIndex

src/backend/cpu/utility.hpp:18–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16namespace arrayfire {
17namespace cpu {
18static inline dim_t trimIndex(int const& idx, dim_t const& len) {
19 int ret_val = idx;
20 if (ret_val < 0) {
21 int offset = (abs(ret_val) - 1) % len;
22 ret_val = offset;
23 } else if (ret_val >= (int)len) {
24 int offset = abs(ret_val) % len;
25 ret_val = len - offset - 1;
26 }
27 return ret_val;
28}
29
30static inline unsigned getIdx(af::dim4 const& strides, int i, int j = 0,
31 int k = 0, int l = 0) {

Callers 4

idxByndEdgeFunction · 0.50
indexFunction · 0.50
lookupFunction · 0.50
assignFunction · 0.50

Calls 1

absFunction · 0.70

Tested by

no test coverage detected