Skip to content

Commit

Permalink
further performance tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
lehner committed Sep 22, 2024
1 parent 85b8d87 commit 69bda77
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
13 changes: 9 additions & 4 deletions lib/gpt/qcd/pseudofermion/action/exact_one_flavor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ class exact_one_flavor_ratio(action_base):
def __init__(self, fermion, m1, m2, inverter):
self.m1 = m1
self.m2 = m2
super().__init__([fermion(m1, m2), fermion(m1, m1)], inverter, fermion)
M12 = fermion(m1, m2)
M11 = fermion(m1, m1)
super().__init__([M12, M11], inverter, fermion)
self.P12 = M12.propagator(inverter)
self.P11 = M11.propagator(inverter)


def matrix(self, fields):

Check failure on line 38 in lib/gpt/qcd/pseudofermion/action/exact_one_flavor.py

View workflow job for this annotation

GitHub Actions / lint

E303:too many blank lines (2)
M12, M11, U, phi = self._updated(fields)

P12 = M12.propagator(self.inverter)
P11 = M11.propagator(self.inverter)

P12 = self.P12
P11 = self.P11
m1 = self.m1
m2 = self.m2

Expand Down
9 changes: 6 additions & 3 deletions lib/gpt/qcd/pseudofermion/action/two_flavor.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,17 @@ class two_flavor_ratio_base(action_base):
def __init__(self, M, inverter, operator):
assert len(M) == 2
super().__init__(M, inverter, operator)
M1, M2 = M
self.inv_MMdag_M1 = inverter(operator.MMdag(M1))
self.inv_MMdag_M2 = inverter(operator.MMdag(M2))

def __call__(self, fields):
M1, M2, U, phi = self._updated(fields)

psi = g.lattice(phi)
psi @= self.operator.M(M2) * phi
chi = g.lattice(phi)
chi @= self.inverter(self.operator.MMdag(M1)) * psi
chi @= self.inv_MMdag_M1 * psi
return g.inner_product(psi, chi).real

def draw(self, fields, rng):
Expand All @@ -155,7 +158,7 @@ def draw(self, fields, rng):
# phi^dag M2dag (M1 M1dag)^-1 M2 phi
# eta = M1^-1 M2 phi
chi = g.lattice(phi)
chi @= self.inverter(self.operator.MMdag(M2)) * self.operator.M(M1) * eta
chi @= self.inv_MMdag_M2 * self.operator.M(M1) * eta
phi @= self.operator.Mdag(M2) * chi
return g.norm2(eta)

Expand All @@ -167,7 +170,7 @@ def gradient(self, fields, dfields):
psi = g.lattice(phi)
psi @= self.operator.M(M2) * phi
chi = g.lattice(phi)
chi @= self.inverter(self.operator.MMdag(M1)) * psi
chi @= self.inv_MMdag_M1 * psi
psi @= self.operator.Mdag(M1) * chi

self._accumulate(frc, self.operator.Mderiv(M2)(chi, phi), +1)
Expand Down

0 comments on commit 69bda77

Please sign in to comment.