1.4. Mathematical Functions

CUDA mathematical functions are always available in device code.

Host implementations of the common mathematical functions are mapped in a platform-specific way to standard math library functions, provided by the host compiler and respective host libm where available. Some functions, not available with the host compilers, are implemented in crt/math_functions.hpp header file. For example, see erfinv(). Other, less common functions, like rhypot(), cyl_bessel_i0() are only available in device code.

Note that many floating-point and integer functions names are overloaded for different argument types. For example, the log() function has the following prototypes:

‎ double log(double x);
       float log(float x);
       float logf(float x);

Note also that due to implementation constraints, certain math functions from std:: namespace may be callable in device code even via explicitly qualified std:: names. However, such use is discouraged, since this capability is unsupported, unverified, undocumented, not portable, and may change without notice.