jax.numpy.ravel_multi_indexΒΆ
-
jax.numpy.
ravel_multi_index
(multi_index, dims, mode='raise', order='C')[source]ΒΆ Converts a tuple of index arrays into an array of flat indices, applying boundary modes to the multi-index.
LAX-backend implementation of
ravel_multi_index()
. Original docstring below.ravel_multi_index(multi_index, dims, mode=βraiseβ, order=βCβ)
- Parameters
multi_index (tuple of array_like) β A tuple of integer arrays, one array for each dimension.
dims (tuple of ints) β The shape of array into which the indices from
multi_index
apply.mode ({'raise', 'wrap', 'clip'}, optional) β Specifies how out-of-bounds indices are handled. Can specify either one mode or a tuple of modes, one mode per index.
order ({'C', 'F'}, optional) β Determines whether the multi-index should be viewed as indexing in row-major (C-style) or column-major (Fortran-style) order.
- Returns
raveled_indices β An array of indices into the flattened version of an array of dimensions
dims
.- Return type
See also
Notes
New in version 1.6.0.
Examples
>>> arr = np.array([[3,6,6],[4,5,1]]) >>> np.ravel_multi_index(arr, (7,6)) array([22, 41, 37]) >>> np.ravel_multi_index(arr, (7,6), order='F') array([31, 41, 13]) >>> np.ravel_multi_index(arr, (4,6), mode='clip') array([22, 23, 19]) >>> np.ravel_multi_index(arr, (4,4), mode=('clip','wrap')) array([12, 13, 13])
>>> np.ravel_multi_index((3,1,4,1), (6,7,8,9)) 1621