tgmath.h 18 KB

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