Skip to main content

diag_indices

Return the indices to access the main diagonal of an array with ndim dimensions.
Returns: NDArray[] — Tuple of ndim index arrays, each of length n, that together select the main diagonal.

diag_indices_from

Return the indices to access the main diagonal of a given array.
Returns: NDArray[] — Tuple of index arrays that select the main diagonal of arr.

tril_indices

Return the indices for the lower triangle of an (n, m) array.
Returns: [NDArray, NDArray] — Row and column index arrays for the lower triangle.

tril_indices_from

Return the indices for the lower triangle of a given array.
Returns: [NDArray, NDArray] — Row and column index arrays for the lower triangle.

triu_indices

Return the indices for the upper triangle of an (n, m) array.
Returns: [NDArray, NDArray] — Row and column index arrays for the upper triangle.

triu_indices_from

Return the indices for the upper triangle of a given array.
Returns: [NDArray, NDArray] — Row and column index arrays for the upper triangle.

mask_indices

Return the indices to access an (n, n) array given a masking function.
Returns: [NDArray, NDArray] — Row and column index arrays where mask_func returns non-zero values.

indices

Return an array representing the indices of a grid.
Returns: NDArray dense grid with shape [N, ...dimensions].

ix_

Construct an open mesh from multiple sequences. This is useful for constructing index arrays for cross-indexing.
Returns: NDArray[] — Tuple of N-D arrays with shapes (len(a0), 1, ..., 1), (1, len(a1), 1, ..., 1), etc.

fill_diagonal

Fill the main diagonal of the given array in-place.
Returns: void — The array a is modified in-place.