We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
&[[usize]; ndim]
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 ?
A
ndim
&[usize]
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 ?
ndarray
The text was updated successfully, but these errors were encountered:
It seems this question is duplicated with #526 ... but can we do it now?
Sorry, something went wrong.
I've tested via julia, this approach is a bit slower than direct loop sum due to the extra allocation. Maybe I should close this issue.
julia
No branches or pull requests
Hi, I just came across a problem with the slicing:
Suppose we have an array
A
ofndim
dimensions and&[usize]
s containing indices of each dimension, how to operateA
with the indices ?For example, in numpy, we can
Is it possible to do the same thing within
ndarray
in an elegant way ?The text was updated successfully, but these errors were encountered: