From 91265ea80bb80fc8a123716c6438ca8dbf1127d0 Mon Sep 17 00:00:00 2001
From: Giovanni La Mura <giovanni.lamura@inaf.it>
Date: Tue, 8 Oct 2024 10:50:34 +0200
Subject: [PATCH] Define real() and imag() as functions to allow for
 overloading

---
 src/include/types.h | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/include/types.h b/src/include/types.h
index 742a5ff8..453514b4 100644
--- a/src/include/types.h
+++ b/src/include/types.h
@@ -62,7 +62,21 @@ typedef __complex__ double dcomplex;
 #endif // lapack_int
 #endif // np_int
 
-#define imag(z) ( __imag__ (z) )
-#define real(z) ( __real__ (z) )
 #define dconjg(z) ( (__real__ (z) - I * (__imag__ (z))) )
+
+/*! \brief Get the imaginary part of double precision complex number.
+ *
+ * \param z: `const dcomplex &` Reference to the complex number from
+ * which to extract the imaginary part.
+ * \return Im(z): `double` Imaginary part of z.
+ */
+double inline imag(const dcomplex &z) { return __imag__ z; }
+
+/*! \brief Get the imaginary part of double precision complex number.
+ *
+ * \param z: `const dcomplex &` Reference to the complex number from
+ * which to extract the real part.
+ * \return Re(z): `double` Real part of z.
+ */
+double inline real(const dcomplex &z) { return __real__ z; }
 #endif
-- 
GitLab