Commit 894cf79d authored by Martin Reinecke's avatar Martin Reinecke
Browse files

performance tweak

parent 55be306e
...@@ -89,8 +89,14 @@ class ConjugateGradient(Minimizer): ...@@ -89,8 +89,14 @@ class ConjugateGradient(Minimizer):
if alpha < 0: if alpha < 0:
return energy, controller.ERROR return energy, controller.ERROR
r -= q * alpha # MR: BLAS candidate
energy = energy.at_with_grad(energy.position+d*alpha, -r) q *= alpha
r -= q
# MR: BLAS candidate
tpos = d*alpha
tpos += energy.position
energy = energy.at_with_grad(tpos, -r)
if self._preconditioner is not None: if self._preconditioner is not None:
s = self._preconditioner(r) s = self._preconditioner(r)
...@@ -110,6 +116,8 @@ class ConjugateGradient(Minimizer): ...@@ -110,6 +116,8 @@ class ConjugateGradient(Minimizer):
if status != controller.CONTINUE: if status != controller.CONTINUE:
return energy, status return energy, status
d = s + d * max(0, gamma/previous_gamma) # MR: BLAS candidate
d *= max(0, gamma/previous_gamma)
d += s
previous_gamma = gamma previous_gamma = gamma
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