The header
#include <tgmath.h>
provides type-generic macros
for
#include <math.h>
and
#include <complex.h>
functions that have
Vt float
(suffixed with
f )
Vt double
and
Vt long double
(suffixed with
l
versions.
The arguments that vary across the three functions and have type
Vt float , double
and
Vt long double ,
respectively, are called
generic arguments
The following rules describe which function is actually called if a
type-generic macro is invoked.
If any generic argument has type
Vt long double
or
Vt long double complex ,
the
Vt long double
function is called.
Else, if any generic argument has type
Vt double , double complex
or an integer type, the
Vt double
version is invoked.
Otherwise, the macro expands to the
Vt float
implementation.
For the macros in the following table, both real and complex functions
exist.
The real functions are prototyped in
#include <math.h>
and the complex equivalents in
In complex.h .
The complex function is called if any of the generic arguments is a
complex value.
Otherwise, the real equivalent is called.
Macro Ta real function Ta complex function
Fn acos Ta Fn acos Ta Fn cacos
Fn asin Ta Fn asin Ta Fn casin
Fn atan Ta Fn atan Ta Fn catan
Fn acosh Ta Fn acosh Ta Fn cacosh
Fn asinh Ta Fn asinh Ta Fn casinh
Fn atanh Ta Fn atanh Ta Fn catanh
Fn cos Ta Fn cos Ta Fn ccos
Fn sin Ta Fn sin Ta Fn csin
Fn tan Ta Fn tan Ta Fn ctan
Fn cosh Ta Fn cosh Ta Fn ccosh
Fn sinh Ta Fn sinh Ta Fn csinh
Fn tanh Ta Fn tanh Ta Fn ctanh
Fn exp Ta Fn exp Ta Fn cexp
Fn log Ta Fn log Ta Fn clog
Fn pow Ta Fn pow Ta Fn cpow
Fn fabs Ta Fn fabs Ta Fn cabs
No complex functions exist for the following macros, so passing a
complex value to a generic argument invokes undefined behaviour:
Fn atan2 Ta Fn fma Ta Fn llround Ta Fn remainder
Fn cbrt Ta Fn fmax Ta Fn log10 Ta Fn remquo
Fn ceil Ta Fn fmin Ta Fn log1p Ta Fn rint
Fn copysign Ta Fn fmod Ta Fn log2 Ta Fn round
Fn erf Ta Fn frexp Ta Fn logb Ta Fn scalbn
Fn erfc Ta Fn hypot Ta Fn lrint Ta Fn scalbln
Fn exp2 Ta Fn ilogb Ta Fn lround Ta Fn tgamma
Fn expm1 Ta Fn ldexp Ta Fn nextbyint Ta Fn trunc
Fn fdim Ta Fn lgamma Ta Fn nextafter
Fn floor Ta Fn llrint Ta Fn nexttoward
The following macros always expand to a complex function:
Fn carg Ta Fn cimag Ta Fn conj Ta Fn cproj Ta Fn creal
This header includes
#include <complex.h>
and
In math.h .
STANDARDS
The header
#include <tgmath.h>
conforms to
St -isoC-99 .
HISTORY
The header
#include <tgmath.h>
first appeared in
Fx 5.3 .
BUGS
The header
#include <tgmath.h>
cannot be implemented with strictly conforming C code and needs
special compiler support.
The current implementation only works for GCC.
Many of the functions mentioned here are not prototyped in
#include <math.h>
or
#include <complex.h>
as they are not yet implemented.