Hello,

I was wondering whether anyone has had to deal with “extra dimensions” while using ChartesianIndices. In particular, I am tempted to implement the following but it doesn’t work. Thanks in advance!

N = 2; M = 2; L = 2; K = 2;

X = rand(N,M);

Y = rand(N,M,L);

Z = rand(N,M,L,K);function do_thing(X, Y, Z, k)

@inbounds for Index in CartesianIndices(X)

xi = X[Index];

for l = 1:L

Z[:, :, l, k] = xi + Y[Index, l];

end

end

return Z;

end