mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
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>
This commit is contained in:
parent
8b438ea8dd
commit
19b114da0e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=151865
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user