pytutorial/numpy/diagonal_triangles
David Rotermund 5fff0a6aef
Create README.md
Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
2023-12-30 19:03:21 +01:00
..
README.md Create README.md 2023-12-30 19:03:21 +01:00

Dealing with the main diagonal / triangles of a matrix

{:.no_toc}

* TOC {:toc}

Top

Questions to David Rotermund

{: .topic-optional} This is an optional topic!

numpy.fill_diagonal

numpy.fill_diagonal(a, val, wrap=False)

Fill the main diagonal of the given array of any dimensionality.

For an array a with a.ndim >= 2, the diagonal is the list of locations with indices a[i, ..., i] all identical. This function modifies the input array in-place, it does not return a value.

numpy.diag_indices

numpy.diag_indices(n, ndim=2)

Return the indices to access the main diagonal of an array.

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, …, n). For a.ndim = 2 this is the usual diagonal, for a.ndim > 2 this is the set of indices to access a[i, i, ..., i] for i = [0..n-1].

numpy.diag_indices_from

numpy.diag_indices_from(arr)

Return the indices to access the main diagonal of an n-dimensional array.