tgmath.h, tgmath - type-generic macros
#include <tgmath.h>
The <tgmath.h> header includes the headers <math.h> and <complex.h> and defines several type-generic macros.
Of the functions contained within the <math.h> and <complex.h> headers without an f (float) or l (long double) suffix, several have one or more parameters whose corresponding real type is double. For each such function except modf(3M), there is a corresponding type-generic macro. The parameters whose corresponding real type is double in the function synopsis are generic parameters. Use of the macro invokes a function whose corresponding real type and type domain are determined by the arguments for the generic parameters.
Use of the macro invokes a function whose generic parameters have the corresponding real type determined as follows:
For each unsuffixed function in the <math.h> header for which there is a function in the <complex.h> header with the same name except for a c prefix, the corresponding type-generic macro (for both functions) has the same name as the function in the <math.h> header. The corresponding type-generic macro for fabs() and cabs() is fabs().
<math.h> Function | <complex.h> Function | Type-Generic Macro |
acos() | cacos() | acos() |
asin() | ||
atan() | ||
acosh() | ||
asinh() | ||
atanh() | ||
cos() | ||
sin() | ||
tan() | ||
cosh() | ||
sinh() | ||
tanh() | ||
exp() | ||
log() | ||
pow() | ||
sqrt() | ||
fabs() |
If at least one argument for a generic parameter is complex, then use of the macro invokes a complex function; otherwise, use of the macro invokes a real function.
For each unsuffixed function in the <math.h> header without a c-prefixed counterpart in the <complex.h> header, the corresponding type-generic macro has the same name as the function. These type-generic macros are:
atan2() fma() llround() remainder() cbrt() fmax() log10() remquo() ceil() fmin() log1p() rint() copysign() fmod() log2() round() erf() frexp() logb() scalbn() erfc() hypot() lrint() scalbln() exp2() ilogb() lround() tgamma() expm1() ldexp() nearbyint() trunc() fdim() lgamma() nextafter() floor() llrint() nexttoward()
If all arguments for generic parameters are real, then use of the macro invokes a real function; otherwise, use of the macro results in undefined behavior.
For each unsuffixed function in the <complex.h> header that is not a c-prefixed counterpart to a function in the <math.h> header, the corresponding type-generic macro has the same name as the function. These type-generic macros are:
carg() cimag() conj() cproj() creal()
Use of the macro with any real or complex argument invokes a complex function.
Functions invoked by use of type-generic macros are invoked with the declarations listed below.
#include <tgmath.h> int n; float f; double d; long double ld; float complex fc; double complex dc; long double complex ldc;
The following are the type-generic macros that invoke the functions that are invoked with the preceding declarations.
Macro | Use Invokes |
exp(n) | exp(n), the function |
acosh(f) | |
sin(d) | |
atan(ld) | |
log(fc) | |
sqrt(dc) | |
pow(ldc,f) | |
remainder(n,n) | |
nextafter(d,f) | |
nexttoward(f,ld) | |
copysign(n,ld) | |
ceil(fc) | |
rint(dc) | |
fmax(ldc,ld) | |
carg(n) | |
cproj(f) | |
creal(d) | |
cimag(ld) | |
cabs(fc) | |
carg(dc) | |
cproj(ldc) |
See attributes(5) for descriptions of the following attributes:
|
modf(3M), complex.h(3HEAD), math.h(3HEAD), cabs(3M), fabs(3M), attributes(5), standards(5)
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |