Array API compatible wrapper for :py:func:`np.linalg.norm `. See its docstring for more information.
(x: Array, /, *, keepdims: bool = False, ord: Optional[Union[int, float, Literal['fro', 'nuc']]] = 'fro')
| 168 | # -np.inf, 'fro', 'nuc']]], but Literal does not support floating-point |
| 169 | # literals. |
| 170 | def matrix_norm(x: Array, /, *, keepdims: bool = False, ord: Optional[Union[int, float, Literal['fro', 'nuc']]] = 'fro') -> Array: |
| 171 | """ |
| 172 | Array API compatible wrapper for :py:func:`np.linalg.norm <numpy.linalg.norm>`. |
| 173 | |
| 174 | See its docstring for more information. |
| 175 | """ |
| 176 | # Note: the restriction to floating-point dtypes only is different from |
| 177 | # np.linalg.norm. |
| 178 | if x.dtype not in _floating_dtypes: |
| 179 | raise TypeError('Only floating-point dtypes are allowed in matrix_norm') |
| 180 | |
| 181 | return Array._new(np.linalg.norm(x._array, axis=(-2, -1), keepdims=keepdims, ord=ord)) |
| 182 | |
| 183 | |
| 184 | def matrix_power(x: Array, n: int, /) -> Array: |