summaryrefslogtreecommitdiff
path: root/stokes.hpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2021-02-17 16:14:33 +0100
committerJaron Kent-Dobias <jaron@kent-dobias.com>2021-02-17 16:14:33 +0100
commit12f15f49cd8cc4ab9c809700e8cb88a0efe198d8 (patch)
tree3b7e973ce93ce942563a55363c3edd8c883da48d /stokes.hpp
parent95df02c90a455c2e539e795acb1921b688e8bc66 (diff)
downloadcode-12f15f49cd8cc4ab9c809700e8cb88a0efe198d8.tar.gz
code-12f15f49cd8cc4ab9c809700e8cb88a0efe198d8.tar.bz2
code-12f15f49cd8cc4ab9c809700e8cb88a0efe198d8.zip
Rearranged some functions among files, and wrote the normalize function to take generic Eigen expressions.
Diffstat (limited to 'stokes.hpp')
-rw-r--r--stokes.hpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/stokes.hpp b/stokes.hpp
index 95bb9c4..117f4de 100644
--- a/stokes.hpp
+++ b/stokes.hpp
@@ -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;