Array API compatible wrapper for :py:func:`np.linalg.cholesky `. See its docstring for more information.
(x: Array, /, *, upper: bool = False)
| 43 | # Note: the inclusion of the upper keyword is different from |
| 44 | # np.linalg.cholesky, which does not have it. |
| 45 | def cholesky(x: Array, /, *, upper: bool = False) -> Array: |
| 46 | """ |
| 47 | Array API compatible wrapper for :py:func:`np.linalg.cholesky <numpy.linalg.cholesky>`. |
| 48 | |
| 49 | See its docstring for more information. |
| 50 | """ |
| 51 | # Note: the restriction to floating-point dtypes only is different from |
| 52 | # np.linalg.cholesky. |
| 53 | if x.dtype not in _floating_dtypes: |
| 54 | raise TypeError('Only floating-point dtypes are allowed in cholesky') |
| 55 | L = np.linalg.cholesky(x._array) |
| 56 | if upper: |
| 57 | U = Array._new(L).mT |
| 58 | if U.dtype in [complex64, complex128]: |
| 59 | U = conj(U) |
| 60 | return U |
| 61 | return Array._new(L) |
| 62 | |
| 63 | # Note: cross is the numpy top-level namespace, not np.linalg |
| 64 | def cross(x1: Array, x2: Array, /, *, axis: int = -1) -> Array: |