summaryrefslogtreecommitdiff
path: root/p-spin.hpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2021-02-17 15:46:00 +0100
committerJaron Kent-Dobias <jaron@kent-dobias.com>2021-02-17 15:46:00 +0100
commit95df02c90a455c2e539e795acb1921b688e8bc66 (patch)
tree7af564d926b6d233432029c030f25f605c144f68 /p-spin.hpp
parent81cc0094a2c7478144702e1532bcb067faaebf26 (diff)
downloadcode-95df02c90a455c2e539e795acb1921b688e8bc66.tar.gz
code-95df02c90a455c2e539e795acb1921b688e8bc66.tar.bz2
code-95df02c90a455c2e539e795acb1921b688e8bc66.zip
Algorithmic tweaks to rope relaxation now suceeds in finding Stokes lines relatively quickly.
Diffstat (limited to 'p-spin.hpp')
-rw-r--r--p-spin.hpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/p-spin.hpp b/p-spin.hpp
index 13fbd98..480b3ca 100644
--- a/p-spin.hpp
+++ b/p-spin.hpp
@@ -21,6 +21,11 @@ std::tuple<Scalar, Vector<Scalar>, Matrix<Scalar>> hamGradHess(const Tensor<Scal
}
template <class Scalar>
+Vector<Scalar> normalize(const Vector<Scalar>& z) {
+ return z * sqrt((double)z.size() / (Scalar)(z.transpose() * z));
+}
+
+template <class Scalar>
Vector<Scalar> project(const Vector<Scalar>& z, const Vector<Scalar>& x) {
Scalar xz = x.transpose() * z;
return x - (xz / z.squaredNorm()) * z.conjugate();