summaryrefslogtreecommitdiff
path: root/src/complex
diff options
context:
space:
mode:
Diffstat (limited to 'src/complex')
-rw-r--r--src/complex/CMPLX.c16
-rw-r--r--src/complex/CMPLXF.c16
-rw-r--r--src/complex/CMPLXL.c17
3 files changed, 49 insertions, 0 deletions
diff --git a/src/complex/CMPLX.c b/src/complex/CMPLX.c
new file mode 100644
index 00000000..d0ffdedf
--- /dev/null
+++ b/src/complex/CMPLX.c
@@ -0,0 +1,16 @@
+#include <complex.h>
+
+#ifdef __STDC_IEC_559_COMPLEX__
+#define CMPLX(__x, __y) \
+ ((double complex)((double)(__x) + _Imaginary_I * (double)(__y)))
+#else
+#define CMPLX(__x, __y) \
+ (((union { \
+ double complex __c; \
+ double __d[2]; \
+ }){ .__d = { __x, __y } }).__c)
+#endif
+
+/*
+STDC(201112)
+*/
diff --git a/src/complex/CMPLXF.c b/src/complex/CMPLXF.c
new file mode 100644
index 00000000..397e7ad7
--- /dev/null
+++ b/src/complex/CMPLXF.c
@@ -0,0 +1,16 @@
+#include <complex.h>
+
+#ifdef __STDC_IEC_559_COMPLEX__
+#define CMPLXF(__x, __y) \
+ ((float complex)((float)(__x) + _Imaginary_I * (float)(__y)))
+#else
+#define CMPLXF(__x, __y) \
+ (((union { \
+ float complex __c; \
+ float __f[2]; \
+ }){ .__f = { __x, __y } }).__c)
+#endif
+
+/*
+STDC(201112)
+*/
diff --git a/src/complex/CMPLXL.c b/src/complex/CMPLXL.c
new file mode 100644
index 00000000..8e820512
--- /dev/null
+++ b/src/complex/CMPLXL.c
@@ -0,0 +1,17 @@
+#include <complex.h>
+
+#ifdef __STDC_IEC_559_COMPLEX__
+#define CMPLXL(__x, __y) \
+ ((long double complex)((long double)(__x) + \
+ _Imaginary_I * (long double)(__y)))
+#else
+#define CMPLXL(__x, __y) \
+ (((union { \
+ long double complex __c; \
+ long double __ld[2]; \
+ }){ .__ld = { __x, __y } }).__c)
+#endif
+
+/*
+STDC(201112)
+*/