From e1ac241062fbe4632e58ec26052d152f6e5aba4b Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Sun, 25 Aug 2024 17:08:52 +0200 Subject: Small cosmetic tweaks. --- topology.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'topology.cpp') diff --git a/topology.cpp b/topology.cpp index 1d46649..129957e 100644 --- a/topology.cpp +++ b/topology.cpp @@ -103,8 +103,8 @@ public: return {∂L, ∂∂L}; } - Vector newtonMethod(const Vector& v0, Real γ = 1, Real ε = 1e-12, unsigned maxSteps = 1e2) const { - Vector v = v0; + Vector newtonMethod(const Vector& v₀, Real γ = 1, Real ε = 1e-12, unsigned maxSteps = 1e3) const { + Vector v = v₀; unsigned steps = 0; Vector ∂L; @@ -112,6 +112,7 @@ public: while (std::tie(∂L, ∂∂L) = ∂L_∂∂L(v), ∂L.squaredNorm() > ε) { if (v.tail(M + 1).squaredNorm() > 1 / ε || steps > N * maxSteps) { + std::cerr << "Quit Newton method algorithm after " << steps << "steps" << std::endl; return Vector::Zero(N + M + 1); } @@ -124,18 +125,18 @@ public: return v; } - Vector randomStationaryPoint(Rng& r, Real γ = 1, Real ε = 1e-12, unsigned maxTries = 1e1) const { + Vector randomStationaryPoint(Rng& r, Real γ = 1, Real ε = 1e-12, unsigned maxTries = 1e2) const { Vector v = Vector::Zero(N + M + 1); unsigned tries = 0; while (v.squaredNorm() < ε && tries < maxTries) { - Vector v0(N + M + 1); - for (Real& v0ᵢ : v0) { - v0ᵢ = r.variate(); + Vector v₀(N + M + 1); + for (Real& v₀ᵢ : v₀) { + v₀ᵢ = r.variate(); } - v0.head(N) = normalize(v0.head(N)); + v₀.head(N) = normalize(v₀.head(N)); - v = newtonMethod(v0, γ, ε); + v = newtonMethod(v₀, γ, ε); tries++; } -- cgit v1.2.3-70-g09d2