From 54416465850a9280a121127e0b5301d97ad13a61 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 8 Nov 2021 23:19:54 +0100 Subject: Removed some unused files. --- stereographic.hpp | 70 ------------------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 stereographic.hpp (limited to 'stereographic.hpp') 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 - -#include "p-spin.hpp" - -template -Vector stereographicToEuclidean(const Vector& ζ) { - unsigned N = ζ.size() + 1; - Vector 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 -Vector euclideanToStereographic(const Vector& z) { - unsigned N = z.size(); - Vector ζ(N - 1); - - for (unsigned i = 0; i < N - 1; i++) { - ζ(i) = z(i); - } - - return ζ / (sqrt((Real)N) - z(N - 1)); -} - -template -Matrix stereographicJacobian(const Vector& ζ) { - unsigned N = ζ.size(); - Matrix 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 -std::tuple, Matrix> stereographicHamGradHess(const Tensor& J, const Vector& ζ, const Vector& z) { - auto [hamiltonian, gradZ, hessZ] = hamGradHess(J, z); - Matrix jacobian = stereographicJacobian(ζ); - - Matrix metric = jacobian * jacobian.adjoint(); - - // The metric is Hermitian and positive definite, so a Cholesky decomposition can be used. - Vector grad = metric.llt().solve(jacobian) * gradZ; - Matrix hess = jacobian * hessZ * jacobian.transpose(); - - return {hamiltonian, grad, hess}; -} -- cgit v1.2.3-54-g00ecf