summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2005-10-29 17:14:11 +0000
committerbde <bde@FreeBSD.org>2005-10-29 17:14:11 +0000
commit26610cfe9b5e6587a4d8e59c1dfd4b12bd5d2bb7 (patch)
treee17f1c8ff1367ace97a7ed91548a58275e50bdcb
parentbbfb40721e74d5bf0d3cef337da864daa1cf217b (diff)
downloadFreeBSD-src-26610cfe9b5e6587a4d8e59c1dfd4b12bd5d2bb7.zip
FreeBSD-src-26610cfe9b5e6587a4d8e59c1dfd4b12bd5d2bb7.tar.gz
Implement inline functions to give the complex result x+I*y from float
or double args x and y. x+I*y cannot be used directly yet due to compiler bugs. Submitted by: Steve Kargl <sgk@troutmask.apl.washington.edu>
-rw-r--r--lib/msun/src/math_private.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/msun/src/math_private.h b/lib/msun/src/math_private.h
index 1fc6a93..27337a9 100644
--- a/lib/msun/src/math_private.h
+++ b/lib/msun/src/math_private.h
@@ -154,6 +154,48 @@ do { \
(d) = sf_u.value; \
} while (0)
+#ifdef _COMPLEX_H
+/*
+ * Inline functions that can be used to construct complex values.
+ *
+ * The C99 standard intends x+I*y to be used for this, but x+I*y is
+ * currently unusable in general since gcc introduces many overflow,
+ * underflow, sign and efficiency bugs by rewriting I*y as
+ * (0.0+I)*(y+0.0*I) and laboriously computing the full complex product.
+ * In particular, I*Inf is corrupted to NaN+I*Inf, and I*-0 is corrupted
+ * to -0.0+I*0.0.
+ */
+static __inline float complex
+cpackf(float x, float y)
+{
+ float complex z;
+
+ __real__ z = x;
+ __imag__ z = y;
+ return (z);
+}
+
+static __inline double complex
+cpack(double x, double y)
+{
+ double complex z;
+
+ __real__ z = x;
+ __imag__ z = y;
+ return (z);
+}
+
+static __inline long double complex
+cpackl(long double x, long double y)
+{
+ long double complex z;
+
+ __real__ z = x;
+ __imag__ z = y;
+ return (z);
+}
+#endif /* _COMPLEX_H */
+
/*
* ieee style elementary functions
*
OpenPOWER on IntegriCloud