Skip to content

Commit

Permalink
force dot product as scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeolson committed Oct 12, 2023
1 parent be056dc commit 6538439
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
9 changes: 1 addition & 8 deletions pyamg/multilevel.py
Expand Up @@ -3,6 +3,7 @@
from warnings import warn

import scipy as sp
from scipy.linalg import pinv
import scipy.sparse.linalg as sla
from scipy.sparse.linalg import LinearOperator
import numpy as np
Expand All @@ -13,14 +14,6 @@
from .relaxation import smoothing
from .util import upcast

# hack to compare the version of scipy
# int(''.join('1.7'.split('.')[:2])) = 17
spversion = sp.__version__
if int(''.join(spversion.split('.')[:2])) >= 17:
from scipy.linalg import pinv # pylint: disable=ungrouped-imports
else:
from scipy.linalg import pinv2 as pinv # pylint: disable=no-name-in-module


class MultilevelSolver:
"""Stores multigrid hierarchy and implements the multigrid cycle.
Expand Down
8 changes: 4 additions & 4 deletions pyamg/util/linalg.py
Expand Up @@ -526,11 +526,11 @@ def ishermitian(A, fast_check=True, tol=1e-6, verbose=False):
A = np.asarray(A)

if fast_check:
x = np.random.rand(A.shape[0], 1)
y = np.random.rand(A.shape[0], 1)
x = np.random.rand(A.shape[0])
y = np.random.rand(A.shape[0])
if A.dtype == complex:
x = x + 1.0j*np.random.rand(A.shape[0], 1)
y = y + 1.0j*np.random.rand(A.shape[0], 1)
x = x + 1.0j*np.random.rand(A.shape[0])
y = y + 1.0j*np.random.rand(A.shape[0])
xAy = np.dot((A.dot(x)).conjugate().T, y)
xAty = np.dot(x.conjugate().T, A.dot(y))
diff = float(np.abs(xAy - xAty) / np.sqrt(np.abs(xAy*xAty)))
Expand Down

0 comments on commit 6538439

Please sign in to comment.