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

Function idxByndEdge

src/backend/cpu/kernel/pad_array_borders.hpp:21–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19namespace kernel {
20namespace {
21static inline dim_t idxByndEdge(const dim_t i, const dim_t lb, const dim_t len,
22 const af::borderType btype) {
23 dim_t retVal;
24 switch (btype) {
25 case AF_PAD_SYM: retVal = trimIndex(i - lb, len); break;
26 case AF_PAD_CLAMP_TO_EDGE:
27 retVal = std::max(dim_t(0), std::min(i - lb, len - 1));
28 break;
29 case AF_PAD_PERIODIC: {
30 dim_t rem = (i - lb) % len;
31 bool cond = rem < 0;
32 retVal = cond * (rem + len) + (1 - cond) * rem;
33 } break;
34 default: retVal = 0; break;
35 }
36 return retVal;
37}
38} // namespace
39
40template<typename T>

Callers 2

operator()Method · 0.85
padBordersFunction · 0.85

Calls 3

trimIndexFunction · 0.50
maxFunction · 0.50
minFunction · 0.50

Tested by

no test coverage detected