Skip to content

Commit

Permalink
Andrea's suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomello committed Sep 19, 2024
1 parent bfc0bc1 commit 065c53c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
9 changes: 8 additions & 1 deletion src/qibo/backends/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,14 @@ def calculate_matrix_power(
self, matrix, power: Union[float, int]
): # pragma: no cover
"""Calculates the (fractional) ``power`` :math:`\\alpha` of ``matrix`` :math:`A`,
i.e. :math:`A^{\\alpha}`."""
i.e. :math:`A^{\\alpha}`.
.. note::
For the ``pytorch`` backend, this method relies on a copy of the original tensor.
This may break the gradient flow. For the GPU backends (i.e. ``cupy`` and
``cuquantum``), this method falls back to CPU whenever ``power`` is not
an integer.
"""
raise_error(NotImplementedError)

@abc.abstractmethod
Expand Down
7 changes: 0 additions & 7 deletions src/qibo/quantum_info/linalg_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,6 @@ def matrix_power(matrix, power: Union[float, int], backend=None):
Returns:
ndarray: matrix power :math:`A^{\\alpha}`.
"""

if not isinstance(power, (float, int)):
raise_error(
TypeError,
f"``power`` must be either float or int, but it is type {type(power)}.",
)

backend = _check_backend(backend)

return backend.calculate_matrix_power(matrix, power)

0 comments on commit 065c53c

Please sign in to comment.