Array API compatible wrapper for :py:func:`np.matrix_power `. See its docstring for more information.
(x: Array, n: int, /)
| 182 | |
| 183 | |
| 184 | def matrix_power(x: Array, n: int, /) -> Array: |
| 185 | """ |
| 186 | Array API compatible wrapper for :py:func:`np.matrix_power <numpy.matrix_power>`. |
| 187 | |
| 188 | See its docstring for more information. |
| 189 | """ |
| 190 | # Note: the restriction to floating-point dtypes only is different from |
| 191 | # np.linalg.matrix_power. |
| 192 | if x.dtype not in _floating_dtypes: |
| 193 | raise TypeError('Only floating-point dtypes are allowed for the first argument of matrix_power') |
| 194 | |
| 195 | # np.matrix_power already checks if n is an integer |
| 196 | return Array._new(np.linalg.matrix_power(x._array, n)) |
| 197 | |
| 198 | # Note: the keyword argument name rtol is different from np.linalg.matrix_rank |
| 199 | def matrix_rank(x: Array, /, *, rtol: Optional[Union[float, Array]] = None) -> Array: |