Dear Julia Community,
This is my first time posting, so I hope I meet the standards put in place. Thank you for all of this btw!!
Problem: Let me illustrate with an example. For a 3D array, I’d like to remove any component (i,j,k) where two of the indices equal 1 e.g., i=1, j=1, k=5 or i=3, j=1, k=1 and create a vector of the remaining elements. I’d also like to store the removed elements and the respective indices. I need an implementation for N > 2, so more general. I can’t say I have a MWE, but I started to write this:
grid = 10
A = zeros(grid, grid, grid)
dimension = ndims(A)
colons_upper = ()
colons_lower = ntuple(_ -> (:), dimension)
condition = 1:grid .!= 1
for d in axes(colons_lower)
A = A[colons_upper..., condition, colons_lower...]
colons_upper = tuple(colons_upper..., :)
colons_lower = ntuple(_ -> (:), dimension - d)
end
Issue is, this removes the first row of every slice, first column of every slice thereafter, and then, the first slice … Thank you in advance and please let me know if I didn’t meet the posting standards