@@ -21,7 +21,8 @@ def eigenvalues_np(A, symmetric=True):
21
21
"""
22
22
Compute the eigenvalues of a square matrix using NumPy's `eig` or `eigh` function.
23
23
24
- This function checks if the input matrix is square (and is actually a matrix) using 'check_square_matrix', and then computes its eigenvalues.
24
+ This function checks if the input matrix is square (and is actually a matrix) using
25
+ 'check_square_matrix', and then computes its eigenvalues.
25
26
If the matrix is symmetric, it uses `eigh` (which is more efficient for symmetric matrices).
26
27
Otherwise, it uses `eig`.
27
28
@@ -80,13 +81,13 @@ def eigenvalues_cp(A):
80
81
81
82
This function checks if the input matrix is square and symmetric, then computes its eigenvalues using
82
83
CuPy's sparse linear algebra solvers. It uses `eigsh` for more efficient computation.
83
- IMPORTANT: it important to underline a couple of things regarding this function:
84
- - installing using the command 'python -m pip install cupy-cuda12x' does not allow, for some reason,
85
- to import cupyx.scipy.sparse.linalg, and it necessary to import the
86
- function manually form the source code. The problem can be observed using python3.10, while for
87
- python3.12 things seem to work.
88
- - the eighs function in this case does not allow to compute *all* the eigenvalues, but only a number
89
- $m<n$, so here just a reduced portion is computed (starting form the ones which are greater in magnitude).
84
+ IMPORTANT: it important to underline a couple of things regarding this function. The first one is that,
85
+ installing using the command 'python -m pip install cupy-cuda12x', does not allow, for some reason,
86
+ to import cupyx.scipy.sparse.linalg, and it necessary to import the function manually form the source
87
+ code. The problem can be observed using python3.10, while for python3.12 things seem to work.
88
+ The second one is that the 'eighs' function in this case does not allow to compute *all* the eigenvalues,
89
+ but only a number $m<n$, so here just a reduced portion is computed (starting form the ones which are
90
+ greater in magnitude).
90
91
91
92
Args:
92
93
A (cpsp.spmatrix): A square sparse matrix whose eigenvalues are to be computed.
@@ -99,7 +100,7 @@ def eigenvalues_cp(A):
99
100
ValueError: If number of rows != number of columns.
100
101
"""
101
102
check_symm_square (A )
102
- k = 5 if A .shape [0 ] > 5 else A .shape [0 ] - 2
103
+ k = 6 if A .shape [0 ] > 5 else A .shape [0 ] - 2
103
104
eigenvalues , _ = cp_eigsh (A , k = k )
104
105
return eigenvalues
105
106
0 commit comments