Commit bf190bbd by Philipp Arras

### Unify notation in conjugate gradient and NewtonCG

parent b2fa7769
Pipeline #52268 passed with stages
in 8 minutes and 32 seconds
 ... @@ -74,27 +74,27 @@ class ConjugateGradient(Minimizer): ... @@ -74,27 +74,27 @@ class ConjugateGradient(Minimizer): if previous_gamma == 0: if previous_gamma == 0: return energy, controller.CONVERGED return energy, controller.CONVERGED iter = 0 ii = 0 while True: while True: q = energy.apply_metric(d) q = energy.apply_metric(d) ddotq = d.vdot(q).real curv = d.vdot(q).real if ddotq == 0.: if curv == 0.: logger.error("Error: ConjugateGradient: ddotq==0.") logger.error("Error: ConjugateGradient: curv==0.") return energy, controller.ERROR return energy, controller.ERROR alpha = previous_gamma/ddotq alpha = previous_gamma/curv if alpha < 0: if alpha < 0: logger.error("Error: ConjugateGradient: alpha<0.") logger.error("Error: ConjugateGradient: alpha<0.") return energy, controller.ERROR return energy, controller.ERROR iter += 1 ii += 1 if iter < self._nreset: if ii < self._nreset: r = r - q*alpha r = r - q*alpha energy = energy.at_with_grad(energy.position - alpha*d, r) energy = energy.at_with_grad(energy.position - alpha*d, r) else: else: energy = energy.at(energy.position - alpha*d) energy = energy.at(energy.position - alpha*d) r = energy.gradient r = energy.gradient iter = 0 ii = 0 s = r if preconditioner is None else preconditioner(r) s = r if preconditioner is None else preconditioner(r) ... ...