We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent efc22df commit 1942d78Copy full SHA for 1942d78
mpqp/tools/maths.py
@@ -133,7 +133,7 @@ def is_unitary(matrix: Matrix) -> bool:
133
134
135
@typechecked
136
-def is_diagonal(matrix: Matrix):
+def is_diagonal(matrix: Union[Matrix, np.ndarray]):
137
"""Checks whether the square matrix in parameter is diagonal.
138
139
Args:
@@ -154,7 +154,11 @@ def is_diagonal(matrix: Matrix):
154
i, j = matrix.shape
155
if i != j:
156
raise ValueError(
157
- "The input matrix is not square. Dimensions = (" + i + ", " + j + ")."
+ "The input matrix is not square. Dimensions = ("
158
+ + str(i)
159
+ + ", "
160
+ + str(j)
161
+ + ")."
162
)
163
test = matrix.reshape(-1)[:-1].reshape(i - 1, j + 1)
164
return not np.any(test[:, 1:])
0 commit comments