summaryrefslogtreecommitdiff
path: root/stereographic.hpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2021-11-08 23:19:54 +0100
committerJaron Kent-Dobias <jaron@kent-dobias.com>2021-11-08 23:19:54 +0100
commit54416465850a9280a121127e0b5301d97ad13a61 (patch)
treedd6cdf2fdb63e6dd268db45dfb7300a079041ebc /stereographic.hpp
parent6b42ce01cd289567a6109d831fe86a0667d18f37 (diff)
downloadcode-54416465850a9280a121127e0b5301d97ad13a61.tar.gz
code-54416465850a9280a121127e0b5301d97ad13a61.tar.bz2
code-54416465850a9280a121127e0b5301d97ad13a61.zip
Removed some unused files.
Diffstat (limited to 'stereographic.hpp')
-rw-r--r--stereographic.hpp70
1 files changed, 0 insertions, 70 deletions
diff --git a/stereographic.hpp b/stereographic.hpp
deleted file mode 100644
index 58c6b31..0000000
--- a/stereographic.hpp
+++ /dev/null
@@ -1,70 +0,0 @@
-#pragma once
-
-#include <eigen3/Eigen/Cholesky>
-
-#include "p-spin.hpp"
-
-template <class Scalar>
-Vector<Scalar> stereographicToEuclidean(const Vector<Scalar>& ζ) {
- unsigned N = ζ.size() + 1;
- Vector<Scalar> z(N);
-
- Scalar a = ζ.transpose() * ζ;
- Scalar b = 2 * sqrt((Real)N) / ((Real)1 + a);
-
- for (unsigned i = 0; i < N - 1; i++) {
- z(i) = ζ(i);
- }
-
- z(N - 1) = (a - (Real)1) / (Real)2;
-
- return b * z;
-}
-
-template <class Scalar>
-Vector<Scalar> euclideanToStereographic(const Vector<Scalar>& z) {
- unsigned N = z.size();
- Vector<Scalar> ζ(N - 1);
-
- for (unsigned i = 0; i < N - 1; i++) {
- ζ(i) = z(i);
- }
-
- return ζ / (sqrt((Real)N) - z(N - 1));
-}
-
-template <class Scalar>
-Matrix<Scalar> stereographicJacobian(const Vector<Scalar>& ζ) {
- unsigned N = ζ.size();
- Matrix<Scalar> J(N, N + 1);
-
- Scalar b = (Real)1 + (Scalar)(ζ.transpose() * ζ);
-
- for (unsigned i = 0; i < N; i++) {
- for (unsigned j = 0; j < N; j++) {
- J(i, j) = - ζ(i) * ζ(j);
-
- if (i == j) {
- J(i, j) += b / (Real)2;
- }
- }
-
- J(i, N) = ζ(i);
- }
-
- return 4 * sqrt(N + 1) * J / pow(b, 2);
-}
-
-template <class Scalar, int p>
-std::tuple<Scalar, Vector<Scalar>, Matrix<Scalar>> stereographicHamGradHess(const Tensor<Scalar, p>& J, const Vector<Scalar>& ζ, const Vector<Scalar>& z) {
- auto [hamiltonian, gradZ, hessZ] = hamGradHess(J, z);
- Matrix<Scalar> jacobian = stereographicJacobian(ζ);
-
- Matrix<Scalar> metric = jacobian * jacobian.adjoint();
-
- // The metric is Hermitian and positive definite, so a Cholesky decomposition can be used.
- Vector<Scalar> grad = metric.llt().solve(jacobian) * gradZ;
- Matrix<Scalar> hess = jacobian * hessZ * jacobian.transpose();
-
- return {hamiltonian, grad, hess};
-}