Array API compatible wrapper for :py:func:`np.linalg.pinv `. See its docstring for more information.
(x: Array, /, *, rtol: Optional[Union[float, Array]] = None)
| 245 | |
| 246 | # Note: the keyword argument name rtol is different from np.linalg.pinv |
| 247 | def pinv(x: Array, /, *, rtol: Optional[Union[float, Array]] = None) -> Array: |
| 248 | """ |
| 249 | Array API compatible wrapper for :py:func:`np.linalg.pinv <numpy.linalg.pinv>`. |
| 250 | |
| 251 | See its docstring for more information. |
| 252 | """ |
| 253 | # Note: the restriction to floating-point dtypes only is different from |
| 254 | # np.linalg.pinv. |
| 255 | if x.dtype not in _floating_dtypes: |
| 256 | raise TypeError('Only floating-point dtypes are allowed in pinv') |
| 257 | |
| 258 | # Note: this is different from np.linalg.pinv, which does not multiply the |
| 259 | # default tolerance by max(M, N). |
| 260 | if rtol is None: |
| 261 | rtol = max(x.shape[-2:]) * np.finfo(x.dtype).eps |
| 262 | return Array._new(np.linalg.pinv(x._array, rcond=rtol)) |
| 263 | |
| 264 | def qr(x: Array, /, *, mode: Literal['reduced', 'complete'] = 'reduced') -> QRResult: |
| 265 | """ |