Closed
Description
Hi, I just came across a problem with the slicing:
Suppose we have an array A
of ndim
dimensions and &[usize]
s containing indices of each dimension, how to operate A
with the indices ?
For example, in numpy, we can
A = np.arange(27).reshape(3, 3, 3)
id_dim1 = [0, 2]
id_dim2 = [0, 1]
id_dim3 = [1, 2]
A[id_dim1, id_dim2, id_dim3] *= 2
# produces
A = array([[[ 0, 2, 2],
[ 3, 4, 5],
[ 6, 7, 8]],
[[ 9, 10, 11],
[12, 13, 14],
[15, 16, 17]],
[[18, 19, 20],
[21, 22, 46],
[24, 25, 26]]])
Is it possible to do the same thing within ndarray
in an elegant way ?
Metadata
Metadata
Assignees
Labels
No labels