diff options
Diffstat (limited to 'stokes.hpp')
-rw-r--r-- | stokes.hpp | 16 |
1 files changed, 4 insertions, 12 deletions
@@ -1,11 +1,6 @@ #include "p-spin.hpp" template <class Scalar> -Vector<Scalar> zDot(const Vector<Scalar>& z, const Vector<Scalar>& dH) { - return -dH.conjugate() + (dH.dot(z) / z.squaredNorm()) * z.conjugate(); -} - -template <class Scalar> double segmentCost(const Vector<Scalar>& z, const Vector<Scalar>& dz, const Vector<Scalar>& dH) { Vector<Scalar> zD = zDot(z, dH); return 1.0 - pow(real(zD.dot(dz)), 2) / zD.squaredNorm() / dz.squaredNorm(); @@ -68,8 +63,7 @@ class Rope { Rope(unsigned N, const Vector<Scalar>& z1, const Vector<Scalar>& z2) : z(N + 2) { for (unsigned i = 0; i < N + 2; i++) { - z[i] = z1 + (z2 - z1) * ((double)i / (N + 1.0)); - z[i] = normalize(z[i]); + z[i] = normalize(z1 + (z2 - z1) * ((double)i / (N + 1.0))); } } @@ -106,8 +100,7 @@ class Rope { while (rNew.cost(J) >= this->cost(J)) { for (unsigned i = 1; i < z.size() - 1; i++) { - rNew.z[i] = z[i] - δ * Δz[i].conjugate(); - rNew.z[i] = normalize(rNew.z[i]); + rNew.z[i] = normalize(z[i] - δ * Δz[i].conjugate()); } δ /= 2; @@ -144,8 +137,7 @@ class Rope { Vector<Scalar> δz = z[pos] - z[pos - 1]; - zNew[i] = z[pos] - (a - b) / δz.norm() * δz; - zNew[i] = normalize(zNew[i]); + zNew[i] = normalize(z[pos] - (a - b) / δz.norm() * δz); } z = zNew; @@ -192,7 +184,7 @@ class Rope { } for (unsigned i = 0; i < z.size() - 1; i++) { - r.z[2 * i + 1] = normalize(((z[i] + z[i + 1]) / 2.0).eval()); + r.z[2 * i + 1] = normalize(((z[i] + z[i + 1]) / 2.0)); } return r; |