Commit 10ad6730 authored by Joseph Weston's avatar Joseph Weston
Browse files

refactor to reduce code duplication

parent 180855fe
...@@ -989,9 +989,8 @@ class GreensFunction(BlockResult): ...@@ -989,9 +989,8 @@ class GreensFunction(BlockResult):
result = np.trace(attdagainv).real result = np.trace(attdagainv).real
if lead_out == lead_in: if lead_out == lead_in:
# For reflection we have to be more careful # For reflection we have to be more careful
gamma = 1j * (self.lead_info[lead_in] -
self.lead_info[lead_in].conj().T)
sigma = self.lead_info[lead_in] sigma = self.lead_info[lead_in]
gamma = 1j * (sigma - sigma.conj().T)
gf = self.submatrix(lead_out, lead_in) gf = self.submatrix(lead_out, lead_in)
# The number of channels is given by the number of # The number of channels is given by the number of
...@@ -1000,9 +999,10 @@ class GreensFunction(BlockResult): ...@@ -1000,9 +999,10 @@ class GreensFunction(BlockResult):
# Golub; van Loan, chapter 5.5.8 # Golub; van Loan, chapter 5.5.8
# We use ‖Σ‖, not ‖Γ‖, for the tolerance as ‖Γ‖~0 when there # We use ‖Σ‖, not ‖Γ‖, for the tolerance as ‖Γ‖~0 when there
# are no open modes. # are no open modes.
eps = np.finfo(gamma.dtype).eps * 1000 eps = (
N = np.sum(np.linalg.eigvalsh(gamma) > 1e3 * np.finfo(gamma.dtype).eps * np.linalg.norm(sigma, np.inf)
eps * np.linalg.norm(sigma, np.inf)) )
N = np.sum(np.linalg.eigvalsh(gamma) > eps)
result += 2 * np.trace(np.dot(gamma, gf)).imag + N result += 2 * np.trace(np.dot(gamma, gf)).imag + N
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment