MCPcopy Create free account
hub / github.com/numpy/numpy / matrix_power

Function matrix_power

numpy/array_api/linalg.py:184–196  ·  view source on GitHub ↗

Array API compatible wrapper for :py:func:`np.matrix_power `. See its docstring for more information.

(x: Array, n: int, /)

Source from the content-addressed store, hash-verified

182
183
184def 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
199def matrix_rank(x: Array, /, *, rtol: Optional[Union[float, Array]] = None) -> Array:

Callers

nothing calls this directly

Calls 1

_newMethod · 0.80

Tested by

no test coverage detected