Array API compatible wrapper for :py:func:`np.diagonal `. See its docstring for more information.
(x: Array, /, *, offset: int = 0)
| 93 | |
| 94 | # Note: diagonal is the numpy top-level namespace, not np.linalg |
| 95 | def diagonal(x: Array, /, *, offset: int = 0) -> Array: |
| 96 | """ |
| 97 | Array API compatible wrapper for :py:func:`np.diagonal <numpy.diagonal>`. |
| 98 | |
| 99 | See its docstring for more information. |
| 100 | """ |
| 101 | # Note: diagonal always operates on the last two axes, whereas np.diagonal |
| 102 | # operates on the first two axes by default |
| 103 | return Array._new(np.diagonal(x._array, offset=offset, axis1=-2, axis2=-1)) |
| 104 | |
| 105 | |
| 106 | def eigh(x: Array, /) -> EighResult: |