I am trying to remove elements from an ArrayFire array (af::array) iteratively in a loop. Say I have:
af::array arr = af::range(af::dim4(4), -1, u32) + 1);
// arr = [1 2 3 4] (it's a column vector, though shown as a row vector here)
At each iteration of the loop, I have to remove a value from the array. The value to be removed depends on a computation, the result of which is not always the same. So in 4 iterations of the loop, the process can look like:
// Iter 1: arr = [1 3 4] (removed 2)
// Iter 2: arr = [1 4] (removed 3)
// Iter 3: arr = [4] (removed 1)
// Iter 4: arr = empty (removed 4)
I was wondering if someone had a suggestion on how best to accomplish this. I have a technique working that requires a conversion of arr to a C-array, removing an element, and re-conversion back to a device af::array. Is there a more idiomatic/efficient way to accomplish this?