sqrtm increases precision, so cast back to double

This commit is contained in:
Jan Petykiewicz 2023-05-23 12:56:38 -07:00
parent be620f7137
commit d8ec46674d

View File

@ -578,7 +578,7 @@ def eigsolve(
trace_U = real(trace(U)) trace_U = real(trace(U))
if trace_U > 1e8 * num_modes: if trace_U > 1e8 * num_modes:
Z = Z @ scipy.linalg.sqrtm(U).conj().T Z = Z @ scipy.linalg.sqrtm(U).astype(numpy.complex128).conj().T
prev_traceGtKG = 0 prev_traceGtKG = 0
continue continue
break break
@ -741,7 +741,7 @@ def eigsolve(
# Recover eigenvectors from Z # Recover eigenvectors from Z
# #
U = numpy.linalg.inv(ZtZ) U = numpy.linalg.inv(ZtZ)
Y = Z @ scipy.linalg.sqrtm(U) Y = Z @ scipy.linalg.sqrtm(U).astype(numpy.complex128)
W = Y.conj().T @ (scipy_op @ Y.copy()) W = Y.conj().T @ (scipy_op @ Y.copy())
eigvals, W_eigvecs = numpy.linalg.eig(W) eigvals, W_eigvecs = numpy.linalg.eig(W)