/* ISO C Runtime Library Copyright (c) 2003-2020 Green Hills Software, Inc. This program is the property of Green Hills Software, Inc, its contents are proprietary information and no part of it is to be disclosed to anyone except employees of Green Hills Software, Inc., or as agreed in writing signed by the President of Green Hills Software, Inc. */ #ifndef _COMPLEX_H #ifdef __ghs__ #pragma ghs startnomisra #endif #define _COMPLEX_H #if !defined(__NoFloat) #ifdef __cplusplus #error complex.h is intended for C99. Use for C++ instead #elif __STDC_VERSION__ < 199901L #error complex.h requires ISO C99 support in the compiler #endif #if defined(__LINUX) && !defined(__GHS_NO_INLINE_COMPLEX_OPS) #define __GHS_NO_INLINE_COMPLEX_OPS #endif #if !defined(__GHS_NO_INLINE_COMPLEX_OPS) #include "ghs_fpclassify.h" /* for __isnan* */ #endif #define complex _Complex #define _Complex_I ((float _Complex)__I__) #define imaginary _Imaginary #ifdef imaginary # define _Imaginary_I ((float _Imaginary)__I__) # define I _Imaginary_I #else # define I _Complex_I #endif #if !defined(__ATTRIBUTES) && !defined(__attribute__) #define __attribute__(x) #define __undefine_attribute_at_end__ #endif /* #pragma STDC CX_LIMITED_RANGE on-off-switch */ #if defined(__GHS_GENERATE_FEE) && defined(__ghs__) #pragma ghs entry_exit_history push on #endif float complex cacosf(float complex); float complex casinf(float complex); float complex catanf(float complex); float complex ccosf(float complex); float complex csinf(float complex); float complex ctanf(float complex); float complex cacoshf(float complex); float complex casinhf(float complex); float complex catanhf(float complex); float complex ccoshf(float complex); float complex csinhf(float complex); float complex ctanhf(float complex); float complex cexpf(float complex); float complex clogf(float complex); float cabsf(float complex) __attribute__((__const__)); float complex cpowf(float complex, float complex); float complex csqrtf(float complex); float cargf(float complex) __attribute__((__const__)); float complex conjf(float complex) __attribute__((__const__)); float complex cprojf(float complex) __attribute__((__const__)); #if !defined(__NoDouble) double complex cacos(double complex); double complex casin(double complex); double complex catan(double complex); double complex ccos(double complex); double complex csin(double complex); double complex ctan(double complex); double complex cacosh(double complex); double complex casinh(double complex); double complex catanh(double complex); double complex ccosh(double complex); double complex csinh(double complex); double complex ctanh(double complex); double complex cexp(double complex); double complex clog(double complex); double cabs(double complex) __attribute__((__const__)); double complex cpow(double complex, double complex); double complex csqrt(double complex); double carg(double complex) __attribute__((__const__)); double complex conj(double complex) __attribute__((__const__)); double complex cproj(double complex) __attribute__((__const__)); long double complex cacosl(long double complex); long double complex casinl(long double complex); long double complex catanl(long double complex); long double complex ccosl(long double complex); long double complex csinl(long double complex); long double complex ctanl(long double complex); long double complex cacoshl(long double complex); long double complex casinhl(long double complex); long double complex catanhl(long double complex); long double complex ccoshl(long double complex); long double complex csinhl(long double complex); long double complex ctanhl(long double complex); long double complex cexpl(long double complex); long double complex clogl(long double complex); long double cabsl(long double complex) __attribute__((__const__)); long double complex cpowl(long double complex, long double complex); long double complex csqrtl(long double complex); long double cargl(long double complex) __attribute__((__const__)); long double complex conjl(long double complex) __attribute__((__const__)); long double complex cprojl(long double complex) __attribute__((__const__)); #endif /* 1 */ #if defined(__GHS_NO_INLINE_COMPLEX_OPS) /* These functions aren't being provided inline; declare them. */ float cimagf(float complex) __attribute__((__const__)); float crealf(float complex) __attribute__((__const__)); #if !defined(__NoDouble) double cimag(double complex) __attribute__((__const__)); double creal(double complex) __attribute__((__const__)); long double cimagl(long double complex) __attribute__((__const__)); long double creall(long double complex) __attribute__((__const__)); #endif /* !defined(__NoDouble) */ #else /* defined(__GHS_NO_INLINE_COMPLEX_OPS) */ #pragma ghs nowarning 2003 /* Inline implementations of the complex operators and trivial functions. */ #if defined(__ghs_max_pack_value) #pragma pack (push, __ghs_max_pack_value) #endif typedef struct _Complex_float { float _Vals[2]; } _Complex_float; #if !defined(__NoDouble) typedef struct _Complex_double { double _Vals[2]; } _Complex_double; typedef struct _Complex_long_double { long double _Vals[2]; } _Complex_long_double; #if defined(__ghs_max_pack_value) #pragma pack(pop) #endif #endif /* !defined(__NoDouble) */ #if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__) #define __Inline_keyword_ static inline #else #define __Inline_keyword_ inline #endif __Inline_keyword_ float crealf(float complex __z) { return ((_Complex_float *)&__z)->_Vals[0]; } __Inline_keyword_ float cimagf(float complex __z) { return ((_Complex_float *)&__z)->_Vals[1]; } __Inline_keyword_ float complex __c99_ifloat_to_cfloat(float __j) { _Complex_float __r_struct; __r_struct._Vals[0] = (float)0.0f; __r_struct._Vals[1] = (float)__j; return *(float complex *)&__r_struct; } __Inline_keyword_ float complex __c99_float_to_cfloat(float __j) { _Complex_float __r_struct; __r_struct._Vals[0] = (float)__j; __r_struct._Vals[1] = (float)0.0f; return *(float complex *)&__r_struct; } __Inline_keyword_ float __c99_cfloat_to_ifloat(float complex __z) { return ((_Complex_float *)&__z)->_Vals[1]; } __Inline_keyword_ float __c99_cfloat_to_float(float complex __z) { return ((_Complex_float *)&__z)->_Vals[0]; } __Inline_keyword_ int __c99_complex_float_eq(float complex __z1, float complex __z2) { _Complex_float __z1_struct = *(_Complex_float *)&__z1; _Complex_float __z2_struct = *(_Complex_float *)&__z2; #pragma ghs nowarning 1704 return __z1_struct._Vals[0] == __z2_struct._Vals[0] && __z1_struct._Vals[1] == __z2_struct._Vals[1]; #pragma ghs endnowarning 1704 } __Inline_keyword_ int __c99_complex_float_ne(float complex __z1, float complex __z2) { _Complex_float __z1_struct = *(_Complex_float *)&__z1; _Complex_float __z2_struct = *(_Complex_float *)&__z2; #pragma ghs nowarning 1704 return __z1_struct._Vals[0] != __z2_struct._Vals[0] || __z1_struct._Vals[1] != __z2_struct._Vals[1]; #pragma ghs endnowarning 1704 } __Inline_keyword_ float complex __c99_complex_float_negate(float complex __z) { _Complex_float __z_struct = *(_Complex_float *)&__z; __z_struct._Vals[0] = -__z_struct._Vals[0]; __z_struct._Vals[1] = -__z_struct._Vals[1]; return *(float complex *)&__z_struct; } __Inline_keyword_ float complex __c99_complex_float_add(float complex __z1, float complex __z2) { _Complex_float __z1_struct = *(_Complex_float *)&__z1; _Complex_float __z2_struct = *(_Complex_float *)&__z2; _Complex_float __r_struct; __r_struct._Vals[0] = __z1_struct._Vals[0] + __z2_struct._Vals[0]; __r_struct._Vals[1] = __z1_struct._Vals[1] + __z2_struct._Vals[1]; return *(float complex *)&__r_struct; } __Inline_keyword_ float complex __c99_complex_float_subtract( float complex __z1, float complex __z2) { _Complex_float __z1_struct = *(_Complex_float *)&__z1; _Complex_float __z2_struct = *(_Complex_float *)&__z2; _Complex_float __r_struct; __r_struct._Vals[0] = __z1_struct._Vals[0] - __z2_struct._Vals[0]; __r_struct._Vals[1] = __z1_struct._Vals[1] - __z2_struct._Vals[1]; return *(float complex *)&__r_struct; } #if defined(__GHS_Optimize_Speed__) || defined(__GHS_Optimize_General__) extern __attribute__((noinline)) _Complex_float __ghs_complex_float_multiply_special( float __a, float __b, float __c, float __d); __Inline_keyword_ float complex __c99_complex_float_multiply( float complex __z1, float complex __z2) { _Complex_float __z1_struct = *(_Complex_float *)&__z1; _Complex_float __z2_struct = *(_Complex_float *)&__z2; float __a, __b, __c, __d, __ac, __bd, __ad, __bc, __x, __y; _Complex_float __r_struct; __a = __z1_struct._Vals[0]; __b = __z1_struct._Vals[1]; __c = __z2_struct._Vals[0]; __d = __z2_struct._Vals[1]; __ac = __a * __c; __bd = __b * __d; __ad = __a * __d; __bc = __b * __c; __x = __ac - __bd; __y = __ad + __bc; if (__isnanf(__x) && __isnanf(__y)) { __r_struct = __ghs_complex_float_multiply_special( __a, __b, __c, __d); return *(float complex *)&__r_struct; } __r_struct._Vals[0] = __x; __r_struct._Vals[1] = __y; return *(float complex *)&__r_struct; } #endif /* __GHS_Optimize_Speed__ || __GHS_Optimize_General__ */ /* __c99_complex_float_divide only provided out-of-line. */ #if !defined(__NoDouble) __Inline_keyword_ double creal(double complex __z) { return ((_Complex_double *)&__z)->_Vals[0]; } __Inline_keyword_ double cimag(double complex __z) { return ((_Complex_double *)&__z)->_Vals[1]; } __Inline_keyword_ double complex __c99_idouble_to_cdouble(double __j) { _Complex_double __r_struct; __r_struct._Vals[0] = (double)0.0; __r_struct._Vals[1] = (double)__j; return *(double complex *)&__r_struct; } __Inline_keyword_ double complex __c99_double_to_cdouble(double __j) { _Complex_double __r_struct; __r_struct._Vals[0] = (double)__j; __r_struct._Vals[1] = (double)0.0; return *(double complex *)&__r_struct; } __Inline_keyword_ double __c99_cdouble_to_idouble(double complex __z) { return ((_Complex_double *)&__z)->_Vals[1]; } __Inline_keyword_ double __c99_cdouble_to_double(double complex __z) { return ((_Complex_double *)&__z)->_Vals[0]; } __Inline_keyword_ int __c99_complex_double_eq(double complex __z1, double complex __z2) { _Complex_double __z1_struct = *(_Complex_double *)&__z1; _Complex_double __z2_struct = *(_Complex_double *)&__z2; #pragma ghs nowarning 1704 return __z1_struct._Vals[0] == __z2_struct._Vals[0] && __z1_struct._Vals[1] == __z2_struct._Vals[1]; #pragma ghs endnowarning 1704 } __Inline_keyword_ int __c99_complex_double_ne(double complex __z1, double complex __z2) { _Complex_double __z1_struct = *(_Complex_double *)&__z1; _Complex_double __z2_struct = *(_Complex_double *)&__z2; #pragma ghs nowarning 1704 return __z1_struct._Vals[0] != __z2_struct._Vals[0] || __z1_struct._Vals[1] != __z2_struct._Vals[1]; #pragma ghs endnowarning 1704 } __Inline_keyword_ double complex __c99_complex_double_negate( double complex __z) { _Complex_double __z_struct = *(_Complex_double *)&__z; __z_struct._Vals[0] = -__z_struct._Vals[0]; __z_struct._Vals[1] = -__z_struct._Vals[1]; return *(double complex *)&__z_struct; } __Inline_keyword_ double complex __c99_complex_double_add(double complex __z1, double complex __z2) { _Complex_double __z1_struct = *(_Complex_double *)&__z1; _Complex_double __z2_struct = *(_Complex_double *)&__z2; _Complex_double __r_struct; __r_struct._Vals[0] = __z1_struct._Vals[0] + __z2_struct._Vals[0]; __r_struct._Vals[1] = __z1_struct._Vals[1] + __z2_struct._Vals[1]; return *(double complex *)&__r_struct; } __Inline_keyword_ double complex __c99_complex_double_subtract( double complex __z1, double complex __z2) { _Complex_double __z1_struct = *(_Complex_double *)&__z1; _Complex_double __z2_struct = *(_Complex_double *)&__z2; _Complex_double __r_struct; __r_struct._Vals[0] = __z1_struct._Vals[0] - __z2_struct._Vals[0]; __r_struct._Vals[1] = __z1_struct._Vals[1] - __z2_struct._Vals[1]; return *(double complex *)&__r_struct; } #if defined(__GHS_Optimize_Speed__) || defined(__GHS_Optimize_General__) extern __attribute__((noinline)) _Complex_double __ghs_complex_double_multiply_special( double __a, double __b, double __c, double __d); __Inline_keyword_ double complex __c99_complex_double_multiply( double complex __z1, double complex __z2) { _Complex_double __z1_struct = *(_Complex_double *)&__z1; _Complex_double __z2_struct = *(_Complex_double *)&__z2; double __a, __b, __c, __d, __ac, __bd, __ad, __bc, __x, __y; _Complex_double __r_struct; __a = __z1_struct._Vals[0]; __b = __z1_struct._Vals[1]; __c = __z2_struct._Vals[0]; __d = __z2_struct._Vals[1]; __ac = __a * __c; __bd = __b * __d; __ad = __a * __d; __bc = __b * __c; __x = __ac - __bd; __y = __ad + __bc; if (__isnand(__x) && __isnand(__y)) { __r_struct = __ghs_complex_double_multiply_special( __a, __b, __c, __d); return *(double complex *)&__r_struct; } __r_struct._Vals[0] = __x; __r_struct._Vals[1] = __y; return *(double complex *)&__r_struct; } #endif /* __GHS_Optimize_Speed__ || __GHS_Optimize_General__ */ /* __c99_complex_double_divide only provided out-of-line. */ __Inline_keyword_ long double creall(long double complex __z) { return ((_Complex_long_double *)&__z)->_Vals[0]; } __Inline_keyword_ long double cimagl(long double complex __z) { return ((_Complex_long_double *)&__z)->_Vals[1]; } __Inline_keyword_ long double complex __c99_ilong_double_to_clong_double( long double __j) { _Complex_long_double __r_struct; __r_struct._Vals[0] = (long double)0.0L; __r_struct._Vals[1] = (long double)__j; return *(long double complex *)&__r_struct; } __Inline_keyword_ long double complex __c99_long_double_to_clong_double( long double __j) { _Complex_long_double __r_struct; __r_struct._Vals[0] = (long double)__j; __r_struct._Vals[1] = (long double)0.0L; return *(long double complex *)&__r_struct; } __Inline_keyword_ long double __c99_clong_double_to_ilong_double( long double complex __z) { return ((_Complex_long_double *)&__z)->_Vals[1]; } __Inline_keyword_ long double __c99_clong_double_to_long_double( long double complex __z) { return ((_Complex_long_double *)&__z)->_Vals[0]; } __Inline_keyword_ int __c99_complex_long_double_eq(long double complex __z1, long double complex __z2) { _Complex_long_double __z1_struct = *(_Complex_long_double *)&__z1; _Complex_long_double __z2_struct = *(_Complex_long_double *)&__z2; #pragma ghs nowarning 1704 return __z1_struct._Vals[0] == __z2_struct._Vals[0] && __z1_struct._Vals[1] == __z2_struct._Vals[1]; #pragma ghs endnowarning 1704 } __Inline_keyword_ int __c99_complex_long_double_ne(long double complex __z1, long double complex __z2) { _Complex_long_double __z1_struct = *(_Complex_long_double *)&__z1; _Complex_long_double __z2_struct = *(_Complex_long_double *)&__z2; #pragma ghs nowarning 1704 return __z1_struct._Vals[0] != __z2_struct._Vals[0] || __z1_struct._Vals[1] != __z2_struct._Vals[1]; #pragma ghs endnowarning 1704 } __Inline_keyword_ long double complex __c99_complex_long_double_negate( long double complex __z) { _Complex_long_double __z_struct = *(_Complex_long_double *)&__z; __z_struct._Vals[0] = -__z_struct._Vals[0]; __z_struct._Vals[1] = -__z_struct._Vals[1]; return *(long double complex *)&__z_struct; } __Inline_keyword_ long double complex __c99_complex_long_double_add( long double complex __z1, long double complex __z2) { _Complex_long_double __z1_struct = *(_Complex_long_double *)&__z1; _Complex_long_double __z2_struct = *(_Complex_long_double *)&__z2; _Complex_long_double __r_struct; __r_struct._Vals[0] = __z1_struct._Vals[0] + __z2_struct._Vals[0]; __r_struct._Vals[1] = __z1_struct._Vals[1] + __z2_struct._Vals[1]; return *(long double complex *)&__r_struct; } __Inline_keyword_ long double complex __c99_complex_long_double_subtract( long double complex __z1, long double complex __z2) { _Complex_long_double __z1_struct = *(_Complex_long_double *)&__z1; _Complex_long_double __z2_struct = *(_Complex_long_double *)&__z2; _Complex_long_double __r_struct; __r_struct._Vals[0] = __z1_struct._Vals[0] - __z2_struct._Vals[0]; __r_struct._Vals[1] = __z1_struct._Vals[1] - __z2_struct._Vals[1]; return *(long double complex *)&__r_struct; } #if defined(__GHS_Optimize_Speed__) || defined(__GHS_Optimize_General__) extern __attribute__((noinline)) _Complex_long_double __ghs_complex_long_double_multiply_special( long double __a, long double __b, long double __c, long double __d); __Inline_keyword_ long double complex __c99_complex_long_double_multiply( long double complex __z1, long double complex __z2) { _Complex_long_double __z1_struct = *(_Complex_long_double *)&__z1; _Complex_long_double __z2_struct = *(_Complex_long_double *)&__z2; long double __a, __b, __c, __d, __ac, __bd, __ad, __bc, __x, __y; _Complex_long_double __r_struct; __a = __z1_struct._Vals[0]; __b = __z1_struct._Vals[1]; __c = __z2_struct._Vals[0]; __d = __z2_struct._Vals[1]; __ac = __a * __c; __bd = __b * __d; __ad = __a * __d; __bc = __b * __c; __x = __ac - __bd; __y = __ad + __bc; if (__isnanl(__x) && __isnanl(__y)) { __r_struct = __ghs_complex_long_double_multiply_special( __a, __b, __c, __d); return *(long double complex *)&__r_struct; } __r_struct._Vals[0] = __x; __r_struct._Vals[1] = __y; return *(long double complex *)&__r_struct; } #endif /* __GHS_Optimize_Speed__ || __GHS_Optimize_General__ */ /* __c99_complex_long_double_divide only provided out-of-line. */ __Inline_keyword_ double complex __c99_cfloat_to_cdouble(float complex __z) { _Complex_double __r_struct; _Complex_float __z_struct = *(_Complex_float *)&__z; __r_struct._Vals[0] = (double)__z_struct._Vals[0]; __r_struct._Vals[1] = (double)__z_struct._Vals[1]; return *(double complex *)&__r_struct; } __Inline_keyword_ long double complex __c99_cfloat_to_clong_double( float complex __z) { _Complex_long_double __r_struct; _Complex_float __z_struct = *(_Complex_float *)&__z; __r_struct._Vals[0] = (long double)__z_struct._Vals[0]; __r_struct._Vals[1] = (long double)__z_struct._Vals[1]; return *(long double complex *)&__r_struct; } __Inline_keyword_ float complex __c99_cdouble_to_cfloat(double complex __z) { _Complex_float __r_struct; _Complex_double __z_struct = *(_Complex_double *)&__z; __r_struct._Vals[0] = (float)__z_struct._Vals[0]; __r_struct._Vals[1] = (float)__z_struct._Vals[1]; return *(float complex *)&__r_struct; } __Inline_keyword_ long double complex __c99_cdouble_to_clong_double( double complex __z) { _Complex_long_double __r_struct; _Complex_double __z_struct = *(_Complex_double *)&__z; __r_struct._Vals[0] = (long double)__z_struct._Vals[0]; __r_struct._Vals[1] = (long double)__z_struct._Vals[1]; return *(long double complex *)&__r_struct; } __Inline_keyword_ float complex __c99_clong_double_to_cfloat( long double complex __z) { _Complex_float __r_struct; _Complex_long_double __z_struct = *(_Complex_long_double *)&__z; __r_struct._Vals[0] = (float)__z_struct._Vals[0]; __r_struct._Vals[1] = (float)__z_struct._Vals[1]; return *(float complex *)&__r_struct; } __Inline_keyword_ double complex __c99_clong_double_to_cdouble( long double complex __z) { _Complex_double __r_struct; _Complex_long_double __z_struct = *(_Complex_long_double *)&__z; __r_struct._Vals[0] = (double)__z_struct._Vals[0]; __r_struct._Vals[1] = (double)__z_struct._Vals[1]; return *(double complex *)&__r_struct; } #endif /* !defined(__NoDouble) */ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) #define CMPLXF(x,y) ((float complex)((float)(x)+_Imaginary_I*(float)(y))) #if !defined(__NoDouble) #define CMPLX(x,y) ((double complex)((double)(x)+_Imaginary_I*(double)(y))) #define CMPLXL(x,y) ((long double complex)((long double)(x)+_Imaginary_I*(long double)(y))) #endif /* !defined(__NoDouble) */ #endif /* defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) */ #undef __Inline_keyword_ #pragma ghs endnowarning 2003 #endif /* defined(__GHS_NO_INLINE_COMPLEX_OPS) */ #if defined(__undefine_attribute_at_end__) #undef __attribute__ #endif #if defined(__GHS_GENERATE_FEE) && defined(__ghs__) #pragma ghs entry_exit_history pop #endif #endif /* !defined(__NoFloat) */ #ifdef __ghs__ #pragma ghs endnomisra #endif #endif /* _COMPLEX_H */