From 4a0dc9133bd2067d429c783f8079cf8726a3118b Mon Sep 17 00:00:00 2001
From: uvos <devnull@uvos.xyz>
Date: Thu, 14 Sep 2023 19:19:19 +0200
Subject: [PATCH] torch dosent allow the use of constants in scripts

---
 constantphase.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/constantphase.cpp b/constantphase.cpp
index 5814e9b..5e68df6 100644
--- a/constantphase.cpp
+++ b/constantphase.cpp
@@ -1,6 +1,7 @@
 #include "constantphase.h"
 #include "strops.h"
 #include <cstdlib>
+#include <string>
 #define _USE_MATH_DEFINES
 #include <cmath>
 #include <cassert>
@@ -85,12 +86,13 @@ std::string Cpe::getCode(std::vector<std::string>& parameters)
 
 std::string Cpe::getTorchScript(std::vector<std::string>& parameters)
 {
+	std::string hpi = std::to_string(M_PI/2);
 	std::string firstParameter = getUniqueName() + "_0";
 	std::string secondParameter = getUniqueName() + "_1";
 	parameters.push_back(firstParameter);
 	parameters.push_back(secondParameter);
-	std::string real = "(1/(" + firstParameter + "*torch.pow(omegas,"+ secondParameter +")))*torch.cos((torch.pi/2)*" + secondParameter + ")";
-	std::string imag = "(1/(" + firstParameter + "*torch.pow(omegas,"+ secondParameter +")))*torch.sin((torch.pi/2)*" + secondParameter + ")";
+	std::string real = "(1/(" + firstParameter + "*torch.pow(omegas,"+ secondParameter +")))*torch.cos("+ hpi +"*" + secondParameter + ")";
+	std::string imag = "(1/(" + firstParameter + "*torch.pow(omegas,"+ secondParameter +")))*torch.sin("+ hpi +"*" + secondParameter + ")";
 	std::string out = real + '-' + imag + "*1j";
 	return out;
 }
-- 
GitLab