complex.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #ifndef _COMPLEX_H
  2. #define _COMPLEX_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define complex _Complex
  7. #ifdef __GNUC__
  8. #define _Complex_I (__extension__ (0.0f+1.0fi))
  9. #else
  10. #define _Complex_I (0.0f+1.0fi)
  11. #endif
  12. #define I _Complex_I
  13. double complex cacos(double complex);
  14. float complex cacosf(float complex);
  15. long double complex cacosl(long double complex);
  16. double complex casin(double complex);
  17. float complex casinf(float complex);
  18. long double complex casinl(long double complex);
  19. double complex catan(double complex);
  20. float complex catanf(float complex);
  21. long double complex catanl(long double complex);
  22. double complex ccos(double complex);
  23. float complex ccosf(float complex);
  24. long double complex ccosl(long double complex);
  25. double complex csin(double complex);
  26. float complex csinf(float complex);
  27. long double complex csinl(long double complex);
  28. double complex ctan(double complex);
  29. float complex ctanf(float complex);
  30. long double complex ctanl(long double complex);
  31. double complex cacosh(double complex);
  32. float complex cacoshf(float complex);
  33. long double complex cacoshl(long double complex);
  34. double complex casinh(double complex);
  35. float complex casinhf(float complex);
  36. long double complex casinhl(long double complex);
  37. double complex catanh(double complex);
  38. float complex catanhf(float complex);
  39. long double complex catanhl(long double complex);
  40. double complex ccosh(double complex);
  41. float complex ccoshf(float complex);
  42. long double complex ccoshl(long double complex);
  43. double complex csinh(double complex);
  44. float complex csinhf(float complex);
  45. long double complex csinhl(long double complex);
  46. double complex ctanh(double complex);
  47. float complex ctanhf(float complex);
  48. long double complex ctanhl(long double complex);
  49. double complex cexp(double complex);
  50. float complex cexpf(float complex);
  51. long double complex cexpl(long double complex);
  52. double complex clog(double complex);
  53. float complex clogf(float complex);
  54. long double complex clogl(long double complex);
  55. double cabs(double complex);
  56. float cabsf(float complex);
  57. long double cabsl(long double complex);
  58. double complex cpow(double complex, double complex);
  59. float complex cpowf(float complex, float complex);
  60. long double complex cpowl(long double complex, long double complex);
  61. double complex csqrt(double complex);
  62. float complex csqrtf(float complex);
  63. long double complex csqrtl(long double complex);
  64. double carg(double complex);
  65. float cargf(float complex);
  66. long double cargl(long double complex);
  67. double cimag(double complex);
  68. float cimagf(float complex);
  69. long double cimagl(long double complex);
  70. double complex conj(double complex);
  71. float complex conjf(float complex);
  72. long double complex conjl(long double complex);
  73. double complex cproj(double complex);
  74. float complex cprojf(float complex);
  75. long double complex cprojl(long double complex);
  76. double creal(double complex);
  77. float crealf(float complex);
  78. long double creall(long double complex);
  79. #ifndef __cplusplus
  80. #define __CIMAG(x, t) \
  81. (+(union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[1])
  82. #define creal(x) ((double)(x))
  83. #define crealf(x) ((float)(x))
  84. #define creall(x) ((long double)(x))
  85. #define cimag(x) __CIMAG(x, double)
  86. #define cimagf(x) __CIMAG(x, float)
  87. #define cimagl(x) __CIMAG(x, long double)
  88. #endif
  89. #if __STDC_VERSION__ >= 201112L
  90. #if defined(_Imaginary_I)
  91. #define __CMPLX(x, y, t) ((t)(x) + _Imaginary_I*(t)(y))
  92. #elif defined(__clang__)
  93. #define __CMPLX(x, y, t) (+(_Complex t){ (t)(x), (t)(y) })
  94. #else
  95. #define __CMPLX(x, y, t) (__builtin_complex((t)(x), (t)(y)))
  96. #endif
  97. #define CMPLX(x, y) __CMPLX(x, y, double)
  98. #define CMPLXF(x, y) __CMPLX(x, y, float)
  99. #define CMPLXL(x, y) __CMPLX(x, y, long double)
  100. #endif
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif