pentapy.tools.diag_indices
- pentapy.tools.diag_indices(n, offset=0)[source]
Get indices for the main or minor diagonals of a matrix.
This returns a tuple of indices that can be used to access the main diagonal of an array a with
a.ndim == 2
dimensions and shape (n, n).- Parameters
n (int) – The size, along each dimension, of the arrays for which the returned indices can be used.
offset (int, optional) – The diagonal offset.
- Returns
idx (
numpy.ndarray
) – row indicesidy (
numpy.ndarray
) – col indices