tgmath.h 18 KB

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