tgmath.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. /* Copyright (C) 1997-2016 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. /*
  15. * ISO C99 Standard: 7.22 Type-generic math <tgmath.h>
  16. */
  17. #ifndef _TGMATH_H
  18. #define _TGMATH_H 1
  19. /* Include the needed headers. */
  20. #include <math.h>
  21. #include <complex.h>
  22. /* Since `complex' is currently not really implemented in most C compilers
  23. and if it is implemented, the implementations differ. This makes it
  24. quite difficult to write a generic implementation of this header. We
  25. do not try this for now and instead concentrate only on GNU CC. Once
  26. we have more information support for other compilers might follow. */
  27. #if __GNUC_PREREQ (2, 7)
  28. # ifdef __NO_LONG_DOUBLE_MATH
  29. # define __tgml(fct) fct
  30. # else
  31. # define __tgml(fct) fct ## l
  32. # endif
  33. /* This is ugly but unless gcc gets appropriate builtins we have to do
  34. something like this. Don't ask how it works. */
  35. /* 1 if 'type' is a floating type, 0 if 'type' is an integer type.
  36. Allows for _Bool. Expands to an integer constant expression. */
  37. # if __GNUC_PREREQ (3, 1)
  38. # define __floating_type(type) \
  39. (__builtin_classify_type ((type) 0) == 8 \
  40. || (__builtin_classify_type ((type) 0) == 9 \
  41. && __builtin_classify_type (__real__ ((type) 0)) == 8))
  42. # else
  43. # define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))
  44. # endif
  45. /* The tgmath real type for T, where E is 0 if T is an integer type and
  46. 1 for a floating type. */
  47. # define __tgmath_real_type_sub(T, E) \
  48. __typeof__ (*(0 ? (__typeof__ (0 ? (double *) 0 : (void *) (E))) 0 \
  49. : (__typeof__ (0 ? (T *) 0 : (void *) (!(E)))) 0))
  50. /* The tgmath real type of EXPR. */
  51. # define __tgmath_real_type(expr) \
  52. __tgmath_real_type_sub (__typeof__ ((__typeof__ (expr)) 0), \
  53. __floating_type (__typeof__ (expr)))
  54. /* We have two kinds of generic macros: to support functions which are
  55. only defined on real valued parameters and those which are defined
  56. for complex functions as well. */
  57. # define __TGMATH_UNARY_REAL_ONLY(Val, Fct) \
  58. (__extension__ ((sizeof (Val) == sizeof (double) \
  59. || __builtin_classify_type (Val) != 8) \
  60. ? (__tgmath_real_type (Val)) Fct (Val) \
  61. : (sizeof (Val) == sizeof (float)) \
  62. ? (__tgmath_real_type (Val)) Fct##f (Val) \
  63. : (__tgmath_real_type (Val)) __tgml(Fct) (Val)))
  64. # define __TGMATH_UNARY_REAL_RET_ONLY(Val, RetType, Fct) \
  65. (__extension__ ((sizeof (Val) == sizeof (double) \
  66. || __builtin_classify_type (Val) != 8) \
  67. ? (RetType) Fct (Val) \
  68. : (sizeof (Val) == sizeof (float)) \
  69. ? (RetType) Fct##f (Val) \
  70. : (RetType) __tgml(Fct) (Val)))
  71. # define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \
  72. (__extension__ ((sizeof (Val1) == sizeof (double) \
  73. || __builtin_classify_type (Val1) != 8) \
  74. ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \
  75. : (sizeof (Val1) == sizeof (float)) \
  76. ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \
  77. : (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2)))
  78. # define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \
  79. (__extension__ (((sizeof (Val1) > sizeof (double) \
  80. || sizeof (Val2) > sizeof (double)) \
  81. && __builtin_classify_type ((Val1) + (Val2)) == 8) \
  82. ? (__typeof ((__tgmath_real_type (Val1)) 0 \
  83. + (__tgmath_real_type (Val2)) 0)) \
  84. __tgml(Fct) (Val1, Val2) \
  85. : (sizeof (Val1) == sizeof (double) \
  86. || sizeof (Val2) == sizeof (double) \
  87. || __builtin_classify_type (Val1) != 8 \
  88. || __builtin_classify_type (Val2) != 8) \
  89. ? (__typeof ((__tgmath_real_type (Val1)) 0 \
  90. + (__tgmath_real_type (Val2)) 0)) \
  91. Fct (Val1, Val2) \
  92. : (__typeof ((__tgmath_real_type (Val1)) 0 \
  93. + (__tgmath_real_type (Val2)) 0)) \
  94. Fct##f (Val1, Val2)))
  95. # define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \
  96. (__extension__ (((sizeof (Val1) > sizeof (double) \
  97. || sizeof (Val2) > sizeof (double)) \
  98. && __builtin_classify_type ((Val1) + (Val2)) == 8) \
  99. ? (__typeof ((__tgmath_real_type (Val1)) 0 \
  100. + (__tgmath_real_type (Val2)) 0)) \
  101. __tgml(Fct) (Val1, Val2, Val3) \
  102. : (sizeof (Val1) == sizeof (double) \
  103. || sizeof (Val2) == sizeof (double) \
  104. || __builtin_classify_type (Val1) != 8 \
  105. || __builtin_classify_type (Val2) != 8) \
  106. ? (__typeof ((__tgmath_real_type (Val1)) 0 \
  107. + (__tgmath_real_type (Val2)) 0)) \
  108. Fct (Val1, Val2, Val3) \
  109. : (__typeof ((__tgmath_real_type (Val1)) 0 \
  110. + (__tgmath_real_type (Val2)) 0)) \
  111. Fct##f (Val1, Val2, Val3)))
  112. # define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \
  113. (__extension__ (((sizeof (Val1) > sizeof (double) \
  114. || sizeof (Val2) > sizeof (double) \
  115. || sizeof (Val3) > sizeof (double)) \
  116. && __builtin_classify_type ((Val1) + (Val2) + (Val3)) \
  117. == 8) \
  118. ? (__typeof ((__tgmath_real_type (Val1)) 0 \
  119. + (__tgmath_real_type (Val2)) 0 \
  120. + (__tgmath_real_type (Val3)) 0)) \
  121. __tgml(Fct) (Val1, Val2, Val3) \
  122. : (sizeof (Val1) == sizeof (double) \
  123. || sizeof (Val2) == sizeof (double) \
  124. || sizeof (Val3) == sizeof (double) \
  125. || __builtin_classify_type (Val1) != 8 \
  126. || __builtin_classify_type (Val2) != 8 \
  127. || __builtin_classify_type (Val3) != 8) \
  128. ? (__typeof ((__tgmath_real_type (Val1)) 0 \
  129. + (__tgmath_real_type (Val2)) 0 \
  130. + (__tgmath_real_type (Val3)) 0)) \
  131. Fct (Val1, Val2, Val3) \
  132. : (__typeof ((__tgmath_real_type (Val1)) 0 \
  133. + (__tgmath_real_type (Val2)) 0 \
  134. + (__tgmath_real_type (Val3)) 0)) \
  135. Fct##f (Val1, Val2, Val3)))
  136. /* XXX This definition has to be changed as soon as the compiler understands
  137. the imaginary keyword. */
  138. # define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \
  139. (__extension__ ((sizeof (__real__ (Val)) == sizeof (double) \
  140. || __builtin_classify_type (__real__ (Val)) != 8) \
  141. ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
  142. ? (__tgmath_real_type (Val)) Fct (Val) \
  143. : (__tgmath_real_type (Val)) Cfct (Val)) \
  144. : (sizeof (__real__ (Val)) == sizeof (float)) \
  145. ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
  146. ? (__tgmath_real_type (Val)) Fct##f (Val) \
  147. : (__tgmath_real_type (Val)) Cfct##f (Val)) \
  148. : ((sizeof (__real__ (Val)) == sizeof (Val)) \
  149. ? (__tgmath_real_type (Val)) __tgml(Fct) (Val) \
  150. : (__tgmath_real_type (Val)) __tgml(Cfct) (Val))))
  151. # define __TGMATH_UNARY_IMAG(Val, Cfct) \
  152. (__extension__ ((sizeof (__real__ (Val)) == sizeof (double) \
  153. || __builtin_classify_type (__real__ (Val)) != 8) \
  154. ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
  155. + _Complex_I)) Cfct (Val) \
  156. : (sizeof (__real__ (Val)) == sizeof (float)) \
  157. ? (__typeof__ ((__tgmath_real_type (Val)) 0 \
  158. + _Complex_I)) Cfct##f (Val) \
  159. : (__typeof__ ((__tgmath_real_type (Val)) 0 \
  160. + _Complex_I)) __tgml(Cfct) (Val)))
  161. /* XXX This definition has to be changed as soon as the compiler understands
  162. the imaginary keyword. */
  163. # define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \
  164. (__extension__ ((sizeof (__real__ (Val)) == sizeof (double) \
  165. || __builtin_classify_type (__real__ (Val)) != 8) \
  166. ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
  167. ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
  168. Fct (Val) \
  169. : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
  170. Cfct (Val)) \
  171. : (sizeof (__real__ (Val)) == sizeof (float)) \
  172. ? ((sizeof (__real__ (Val)) == sizeof (Val)) \
  173. ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
  174. Fct##f (Val) \
  175. : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
  176. Cfct##f (Val)) \
  177. : ((sizeof (__real__ (Val)) == sizeof (Val)) \
  178. ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
  179. __tgml(Fct) (Val) \
  180. : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\
  181. __tgml(Cfct) (Val))))
  182. /* XXX This definition has to be changed as soon as the compiler understands
  183. the imaginary keyword. */
  184. # define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \
  185. (__extension__ (((sizeof (__real__ (Val1)) > sizeof (double) \
  186. || sizeof (__real__ (Val2)) > sizeof (double)) \
  187. && __builtin_classify_type (__real__ (Val1) \
  188. + __real__ (Val2)) == 8) \
  189. ? ((sizeof (__real__ (Val1)) == sizeof (Val1) \
  190. && sizeof (__real__ (Val2)) == sizeof (Val2)) \
  191. ? (__typeof ((__tgmath_real_type (Val1)) 0 \
  192. + (__tgmath_real_type (Val2)) 0)) \
  193. __tgml(Fct) (Val1, Val2) \
  194. : (__typeof ((__tgmath_real_type (Val1)) 0 \
  195. + (__tgmath_real_type (Val2)) 0)) \
  196. __tgml(Cfct) (Val1, Val2)) \
  197. : (sizeof (__real__ (Val1)) == sizeof (double) \
  198. || sizeof (__real__ (Val2)) == sizeof (double) \
  199. || __builtin_classify_type (__real__ (Val1)) != 8 \
  200. || __builtin_classify_type (__real__ (Val2)) != 8) \
  201. ? ((sizeof (__real__ (Val1)) == sizeof (Val1) \
  202. && sizeof (__real__ (Val2)) == sizeof (Val2)) \
  203. ? (__typeof ((__tgmath_real_type (Val1)) 0 \
  204. + (__tgmath_real_type (Val2)) 0)) \
  205. Fct (Val1, Val2) \
  206. : (__typeof ((__tgmath_real_type (Val1)) 0 \
  207. + (__tgmath_real_type (Val2)) 0)) \
  208. Cfct (Val1, Val2)) \
  209. : ((sizeof (__real__ (Val1)) == sizeof (Val1) \
  210. && sizeof (__real__ (Val2)) == sizeof (Val2)) \
  211. ? (__typeof ((__tgmath_real_type (Val1)) 0 \
  212. + (__tgmath_real_type (Val2)) 0)) \
  213. Fct##f (Val1, Val2) \
  214. : (__typeof ((__tgmath_real_type (Val1)) 0 \
  215. + (__tgmath_real_type (Val2)) 0)) \
  216. Cfct##f (Val1, Val2))))
  217. #else
  218. # error "Unsupported compiler; you cannot use <tgmath.h>"
  219. #endif
  220. /* Unary functions defined for real and complex values. */
  221. /* Trigonometric functions. */
  222. /* Arc cosine of X. */
  223. #define acos(Val) __TGMATH_UNARY_REAL_IMAG (Val, acos, cacos)
  224. /* Arc sine of X. */
  225. #define asin(Val) __TGMATH_UNARY_REAL_IMAG (Val, asin, casin)
  226. /* Arc tangent of X. */
  227. #define atan(Val) __TGMATH_UNARY_REAL_IMAG (Val, atan, catan)
  228. /* Arc tangent of Y/X. */
  229. #define atan2(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, atan2)
  230. /* Cosine of X. */
  231. #define cos(Val) __TGMATH_UNARY_REAL_IMAG (Val, cos, ccos)
  232. /* Sine of X. */
  233. #define sin(Val) __TGMATH_UNARY_REAL_IMAG (Val, sin, csin)
  234. /* Tangent of X. */
  235. #define tan(Val) __TGMATH_UNARY_REAL_IMAG (Val, tan, ctan)
  236. /* Hyperbolic functions. */
  237. /* Hyperbolic arc cosine of X. */
  238. #define acosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, acosh, cacosh)
  239. /* Hyperbolic arc sine of X. */
  240. #define asinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, asinh, casinh)
  241. /* Hyperbolic arc tangent of X. */
  242. #define atanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, atanh, catanh)
  243. /* Hyperbolic cosine of X. */
  244. #define cosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, cosh, ccosh)
  245. /* Hyperbolic sine of X. */
  246. #define sinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, sinh, csinh)
  247. /* Hyperbolic tangent of X. */
  248. #define tanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, tanh, ctanh)
  249. /* Exponential and logarithmic functions. */
  250. /* Exponential function of X. */
  251. #define exp(Val) __TGMATH_UNARY_REAL_IMAG (Val, exp, cexp)
  252. /* Break VALUE into a normalized fraction and an integral power of 2. */
  253. #define frexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, frexp)
  254. /* X times (two to the EXP power). */
  255. #define ldexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, ldexp)
  256. /* Natural logarithm of X. */
  257. #define log(Val) __TGMATH_UNARY_REAL_IMAG (Val, log, clog)
  258. /* Base-ten logarithm of X. */
  259. #ifdef __USE_GNU
  260. # define log10(Val) __TGMATH_UNARY_REAL_IMAG (Val, log10, __clog10)
  261. #else
  262. # define log10(Val) __TGMATH_UNARY_REAL_ONLY (Val, log10)
  263. #endif
  264. /* Return exp(X) - 1. */
  265. #define expm1(Val) __TGMATH_UNARY_REAL_ONLY (Val, expm1)
  266. /* Return log(1 + X). */
  267. #define log1p(Val) __TGMATH_UNARY_REAL_ONLY (Val, log1p)
  268. /* Return the base 2 signed integral exponent of X. */
  269. #define logb(Val) __TGMATH_UNARY_REAL_ONLY (Val, logb)
  270. /* Compute base-2 exponential of X. */
  271. #define exp2(Val) __TGMATH_UNARY_REAL_ONLY (Val, exp2)
  272. /* Compute base-2 logarithm of X. */
  273. #define log2(Val) __TGMATH_UNARY_REAL_ONLY (Val, log2)
  274. /* Power functions. */
  275. /* Return X to the Y power. */
  276. #define pow(Val1, Val2) __TGMATH_BINARY_REAL_IMAG (Val1, Val2, pow, cpow)
  277. /* Return the square root of X. */
  278. #define sqrt(Val) __TGMATH_UNARY_REAL_IMAG (Val, sqrt, csqrt)
  279. /* Return `sqrt(X*X + Y*Y)'. */
  280. #define hypot(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, hypot)
  281. /* Return the cube root of X. */
  282. #define cbrt(Val) __TGMATH_UNARY_REAL_ONLY (Val, cbrt)
  283. /* Nearest integer, absolute value, and remainder functions. */
  284. /* Smallest integral value not less than X. */
  285. #define ceil(Val) __TGMATH_UNARY_REAL_ONLY (Val, ceil)
  286. /* Absolute value of X. */
  287. #define fabs(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, fabs, cabs)
  288. /* Largest integer not greater than X. */
  289. #define floor(Val) __TGMATH_UNARY_REAL_ONLY (Val, floor)
  290. /* Floating-point modulo remainder of X/Y. */
  291. #define fmod(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmod)
  292. /* Round X to integral valuein floating-point format using current
  293. rounding direction, but do not raise inexact exception. */
  294. #define nearbyint(Val) __TGMATH_UNARY_REAL_ONLY (Val, nearbyint)
  295. /* Round X to nearest integral value, rounding halfway cases away from
  296. zero. */
  297. #define round(Val) __TGMATH_UNARY_REAL_ONLY (Val, round)
  298. /* Round X to the integral value in floating-point format nearest but
  299. not larger in magnitude. */
  300. #define trunc(Val) __TGMATH_UNARY_REAL_ONLY (Val, trunc)
  301. /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
  302. and magnitude congruent `mod 2^n' to the magnitude of the integral
  303. quotient x/y, with n >= 3. */
  304. #define remquo(Val1, Val2, Val3) \
  305. __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY (Val1, Val2, Val3, remquo)
  306. /* Round X to nearest integral value according to current rounding
  307. direction. */
  308. #define lrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long int, lrint)
  309. #define llrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long long int, llrint)
  310. /* Round X to nearest integral value, rounding halfway cases away from
  311. zero. */
  312. #define lround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long int, lround)
  313. #define llround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, long long int, llround)
  314. /* Return X with its signed changed to Y's. */
  315. #define copysign(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, copysign)
  316. /* Error and gamma functions. */
  317. #define erf(Val) __TGMATH_UNARY_REAL_ONLY (Val, erf)
  318. #define erfc(Val) __TGMATH_UNARY_REAL_ONLY (Val, erfc)
  319. #define tgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, tgamma)
  320. #define lgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, lgamma)
  321. /* Return the integer nearest X in the direction of the
  322. prevailing rounding mode. */
  323. #define rint(Val) __TGMATH_UNARY_REAL_ONLY (Val, rint)
  324. /* Return X + epsilon if X < Y, X - epsilon if X > Y. */
  325. #define nextafter(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, nextafter)
  326. #define nexttoward(Val1, Val2) \
  327. __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, nexttoward)
  328. /* Return the remainder of integer divison X / Y with infinite precision. */
  329. #define remainder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, remainder)
  330. /* Return X times (2 to the Nth power). */
  331. #ifdef __USE_MISC
  332. # define scalb(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, scalb)
  333. #endif
  334. /* Return X times (2 to the Nth power). */
  335. #define scalbn(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbn)
  336. /* Return X times (2 to the Nth power). */
  337. #define scalbln(Val1, Val2) \
  338. __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln)
  339. /* Return the binary exponent of X, which must be nonzero. */
  340. #define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, int, ilogb)
  341. /* Return positive difference between X and Y. */
  342. #define fdim(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fdim)
  343. /* Return maximum numeric value from X and Y. */
  344. #define fmax(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmax)
  345. /* Return minimum numeric value from X and Y. */
  346. #define fmin(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmin)
  347. /* Multiply-add function computed as a ternary operation. */
  348. #define fma(Val1, Val2, Val3) \
  349. __TGMATH_TERNARY_REAL_ONLY (Val1, Val2, Val3, fma)
  350. /* Absolute value, conjugates, and projection. */
  351. /* Argument value of Z. */
  352. #define carg(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, carg, carg)
  353. /* Complex conjugate of Z. */
  354. #define conj(Val) __TGMATH_UNARY_IMAG (Val, conj)
  355. /* Projection of Z onto the Riemann sphere. */
  356. #define cproj(Val) __TGMATH_UNARY_IMAG (Val, cproj)
  357. /* Decomposing complex values. */
  358. /* Imaginary part of Z. */
  359. #define cimag(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, cimag, cimag)
  360. /* Real part of Z. */
  361. #define creal(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, creal, creal)
  362. #endif /* tgmath.h */