discretize.utils.ind2sub(shape, inds)[source]#

Return subscripts of tensor grid elements from indices.

This function is a wrapper for numpy.unravel_index() with a hard-coded Fortran order.

Consider the \(n^{th}\) element of a tensor grid with N elements. The position of this element in the tensor grid can also be defined by subscripts (i,j,k). For an array containing the indices for a set of tensor elements, this function returns the corresponding subscripts.

shape(dim) tuple of int

Defines the shape of the tensor (1D, 2D or 3D).

indsarray_like of int

The indices of the tensor elements whose subscripts you want returned.

(dim) tuple of numpy.ndarray

Corresponding subscipts for the indices provided. The output is a tuple containing 1D integer arrays for the i, j and k subscripts, respectively. The output array will match the shape of the inds input.