From 5b8ae4706db195271b0b46469868b0cd8b5bbf4e Mon Sep 17 00:00:00 2001
From: Pauli Virtanen <pauli.t.virtanen@jyu.fi>
Date: Tue, 2 Aug 2022 18:20:55 +0300
Subject: [PATCH] common: some helper funcs

---
 src/common.hpp | 10 ++++++++++
 src/main.cpp   |  5 ++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/common.hpp b/src/common.hpp
index b7f4c4b..394b2f2 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -11,4 +11,14 @@
 typedef CppAD::AD<double> ADDouble;
 typedef std::complex<ADDouble> ADComplex;
 
+ADComplex adcomplex(const ADComplex& cpx)
+{
+    return {cpx};
+}
+
+ADComplex adcomplex(const std::complex<double>& cpx)
+{
+    return {cpx};
+}
+
 #endif
diff --git a/src/main.cpp b/src/main.cpp
index c361b4e..1a79aad 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2,6 +2,7 @@
 #include "array.hpp"
 #include "action.hpp"
 
+using namespace std::complex_literals;
 
 template <typename Scalar>
 void dump(Array<Scalar,3> Q)
@@ -34,7 +35,9 @@ int main()
     //auto mat = Q.to_matrix();
     auto mat = Q.to_fixed_matrix<2,2>();
 
-    mat = mat * mat * mat;
+    mat = mat * mat * mat * adcomplex(1j);
+
+    mat(0,0) = mat(1,1) = mat.trace();
 
     dump(Q0);
     std::cout << mat << std::endl;
-- 
GitLab