File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 2
2
from typing import Tuple , Union
3
3
import numpy .typing as npt
4
4
5
+
5
6
def power_iteration (
6
7
input_matrix : npt .NDArray [Union [np .float64 , np .complex128 ]],
7
8
vector : npt .NDArray [Union [np .float64 , np .complex128 ]],
@@ -42,12 +43,16 @@ def power_iteration(
42
43
# Ensure proper dimensionality.
43
44
assert N == np .shape (vector )[0 ], "Vector must be compatible with matrix dimensions."
44
45
# Ensure inputs are either both complex or both real
45
- assert np .iscomplexobj (input_matrix ) == np .iscomplexobj (vector ), "Both inputs must be either real or complex."
46
-
46
+ assert np .iscomplexobj (input_matrix ) == np .iscomplexobj (
47
+ vector
48
+ ), "Both inputs must be either real or complex."
49
+
47
50
is_complex = np .iscomplexobj (input_matrix )
48
51
if is_complex :
49
52
# Ensure complex input_matrix is Hermitian (A == A*)
50
- assert np .array_equal (input_matrix , input_matrix .conj ().T ), "Input matrix must be Hermitian if complex."
53
+ assert np .array_equal (
54
+ input_matrix , input_matrix .conj ().T
55
+ ), "Input matrix must be Hermitian if complex."
51
56
52
57
convergence = False
53
58
lambda_previous = 0.0
You can’t perform that action at this time.
0 commit comments