CUDA Math API Reference Manual (Release 12.9) May 31, 2025 - page 4

 

  Index      Manuals     CUDA Math API Reference Manual (Release 12.9) May 31, 2025

 

Search            copyright infringement  

 

   

 

   

 

Content      ..     2      3      4      5     ..

 

 

 

CUDA Math API Reference Manual (Release 12.9) May 31, 2025 - page 4

 

 

erfcf( -∞ ) returns 2.
erfcf( + ) returns +0.
erfcf(NaN) returns NaN.
__device__ float erfcinvf(float x)
Calculate the inverse complementary error function of the input argument.
Calculate the inverse complementary error function erfc-1 (x), of the input argument x in the
interval [0, 2].
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
erfcinvf( ±0 ) returns +.
erfcinvf(2) returns -∞.
erfcinvf(x) returns NaN for x outside [0, 2].
erfcinvf(NaN) returns NaN.
__device__ float erfcxf(float x)
Calculate the scaled complementary error function of the input argument.
Calculate the scaled complementary error function of the input argument x, ex2 · erfc(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
erfcxf( -∞ ) returns +.
erfcxf( + ) returns +0.
erfcxf(NaN) returns NaN.
__device__ float erff(float x)
Calculate the error function of the input argument.
x
2
Calculate the value of the error function for the input argument x,
e-t2 dt.
π
0
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
erff( ±0 ) returns ±0.
6.1. Functions
235
erff( ±∞ ) returns ±1.
erff(NaN) returns NaN.
__device__ float erfinvf(float x)
Calculate the inverse error function of the input argument.
Calculate the inverse error function erf-1 (x), of the input argument x in the interval [-1, 1].
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
erfinvf( ±0 ) returns ±0.
erfinvf(1) returns +.
erfinvf(-1) returns -∞.
erfinvf(x) returns NaN for x outside [-1, +1].
erfinvf(NaN) returns NaN.
__device__ float exp10f(float x)
Calculate the base 10 exponential of the input argument.
Calculate 10x , the base 10 exponential of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Note: This function is affected by the use_fast_math compiler flag. See the CUDA C++ Pro-
gramming Guide, Mathematical Functions Appendix, Intrinsic Functions section for a complete
list of functions affected.
Returns
exp10f( ±0 ) returns 1.
exp10f( -∞ ) returns +0.
exp10f( + ) returns +.
exp10f(NaN) returns NaN.
__device__ float exp2f(float x)
Calculate the base 2 exponential of the input argument.
Calculate 2x , the base 2 exponential of the input argument x.
236
Chapter 6. Single Precision Mathematical Functions
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
exp2f( ±0 ) returns 1.
exp2f( -∞ ) returns +0.
exp2f( + ) returns +.
exp2f(NaN) returns NaN.
__device__ float expf(float x)
Calculate the base e exponential of the input argument.
Calculate ex , the base e exponential of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Note: This function is affected by the use_fast_math compiler flag. See the CUDA C++ Pro-
gramming Guide, Mathematical Functions Appendix, Intrinsic Functions section for a complete
list of functions affected.
Returns
expf( ±0 ) returns 1.
expf( -∞ ) returns +0.
expf( + ) returns +.
expf(NaN) returns NaN.
__device__ float expm1f(float x)
Calculate the base e exponential of the input argument, minus 1.
Calculate ex -1, the base e exponential of the input argument x, minus 1.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
expm1f( ±0 ) returns ±0.
expm1f( -∞ ) returns -1.
expm1f( + ) returns +.
6.1. Functions
237
expm1f(NaN) returns NaN.
__device__ float fabsf(float x)
Calculate the absolute value of its argument.
Calculate the absolute value of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the absolute value of its argument.
fabsf( ±∞ ) returns +.
fabsf( ±0 ) returns +0.
fabsf(NaN) returns an unspecified NaN.
__device__ float fdimf(float x, float y)
Compute the positive difference between x and y.
Compute the positive difference between x and y. The positive difference is x - y when x > y and
+0 otherwise.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the positive difference between x and y.
fdimf(x, y) returns x - y if x > y.
fdimf(x, y) returns +0 if x y.
If either argument is NaN, NaN is returned.
__device__ float fdividef(float x, float y)
Divide two floating-point values.
Compute x divided by y.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Note: This function is affected by the use_fast_math compiler flag. See the CUDA C++ Pro-
gramming Guide, Mathematical Functions Appendix, Intrinsic Functions section for a complete
list of functions affected.
Returns
Returns x / y.
238
Chapter 6. Single Precision Mathematical Functions
Follows the regular division operation behavior by default.
If -use_fast_math is specified and is not amended by an explicit
-prec_div=true, uses __fdividef() for higher performance
__device__ float floorf(float x)
Calculate the largest integer less than or equal to x.
Calculate the largest integer value which is less than or equal to x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns ⌊x⌋ expressed as a floating-point number.
floorf( ±∞ ) returns ±∞.
floorf( ±0 ) returns ±0.
floorf(NaN) returns NaN.
__device__ float fmaf(float x, float y, float z)
Compute x × y + z as a single operation.
Compute the value of x×y +z as a single ternary operation. After computing the value to infinite
precision, the value is rounded once using round-to-nearest, ties-to-even rounding mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the rounded value of x × y + z as a single operation.
fmaf( ±∞ , ±0 , z) returns NaN.
fmaf( ±0 , ±∞ , z) returns NaN.
fmaf(x, y, -∞ ) returns NaN if x × y is an exact +.
fmaf(x, y, + ) returns NaN if x × y is an exact -∞.
fmaf(x, y, ±0) returns ±0 if x × y is exact ±0.
fmaf(x, y,0) returns +0 if x × y is exact ±0.
fmaf(x, y, z) returns +0 if x × y + z is exactly zero and z = 0.
If either argument is NaN, NaN is returned.
__device__ float fmaxf(float x, float y)
Determine the maximum numeric value of the arguments.
Determines the maximum numeric value of the arguments x and y. Treats NaN arguments as
missing data. If one argument is a NaN and the other is legitimate numeric value, the numeric
value is chosen.
6.1. Functions
239
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the maximum numeric values of the arguments x and y.
If both arguments are NaN, returns NaN.
If one argument is NaN, returns the numeric argument.
__device__ float fminf(float x, float y)
Determine the minimum numeric value of the arguments.
Determines the minimum numeric value of the arguments x and y. Treats NaN arguments as
missing data. If one argument is a NaN and the other is legitimate numeric value, the numeric
value is chosen.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the minimum numeric value of the arguments x and y.
If both arguments are NaN, returns NaN.
If one argument is NaN, returns the numeric argument.
__device__ float fmodf(float x, float y)
Calculate the floating-point remainder of x / y.
Calculate the floating-point remainder of x / y. The floating-point remainder of the division op-
eration x / y calculated by this function is exactly the value x - n*y, where n is x / y with its
fractional part truncated. The computed value will have the same sign as x, and its magnitude
will be less than the magnitude of y.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the floating-point remainder of x / y.
fmodf( ±0 , y) returns ±0 if y is not zero.
fmodf(x, ±∞ ) returns x if x is finite.
fmodf(x, y) returns NaN if x is ±∞ or y is zero.
If either argument is NaN, NaN is returned.
240
Chapter 6. Single Precision Mathematical Functions
__device__ float frexpf(float x, int *nptr)
Extract mantissa and exponent of a floating-point value.
Decomposes the floating-point value x into a component m for the normalized fraction element
and another term n for the exponent. The absolute value of m will be greater than or equal to 0.5
and less than 1.0 or it will be equal to 0; x = m · 2n. The integer exponent n will be stored in the
location to which nptr points.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the fractional component m.
frexpf( ±0 , nptr) returns ±0 and stores zero in the location pointed to by nptr.
frexpf( ±∞ , nptr) returns ±∞ and stores an unspecified value in the location
to which nptr points.
frexpf(NaN, y) returns a NaN and stores an unspecified value in the location to
which nptr points.
__device__ float hypotf(float x, float y)
Calculate the square root of the sum of squares of two arguments.
Calculates the length of the hypotenuse of a right triangle whose two sides have lengths x and
y without undue overflow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the length of the hypotenuse
x2 + y2.
hypotf(x,y), hypotf(y,x), and hypotf(x, -y) are equivalent.
hypotf(x, ±0 ) is equivalent to fabsf(x).
hypotf( ±∞ ,y) returns + , even if y is a NaN.
hypotf(NaN, y) returns NaN, when y is not ±∞.
__device__ int ilogbf(float x)
Compute the unbiased integer exponent of the argument.
Calculates the unbiased integer exponent of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
If successful, returns the unbiased exponent of the argument.
6.1. Functions
241
ilogbf( ±0 ) returns INT_MIN.
ilogbf(NaN) returns INT_MIN.
ilogbf( ±∞ ) returns INT_MAX.
Note: above behavior does not take into account FP_ILOGB0 nor FP_ILOGBNAN.
__device__ __RETURN_TYPE isfinite(float a)
Determine whether argument is finite.
Determine whether the floating-point value a is a finite value (zero, subnormal, or normal and not
infinity or NaN).
Returns
With Visual Studio 2013 host compiler: __RETURN_TYPE is ‘bool’. Returns true
if and only if a is a finite value.
With other host compilers: __RETURN_TYPE is ‘int’. Returns a nonzero value if
and only if a is a finite value.
__device__ __RETURN_TYPE isinf(float a)
Determine whether argument is infinite.
Determine whether the floating-point value a is an infinite value (positive or negative).
Returns
With Visual Studio 2013 host compiler: __RETURN_TYPE is ‘bool’. Returns true
if and only if a is an infinite value.
With other host compilers: __RETURN_TYPE is ‘int’. Returns a nonzero value if
and only if a is an infinite value.
__device__ __RETURN_TYPE isnan(float a)
Determine whether argument is a NaN.
Determine whether the floating-point value a is a NaN.
Returns
With Visual Studio 2013 host compiler: __RETURN_TYPE is ‘bool’. Returns true
if and only if a is a NaN value.
With other host compilers: __RETURN_TYPE is ‘int’. Returns a nonzero value if
and only if a is a NaN value.
__device__ float j0f(float x)
Calculate the value of the Bessel function of the first kind of order 0 for the input argument.
Calculate the value of the Bessel function of the first kind of order 0 for the input argument x,
J0(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
242
Chapter 6. Single Precision Mathematical Functions
Returns
Returns the value of the Bessel function of the first kind of order 0.
j0f( ±∞ ) returns +0.
j0f(NaN) returns NaN.
__device__ float j1f(float x)
Calculate the value of the Bessel function of the first kind of order 1 for the input argument.
Calculate the value of the Bessel function of the first kind of order 1 for the input argument x,
J1(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the value of the Bessel function of the first kind of order 1.
j1f( ±0 ) returns ±0.
j1f( ±∞ ) returns ±0.
j1f(NaN) returns NaN.
__device__ float jnf(int n, float x)
Calculate the value of the Bessel function of the first kind of order n for the input argument.
Calculate the value of the Bessel function of the first kind of order n for the input argument x,
Jn(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the value of the Bessel function of the first kind of order n.
jnf(n, NaN) returns NaN.
jnf(n, x) returns NaN for n < 0.
jnf(n, + ) returns +0.
__device__ float ldexpf(float x, int exp)
Calculate the value of x · 2exp.
Calculate the value of x · 2exp of the input arguments x and exp.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
ldexpf(x, exp) is equivalent to scalbnf(x, exp).
6.1. Functions
243
__device__ float lgammaf(float x)
Calculate the natural logarithm of the absolute value of the gamma function of the input argu-
ment.
Calculate the natural logarithm of the absolute value of the gamma function of the input argu-
ment x, namely the value of loge |Γ(x)|
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
lgammaf(1) returns +0.
lgammaf(2) returns +0.
lgammaf(x) returns + if x 0 and x is an integer.
lgammaf( -∞ ) returns +.
lgammaf( + ) returns +.
lgammaf(NaN) returns NaN.
__device__ long long int llrintf(float x)
Round input to nearest integer value.
Round x to the nearest integer value, with halfway cases rounded to the nearest even integer
value. If the result is outside the range of the return type, the behavior is undefined.
Returns
Returns rounded integer value.
__device__ long long int llroundf(float x)
Round to nearest integer value.
Round x to the nearest integer value, with halfway cases rounded away from zero. If the result is
outside the range of the return type, the behavior is undefined.
Note: This function may be slower than alternate rounding methods. See llrintf().
Returns
Returns rounded integer value.
__device__ float log10f(float x)
Calculate the base 10 logarithm of the input argument.
Calculate the base 10 logarithm of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
244
Chapter 6. Single Precision Mathematical Functions
Note: This function is affected by the use_fast_math compiler flag. See the CUDA C++ Pro-
gramming Guide, Mathematical Functions Appendix, Intrinsic Functions section for a complete
list of functions affected.
Returns
log10f( ±0 ) returns -∞.
log10f(1) returns +0.
log10f(x) returns NaN for x < 0.
log10f( + ) returns +.
log10f(NaN) returns NaN.
__device__ float log1pf(float x)
Calculate the value of loge(1 + x).
Calculate the value of loge(1 + x) of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
log1pf( ±0 ) returns ±0.
log1pf(-1) returns -∞.
log1pf(x) returns NaN for x < -1.
log1pf( + ) returns +.
log1pf(NaN) returns NaN.
__device__ float log2f(float x)
Calculate the base 2 logarithm of the input argument.
Calculate the base 2 logarithm of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Note: This function is affected by the use_fast_math compiler flag. See the CUDA C++ Pro-
gramming Guide, Mathematical Functions Appendix, Intrinsic Functions section for a complete
list of functions affected.
Returns
6.1. Functions
245
log2f( ±0 ) returns -∞.
log2f(1) returns +0.
log2f(x) returns NaN for x < 0.
log2f( + ) returns +.
log2f(NaN) returns NaN.
__device__ float logbf(float x)
Calculate the floating-point representation of the exponent of the input argument.
Calculate the floating-point representation of the exponent of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
logbf( ±0 ) returns -∞.
logbf( ±∞ ) returns +.
logbf(NaN) returns NaN.
__device__ float logf(float x)
Calculate the natural logarithm of the input argument.
Calculate the natural logarithm of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Note: This function is affected by the use_fast_math compiler flag. See the CUDA C++ Pro-
gramming Guide, Mathematical Functions Appendix, Intrinsic Functions section for a complete
list of functions affected.
Returns
logf( ±0 ) returns -∞.
logf(1) returns +0.
logf(x) returns NaN for x < 0.
logf( + ) returns +.
logf(NaN) returns NaN.
246
Chapter 6. Single Precision Mathematical Functions
__device__ long int lrintf(float x)
Round input to nearest integer value.
Round x to the nearest integer value, with halfway cases rounded to the nearest even integer
value. If the result is outside the range of the return type, the behavior is undefined.
Returns
Returns rounded integer value.
__device__ long int lroundf(float x)
Round to nearest integer value.
Round x to the nearest integer value, with halfway cases rounded away from zero. If the result is
outside the range of the return type, the behavior is undefined.
Note: This function may be slower than alternate rounding methods. See lrintf().
Returns
Returns rounded integer value.
__device__ float max(const float a, const float b)
Calculate the maximum value of the input float arguments.
Calculate the maximum value of the arguments a and b. Behavior is equivalent to fmaxf() func-
tion.
Note, this is different from std:: specification
__device__ float min(const float a, const float b)
Calculate the minimum value of the input float arguments.
Calculate the minimum value of the arguments a and b. Behavior is equivalent to fminf() function.
Note, this is different from std:: specification
__device__ float modff(float x, float *iptr)
Break down the input argument into fractional and integral parts.
Break down the argument x into fractional and integral parts. The integral part is stored in the
argument iptr. Fractional and integral parts are given the same sign as the argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
modff( ±x , iptr) returns a result with the same sign as x.
modff( ±∞ , iptr) returns ±0 and stores ±∞ in the object pointed to by iptr.
modff(NaN, iptr) stores a NaN in the object pointed to by iptr and returns a
NaN.
6.1. Functions
247
__device__ float nanf(const char *tagp)
Returns “Not a Number” value.
Return a representation of a quiet NaN. Argument tagp selects one of the possible representa-
tions.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
nanf(tagp) returns NaN.
__device__ float nearbyintf(float x)
Round the input argument to the nearest integer.
Round argument x to an integer value in single precision floating-point format. Uses round to
nearest rounding, with ties rounding to even.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
nearbyintf( ±0 ) returns ±0.
nearbyintf( ±∞ ) returns ±∞.
nearbyintf(NaN) returns NaN.
__device__ float nextafterf(float x, float y)
Return next representable single-precision floating-point value after argument x in the direction
of y.
Calculate the next representable single-precision floating-point value following x in the direction
of y. For example, if y is greater than x, nextafterf() returns the smallest representable number
greater than x
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
nextafterf(x, y) = y if x equals y.
nextafterf(x, y) = NaN if either x or y are NaN.
248
Chapter 6. Single Precision Mathematical Functions
__device__ float norm3df(float a, float b, float c)
Calculate the square root of the sum of squares of three coordinates of the argument.
Calculates the length of three dimensional vector in Euclidean space without undue overflow or
underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the length of the 3D vector
a2 + b2 + c2.
In the presence of an exactly infinite coordinate + is returned, even if there
are NaNs.
returns +0, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
__device__ float norm4df(float a, float b, float c, float d)
Calculate the square root of the sum of squares of four coordinates of the argument.
Calculates the length of four dimensional vector in Euclidean space without undue overflow or
underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the length of the 4D vector
a2 + b2 + c2 + d2.
In the presence of an exactly infinite coordinate + is returned, even if there
are NaNs.
returns +0, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
__device__ float normcdff(float x)
Calculate the standard normal cumulative distribution function.
Calculate the cumulative distribution function of the standard normal distribution for input ar-
gument x, Φ(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
normcdff( + ) returns 1.
normcdff( -∞ ) returns +0
normcdff(NaN) returns NaN.
6.1. Functions
249
__device__ float normcdfinvf(float x)
Calculate the inverse of the standard normal cumulative distribution function.
Calculate the inverse of the standard normal cumulative distribution function for input argument
x, Φ-1(x). The function is defined for input values in the interval (0, 1).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
normcdfinvf( ±0 ) returns -∞.
normcdfinvf(1) returns +.
normcdfinvf(x) returns NaN if x is not in the interval [0,1].
normcdfinvf(NaN) returns NaN.
__device__ float normf(int dim, float const *p)
Calculate the square root of the sum of squares of any number of coordinates.
Calculates the length of a vector p, dimension of which is passed as an argument without undue
overflow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
√∑dim-1
Returns the length of the dim-D vector
p2i.
i=0
In the presence of an exactly infinite coordinate + is returned, even if there
are NaNs.
returns +0, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
__device__ float powf(float x, float y)
Calculate the value of first argument to the power of second argument.
Calculate the value of x to the power of y.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Note: This function is affected by the use_fast_math compiler flag. See the CUDA C++ Pro-
gramming Guide, Mathematical Functions Appendix, Intrinsic Functions section for a complete
list of functions affected.
250
Chapter 6. Single Precision Mathematical Functions
Returns
powf( ±0 , y) returns ±∞ for y an odd integer less than 0.
powf( ±0 , y) returns + for y less than 0 and not an odd integer.
powf( ±0 , y) returns ±0 for y an odd integer greater than 0.
powf( ±0 , y) returns +0 for y > 0 and not an odd integer.
powf(-1, ±∞ ) returns 1.
powf(+1, y) returns 1 for any y, even a NaN.
powf(x, ±0 ) returns 1 for any x, even a NaN.
powf(x, y) returns a NaN for finite x < 0 and finite non-integer y.
powf(x, -∞ ) returns + for |x| < 1.
powf(x, -∞ ) returns +0 for |x| > 1.
powf(x, + ) returns +0 for |x| < 1.
powf(x, + ) returns + for |x| > 1.
powf( -∞ , y) returns -0 for y an odd integer less than 0.
powf( -∞ , y) returns +0 for y < 0 and not an odd integer.
powf( -∞ , y) returns -∞ for y an odd integer greater than 0.
powf( -∞ , y) returns + for y > 0 and not an odd integer.
powf( + , y) returns +0 for y < 0.
powf( + , y) returns + for y > 0.
powf(x, y) returns NaN if either x or y or both are NaN and x = +1 and y = ±0.
__device__ float rcbrtf(float x)
Calculate reciprocal cube root function.
Calculate reciprocal cube root function of x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
rcbrtf( ±0 ) returns ±∞.
rcbrtf( ±∞ ) returns ±0.
rcbrtf(NaN) returns NaN.
__device__ float remainderf(float x, float y)
Compute single-precision floating-point remainder.
Compute single-precision floating-point remainder r of dividing x by y for nonzero y. Thus r =
x - ny. The value n is the integer value nearest xy. In the case when |n - xy| = 12 , the even n value
is chosen.
6.1. Functions
251
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
remainderf(x, ±0 ) returns NaN.
remainderf( ±∞ , y) returns NaN.
remainderf(x, ±∞ ) returns x for finite x.
If either argument is NaN, NaN is returned.
__device__ float remquof(float x, float y, int *quo)
Compute single-precision floating-point remainder and part of quotient.
Compute a single-precision floating-point remainder in the same way as the remainderf() func-
tion. Argument quo returns part of quotient upon division of x by y. Value quo has the same
sign asxy and may not be the exact quotient but agrees with the exact quotient in the low order
3 bits.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the remainder.
remquof(x, ±0 , quo) returns NaN and stores an unspecified value in the location
to which quo points.
remquof( ±∞ , y, quo) returns NaN and stores an unspecified value in the loca-
tion to which quo points.
remquof(x, y, quo) returns NaN and stores an unspecified value in the location
to which quo points if either of x or y is NaN.
remquof(x, ±∞ , quo) returns x and stores zero in the location to which quo
points for finite x.
__device__ float rhypotf(float x, float y)
Calculate one over the square root of the sum of squares of two arguments.
Calculates one over the length of the hypotenuse of a right triangle whose two sides have lengths
x and y without undue overflow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
1
Returns one over the length of the hypotenuse
x2+y2
rhypotf(x,y), rhypotf(y,x), and rhypotf(x, -y) are equivalent.
252
Chapter 6. Single Precision Mathematical Functions
rhypotf( ±∞ ,y) returns +0, even if y is a NaN.
rhypotf( ±0, ±0) returns +.
rhypotf(NaN, y) returns NaN, when y is not ±∞.
__device__ float rintf(float x)
Round input to nearest integer value in floating-point.
Round x to the nearest integer value in floating-point format, with halfway cases rounded to the
nearest even integer value.
Returns
Returns rounded integer value.
rintf( ±0 ) returns ±0.
rintf( ±∞ ) returns ±∞.
rintf(NaN) returns NaN.
__device__ float rnorm3df(float a, float b, float c)
Calculate one over the square root of the sum of squares of three coordinates.
Calculates one over the length of three dimension vector in Euclidean space without undue over-
flow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
1
Returns one over the length of the 3D vector
a2+b2+c2
In the presence of an exactly infinite coordinate +0 is returned, even if there are
NaNs.
returns +, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
__device__ float rnorm4df(float a, float b, float c, float d)
Calculate one over the square root of the sum of squares of four coordinates.
Calculates one over the length of four dimension vector in Euclidean space without undue over-
flow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
1
Returns one over the length of the 3D vector
a2+b2+c2+d2
In the presence of an exactly infinite coordinate +0 is returned, even if there are
NaNs.
returns +, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
6.1. Functions
253
__device__ float rnormf(int dim, float const *p)
Calculate the reciprocal of square root of the sum of squares of any number of coordinates.
Calculates one over the length of vector p, dimension of which is passed as an argument, in
Euclidean space without undue overflow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
1
Returns one over the length of the vector
dim-1
i=0
p2
i
In the presence of an exactly infinite coordinate +0 is returned, even if there are
NaNs.
returns +, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
__device__ float roundf(float x)
Round to nearest integer value in floating-point.
Round x to the nearest integer value in floating-point format, with halfway cases rounded away
from zero.
Note: This function may be slower than alternate rounding methods. See rintf().
Returns
Returns rounded integer value.
roundf( ±0 ) returns ±0.
roundf( ±∞ ) returns ±∞.
roundf(NaN) returns NaN.
__device__ float rsqrtf(float x)
Calculate the reciprocal of the square root of the input argument.
Calculate the reciprocal of the nonnegative square root of x, 1/x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns 1/x.
rsqrtf( + ) returns +0.
rsqrtf( ±0 ) returns ±∞.
rsqrtf(x) returns NaN if x is less than 0.
rsqrtf(NaN) returns NaN.
254
Chapter 6. Single Precision Mathematical Functions
__device__ float scalblnf(float x, long int n)
Scale floating-point input by integer power of two.
Scale x by 2n by efficient manipulation of the floating-point exponent.
Returns
Returns x * 2n.
scalblnf( ±0 , n) returns ±0.
scalblnf(x, 0) returns x.
scalblnf( ±∞ , n) returns ±∞.
scalblnf(NaN, n) returns NaN.
__device__ float scalbnf(float x, int n)
Scale floating-point input by integer power of two.
Scale x by 2n by efficient manipulation of the floating-point exponent.
Returns
Returns x * 2n.
scalbnf( ±0 , n) returns ±0.
scalbnf(x, 0) returns x.
scalbnf( ±∞ , n) returns ±∞.
scalbnf(NaN, n) returns NaN.
__device__ __RETURN_TYPE signbit(float a)
Return the sign bit of the input.
Determine whether the floating-point value a is negative.
Returns
Reports the sign bit of all values including infinities, zeros, and NaNs.
With Visual Studio 2013 host compiler: __RETURN_TYPE is ‘bool’. Returns true
if and only if a is negative.
With other host compilers: __RETURN_TYPE is ‘int’. Returns a nonzero value if
and only if a is negative.
__device__ void sincosf(float x, float *sptr, float *cptr)
Calculate the sine and cosine of the first input argument.
Calculate the sine and cosine of the first input argument x (measured in radians). The results for
sine and cosine are written into the second argument, sptr, and, respectively, third argument,
cptr.
See also:
sinf() and cosf().
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
6.1. Functions
255
Note: This function is affected by the use_fast_math compiler flag. See the CUDA C++ Pro-
gramming Guide, Mathematical Functions Appendix, Intrinsic Functions section for a complete
list of functions affected.
__device__ void sincospif(float x, float *sptr, float *cptr)
Calculate the sine and cosine of the first input argument ×π.
Calculate the sine and cosine of the first input argument, x (measured in radians), ×π. The results
for sine and cosine are written into the second argument, sptr, and, respectively, third argument,
cptr.
See also:
sinpif() and cospif().
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
__device__ float sinf(float x)
Calculate the sine of the input argument.
Calculate the sine of the input argument x (measured in radians).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Note: This function is affected by the use_fast_math compiler flag. See the CUDA C++ Pro-
gramming Guide, Mathematical Functions Appendix, Intrinsic Functions section for a complete
list of functions affected.
Returns
sinf( ±0 ) returns ±0.
sinf( ±∞ ) returns NaN.
sinf(NaN) returns NaN.
__device__ float sinhf(float x)
Calculate the hyperbolic sine of the input argument.
Calculate the hyperbolic sine of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
256
Chapter 6. Single Precision Mathematical Functions
sinhf( ±0 ) returns ±0.
sinhf( ±∞ ) returns ±∞.
sinhf(NaN) returns NaN.
__device__ float sinpif(float x)
Calculate the sine of the input argument ×π.
Calculate the sine of x ×π (measured in radians), where x is the input argument.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
sinpif( ±0 ) returns ±0.
sinpif( ±∞ ) returns NaN.
sinpif(NaN) returns NaN.
__device__ float sqrtf(float x)
Calculate the square root of the input argument.
Calculate the nonnegative square root of x,
x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns
x.
sqrtf( ±0 ) returns ±0.
sqrtf( + ) returns +.
sqrtf(x) returns NaN if x is less than 0.
sqrtf(NaN) returns NaN.
__device__ float tanf(float x)
Calculate the tangent of the input argument.
Calculate the tangent of the input argument x (measured in radians).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Note: This function is affected by the use_fast_math compiler flag. See the CUDA C++ Pro-
gramming Guide, Mathematical Functions Appendix, Intrinsic Functions section for a complete
list of functions affected.
6.1. Functions
257
Returns
tanf( ±0 ) returns ±0.
tanf( ±∞ ) returns NaN.
tanf(NaN) returns NaN.
__device__ float tanhf(float x)
Calculate the hyperbolic tangent of the input argument.
Calculate the hyperbolic tangent of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
tanhf( ±0 ) returns ±0.
tanhf( ±∞ ) returns ±1.
tanhf(NaN) returns NaN.
__device__ float tgammaf(float x)
Calculate the gamma function of the input argument.
Calculate the gamma function of the input argument x, namely the value of Γ(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
tgammaf( ±0 ) returns ±∞.
tgammaf(x) returns NaN if x < 0 and x is an integer.
tgammaf( -∞ ) returns NaN.
tgammaf( + ) returns +.
tgammaf(NaN) returns NaN.
__device__ float truncf(float x)
Truncate input argument to the integral part.
Round x to the nearest integer value that does not exceed x in magnitude.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
258
Chapter 6. Single Precision Mathematical Functions
Returns
Returns truncated integer value.
truncf( ±0 ) returns ±0.
truncf( ±∞ ) returns ±∞.
truncf(NaN) returns NaN.
__device__ float y0f(float x)
Calculate the value of the Bessel function of the second kind of order 0 for the input argument.
Calculate the value of the Bessel function of the second kind of order 0 for the input argument
x, Y0(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the value of the Bessel function of the second kind of order 0.
y0f( ±0 ) returns -∞.
y0f(x) returns NaN for x < 0.
y0f( + ) returns +0.
y0f(NaN) returns NaN.
__device__ float y1f(float x)
Calculate the value of the Bessel function of the second kind of order 1 for the input argument.
Calculate the value of the Bessel function of the second kind of order 1 for the input argument
x, Y1(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the value of the Bessel function of the second kind of order 1.
y1f( ±0 ) returns -∞.
y1f(x) returns NaN for x < 0.
y1f( + ) returns +0.
y1f(NaN) returns NaN.
__device__ float ynf(int n, float x)
Calculate the value of the Bessel function of the second kind of order n for the input argument.
Calculate the value of the Bessel function of the second kind of order n for the input argument
x, Yn(x).
6.1. Functions
259
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Single-Precision Floating-Point Functions section.
Returns
Returns the value of the Bessel function of the second kind of order n.
ynf(n, x) returns NaN for n < 0.
ynf(n, ±0 ) returns -∞.
ynf(n, x) returns NaN for x < 0.
ynf(n, + ) returns +0.
ynf(n, NaN) returns NaN.
260
Chapter 6. Single Precision Mathematical Functions
Chapter 7. Single Precision Intrinsics
This section describes single precision intrinsic functions that are only supported in device code.
To use these functions, you do not need to include any additional header file in your program.
Functions
__device__ float __cosf(float x)
Calculate the fast approximate cosine of the input argument.
__device__ float __exp10f(float x)
Calculate the fast approximate base 10 exponential of the input argument.
__device__ float __expf(float x)
Calculate the fast approximate base e exponential of the input argument.
__device__ float2 __fadd2_rd(float2 x, float2 y)
Compute vector add operation x + y in round-down mode.
__device__ float2 __fadd2_rn(float2 x, float2 y)
Compute vector add operation x + y in round-to-nearest-even mode.
__device__ float2 __fadd2_ru(float2 x, float2 y)
Compute vector add operation x + y in round-up mode.
__device__ float2 __fadd2_rz(float2 x, float2 y)
Compute vector add operation x + y in round-towards-zero mode.
__device__ float __fadd_rd(float x, float y)
Add two floating-point values in round-down mode.
__device__ float __fadd_rn(float x, float y)
Add two floating-point values in round-to-nearest-even mode.
__device__ float __fadd_ru(float x, float y)
Add two floating-point values in round-up mode.
__device__ float __fadd_rz(float x, float y)
Add two floating-point values in round-towards-zero mode.
__device__ float __fdiv_rd(float x, float y)
Divide two floating-point values in round-down mode.
__device__ float __fdiv_rn(float x, float y)
Divide two floating-point values in round-to-nearest-even mode.
__device__ float __fdiv_ru(float x, float y)
Divide two floating-point values in round-up mode.
261
__device__ float __fdiv_rz(float x, float y)
Divide two floating-point values in round-towards-zero mode.
__device__ float __fdividef(float x, float y)
Calculate the fast approximate division of the input arguments.
__device__ float2 __ffma2_rd(float2 x, float2 y, float2 z)
Compute vector fused multiply-add operation x × y + z in round-down mode.
__device__ float2 __ffma2_rn(float2 x, float2 y, float2 z)
Compute vector fused multiply-add operation x × y + z in round-to-nearest-even mode.
__device__ float2 __ffma2_ru(float2 x, float2 y, float2 z)
Compute vector fused multiply-add operation x × y + z in round-up mode.
__device__ float2 __ffma2_rz(float2 x, float2 y, float2 z)
Compute vector fused multiply-add operation x × y + z in round-towards-zero mode.
__device__ float __fmaf_ieee_rd(float x, float y, float z)
Compute fused multiply-add operation in round-down mode, ignore -ftz=true compiler flag.
__device__ float __fmaf_ieee_rn(float x, float y, float z)
Compute fused multiply-add operation in round-to-nearest-even mode, ignore -ftz=true com-
piler flag.
__device__ float __fmaf_ieee_ru(float x, float y, float z)
Compute fused multiply-add operation in round-up mode, ignore -ftz=true compiler flag.
__device__ float __fmaf_ieee_rz(float x, float y, float z)
Compute fused multiply-add operation in round-towards-zero mode, ignore -ftz=true compiler
flag.
__device__ float __fmaf_rd(float x, float y, float z)
Compute x × y + z as a single operation, in round-down mode.
__device__ float __fmaf_rn(float x, float y, float z)
Compute x × y + z as a single operation, in round-to-nearest-even mode.
__device__ float __fmaf_ru(float x, float y, float z)
Compute x × y + z as a single operation, in round-up mode.
__device__ float __fmaf_rz(float x, float y, float z)
Compute x × y + z as a single operation, in round-towards-zero mode.
__device__ float2 __fmul2_rd(float2 x, float2 y)
Compute vector multiply operation x × y in round-down mode.
__device__ float2 __fmul2_rn(float2 x, float2 y)
Compute vector multiply operation x × y in round-to-nearest-even mode.
__device__ float2 __fmul2_ru(float2 x, float2 y)
Compute vector multiply operation x × y in round-up mode.
__device__ float2 __fmul2_rz(float2 x, float2 y)
Compute vector multiply operation x × y in round-towards-zero mode.
__device__ float __fmul_rd(float x, float y)
Multiply two floating-point values in round-down mode.
__device__ float __fmul_rn(float x, float y)
Multiply two floating-point values in round-to-nearest-even mode.
__device__ float __fmul_ru(float x, float y)
Multiply two floating-point values in round-up mode.
262
Chapter 7. Single Precision Intrinsics
__device__ float __fmul_rz(float x, float y)
Multiply two floating-point values in round-towards-zero mode.
__device__ float __frcp_rd(float x)
Compute1x in round-down mode.
__device__ float __frcp_rn(float x)
Compute1x in round-to-nearest-even mode.
__device__ float __frcp_ru(float x)
Compute1x in round-up mode.
__device__ float __frcp_rz(float x)
Compute1x in round-towards-zero mode.
__device__ float frsqrt_rn(float x)
Compute 1/
x in round-to-nearest-even mode.
__device__ floa__fsqrt_rd(float x)
Compute
x in round-down mode.
__device__ floa__fsqrt_rn(float x)
Compute
x in round-to-nearest-even mode.
__device__ floa__fsqrt_ru(float x)
Compute
x in round-up mode.
__device__ floa__fsqrt_rz(float x)
Compute
x in round-towards-zero mode.
__device__ float __fsub_rd(float x, float y)
Subtract two floating-point values in round-down mode.
__device__ float __fsub_rn(float x, float y)
Subtract two floating-point values in round-to-nearest-even mode.
__device__ float __fsub_ru(float x, float y)
Subtract two floating-point values in round-up mode.
__device__ float __fsub_rz(float x, float y)
Subtract two floating-point values in round-towards-zero mode.
__device__ float __log10f(float x)
Calculate the fast approximate base 10 logarithm of the input argument.
__device__ float __log2f(float x)
Calculate the fast approximate base 2 logarithm of the input argument.
__device__ float __logf(float x)
Calculate the fast approximate base e logarithm of the input argument.
__device__ float __powf(float x, float y)
Calculate the fast approximate of xy .
__device__ float __saturatef(float x)
Clamp the input argument to [+0.0, 1.0].
__device__ void __sincosf(float x, float *sptr, float *cptr)
Calculate the fast approximate of sine and cosine of the first input argument.
__device__ float __sinf(float x)
Calculate the fast approximate sine of the input argument.
263
__device__ float __tanf(float x)
Calculate the fast approximate tangent of the input argument.
__device__ float __tanhf(float x)
Calculate the fast approximate hyperbolic tangent of the input argument.
7.1. Functions
__device__ float __cosf(float x)
Calculate the fast approximate cosine of the input argument.
Calculate the fast approximate cosine of the input argument x, measured in radians.
See also:
cosf() for further special case behavior specification.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns the approximate cosine of x.
__device__ float __exp10f(float x)
Calculate the fast approximate base 10 exponential of the input argument.
Calculate the fast approximate base 10 exponential of the input argument x, 10x.
See also:
exp10f() for further special case behavior specification.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns an approximation to 10x.
__device__ float __expf(float x)
Calculate the fast approximate base e exponential of the input argument.
Calculate the fast approximate base e exponential of the input argument x, ex.
See also:
expf() for further special case behavior specification.
264
Chapter 7. Single Precision Intrinsics
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns an approximation to ex.
__device__ float2 __fadd2_rd(float2 x, float2 y)
Compute vector add operation x + y in round-down mode.
Numeric behavior per component is the same as __fadd_rd().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
__device__ float2 __fadd2_rn(float2 x, float2 y)
Compute vector add operation x + y in round-to-nearest-even mode.
Numeric behavior per component is the same as __fadd_rn().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
__device__ float2 __fadd2_ru(float2 x, float2 y)
Compute vector add operation x + y in round-up mode.
Numeric behavior per component is the same as __fadd_ru().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
__device__ float2 __fadd2_rz(float2 x, float2 y)
Compute vector add operation x + y in round-towards-zero mode.
Numeric behavior per component is the same as __fadd_rz().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
7.1. Functions
265
__device__ float __fadd_rd(float x, float y)
Add two floating-point values in round-down mode.
Compute the sum of x and y in round-down (to negative infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x + y.
__fadd_rd(x, y) is equivalent to __fadd_rd(y, x).
__fadd_rd(x, ±∞) returns ±∞ for finite x.
__fadd_rd( ±∞, ±∞) returns ±∞.
__fadd_rd( ±∞, ∓∞) returns NaN.
__fadd_rd( ±0, ±0) returns ±0.
__fadd_rd(x, -x) returns -0 for finite x, including ±0.
If either argument is NaN, NaN is returned.
__device__ float __fadd_rn(float x, float y)
Add two floating-point values in round-to-nearest-even mode.
Compute the sum of x and y in round-to-nearest-even rounding mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x + y.
__fadd_rn(x, y) is equivalent to __fadd_rn(y, x).
__fadd_rn(x, ±∞) returns ±∞ for finite x.
__fadd_rn( ±∞, ±∞) returns ±∞.
__fadd_rn( ±∞, ∓∞) returns NaN.
__fadd_rn( ±0, ±0) returns ±0.
__fadd_rn(x, -x) returns +0 for finite x, including ±0.
If either argument is NaN, NaN is returned.
266
Chapter 7. Single Precision Intrinsics
__device__ float __fadd_ru(float x, float y)
Add two floating-point values in round-up mode.
Compute the sum of x and y in round-up (to positive infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x + y.
__fadd_ru(x, y) is equivalent to __fadd_ru(y, x).
__fadd_ru(x, ±∞) returns ±∞ for finite x.
__fadd_ru( ±∞, ±∞) returns ±∞.
__fadd_ru( ±∞, ∓∞) returns NaN.
__fadd_ru( ±0, ±0) returns ±0.
__fadd_ru(x, -x) returns +0 for finite x, including ±0.
If either argument is NaN, NaN is returned.
__device__ float __fadd_rz(float x, float y)
Add two floating-point values in round-towards-zero mode.
Compute the sum of x and y in round-towards-zero mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x + y.
__fadd_rz(x, y) is equivalent to __fadd_rz(y, x).
__fadd_rz(x, ±∞) returns ±∞ for finite x.
__fadd_rz( ±∞, ±∞) returns ±∞.
__fadd_rz( ±∞, ∓∞) returns NaN.
__fadd_rz( ±0, ±0) returns ±0.
__fadd_rz(x, -x) returns +0 for finite x, including ±0.
If either argument is NaN, NaN is returned.
7.1. Functions
267
__device__ float __fdiv_rd(float x, float y)
Divide two floating-point values in round-down mode.
Divide two floating-point values x by y in round-down (to negative infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns x / y.
sign of the quotient x / y is XOR of the signs of x and y when neither inputs nor
result are NaN.
__fdiv_rd( ±0, ±0) returns NaN.
__fdiv_rd( ±∞, ±∞) returns NaN.
__fdiv_rd(x, ±∞) returns 0 of appropriate sign for finite x.
__fdiv_rd( ±∞, y) returns of appropriate sign for finite y.
__fdiv_rd(x, ±0) returns of appropriate sign for x = 0.
__fdiv_rd( ±0, y) returns 0 of appropriate sign for y = 0.
If either argument is NaN, NaN is returned.
__device__ float __fdiv_rn(float x, float y)
Divide two floating-point values in round-to-nearest-even mode.
Divide two floating-point values x by y in round-to-nearest-even mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns x / y.
sign of the quotient x / y is XOR of the signs of x and y when neither inputs nor
result are NaN.
__fdiv_rn( ±0, ±0) returns NaN.
__fdiv_rn( ±∞, ±∞) returns NaN.
__fdiv_rn(x, ±∞) returns 0 of appropriate sign for finite x.
__fdiv_rn( ±∞, y) returns of appropriate sign for finite y.
__fdiv_rn(x, ±0) returns of appropriate sign for x = 0.
__fdiv_rn( ±0, y) returns 0 of appropriate sign for y = 0.
If either argument is NaN, NaN is returned.
268
Chapter 7. Single Precision Intrinsics
__device__ float __fdiv_ru(float x, float y)
Divide two floating-point values in round-up mode.
Divide two floating-point values x by y in round-up (to positive infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns x / y.
sign of the quotient x / y is XOR of the signs of x and y when neither inputs nor
result are NaN.
__fdiv_ru( ±0, ±0) returns NaN.
__fdiv_ru( ±∞, ±∞) returns NaN.
__fdiv_ru(x, ±∞) returns 0 of appropriate sign for finite x.
__fdiv_ru( ±∞, y) returns of appropriate sign for finite y.
__fdiv_ru(x, ±0) returns of appropriate sign for x = 0.
__fdiv_ru( ±0, y) returns 0 of appropriate sign for y = 0.
If either argument is NaN, NaN is returned.
__device__ float __fdiv_rz(float x, float y)
Divide two floating-point values in round-towards-zero mode.
Divide two floating-point values x by y in round-towards-zero mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns x / y.
sign of the quotient x / y is XOR of the signs of x and y when neither inputs nor
result are NaN.
__fdiv_rz( ±0, ±0) returns NaN.
__fdiv_rz( ±∞, ±∞) returns NaN.
__fdiv_rz(x, ±∞) returns 0 of appropriate sign for finite x.
__fdiv_rz( ±∞, y) returns of appropriate sign for finite y.
__fdiv_rz(x, ±0) returns of appropriate sign for x = 0.
__fdiv_rz( ±0, y) returns 0 of appropriate sign for y = 0.
If either argument is NaN, NaN is returned.
7.1. Functions
269
__device__ float __fdividef(float x, float y)
Calculate the fast approximate division of the input arguments.
Calculate the fast approximate division of x by y.
See also:
__fdiv_rn() for further special case behavior specification.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns x / y.
__fdividef( , y) returns NaN for 2126 < |y| < 2128.
__fdividef(x, y) returns 0 for 2126 < |y| < 2128 and finite x.
__device__ float2 __ffma2_rd(float2 x, float2 y, float2 z)
Compute vector fused multiply-add operation x × y + z in round-down mode.
Numeric behavior per component is the same as __fmaf_rd().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
__device__ float2 __ffma2_rn(float2 x, float2 y, float2 z)
Compute vector fused multiply-add operation x × y + z in round-to-nearest-even mode.
Numeric behavior per component is the same as __fmaf_rn().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
__device__ float2 __ffma2_ru(float2 x, float2 y, float2 z)
Compute vector fused multiply-add operation x × y + z in round-up mode.
Numeric behavior per component is the same as __fmaf_ru().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
270
Chapter 7. Single Precision Intrinsics
__device__ float2 __ffma2_rz(float2 x, float2 y, float2 z)
Compute vector fused multiply-add operation x × y + z in round-towards-zero mode.
Numeric behavior per component is the same as __fmaf_rz().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
__device__ float __fmaf_ieee_rd(float x, float y, float z)
Compute fused multiply-add operation in round-down mode, ignore -ftz=true compiler flag.
Behavior is the same as __fmaf_rd(x, y, z), the difference is in handling denormalized inputs and
outputs: -ftz compiler flag has no effect.
__device__ float __fmaf_ieee_rn(float x, float y, float z)
Compute fused multiply-add operation in round-to-nearest-even mode, ignore -ftz=true com-
piler flag.
Behavior is the same as __fmaf_rn(x, y, z), the difference is in handling denormalized inputs and
outputs: -ftz compiler flag has no effect.
__device__ float __fmaf_ieee_ru(float x, float y, float z)
Compute fused multiply-add operation in round-up mode, ignore -ftz=true compiler flag.
Behavior is the same as __fmaf_ru(x, y, z), the difference is in handling denormalized inputs and
outputs: -ftz compiler flag has no effect.
__device__ float __fmaf_ieee_rz(float x, float y, float z)
Compute fused multiply-add operation in round-towards-zero mode, ignore -ftz=true compiler
flag.
Behavior is the same as __fmaf_rz(x, y, z), the difference is in handling denormalized inputs and
outputs: -ftz compiler flag has no effect.
__device__ float __fmaf_rd(float x, float y, float z)
Compute x × y + z as a single operation, in round-down mode.
Computes the value of x × y + z as a single ternary operation, rounding the result once in round-
down (to negative infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns the rounded value of x × y + z as a single operation.
__fmaf_rd( ±∞ , ±0 , z) returns NaN.
__fmaf_rd( ±0 , ±∞ , z) returns NaN.
__fmaf_rd(x, y, -∞ ) returns NaN if x × y is an exact +.
__fmaf_rd(x, y, + ) returns NaN if x × y is an exact -∞.
__fmaf_rd(x, y, ±0) returns ±0 if x × y is exact ±0.
7.1. Functions
271
__fmaf_rd(x, y,0) returns -0 if x × y is exact ±0.
__fmaf_rd(x, y, z) returns -0 if x × y + z is exactly zero and z = 0.
If either argument is NaN, NaN is returned.
__device__ float __fmaf_rn(float x, float y, float z)
Compute x × y + z as a single operation, in round-to-nearest-even mode.
Computes the value of x × y + z as a single ternary operation, rounding the result once in round-
to-nearest-even mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns the rounded value of x × y + z as a single operation.
__fmaf_rn( ±∞ , ±0 , z) returns NaN.
__fmaf_rn( ±0 , ±∞ , z) returns NaN.
__fmaf_rn(x, y, -∞ ) returns NaN if x × y is an exact +.
__fmaf_rn(x, y, + ) returns NaN if x × y is an exact -∞.
__fmaf_rn(x, y, ±0) returns ±0 if x × y is exact ±0.
__fmaf_rn(x, y,0) returns +0 if x × y is exact ±0.
__fmaf_rn(x, y, z) returns +0 if x × y + z is exactly zero and z = 0.
If either argument is NaN, NaN is returned.
__device__ float __fmaf_ru(float x, float y, float z)
Compute x × y + z as a single operation, in round-up mode.
Computes the value of x×y+z as a single ternary operation, rounding the result once in round-up
(to positive infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns the rounded value of x × y + z as a single operation.
__fmaf_ru( ±∞ , ±0 , z) returns NaN.
__fmaf_ru( ±0 , ±∞ , z) returns NaN.
__fmaf_ru(x, y, -∞ ) returns NaN if x × y is an exact +.
__fmaf_ru(x, y, + ) returns NaN if x × y is an exact -∞.
__fmaf_ru(x, y, ±0) returns ±0 if x × y is exact ±0.
__fmaf_ru(x, y,0) returns +0 if x × y is exact ±0.
__fmaf_ru(x, y, z) returns +0 if x × y + z is exactly zero and z = 0.
272
Chapter 7. Single Precision Intrinsics
If either argument is NaN, NaN is returned.
__device__ float __fmaf_rz(float x, float y, float z)
Compute x × y + z as a single operation, in round-towards-zero mode.
Computes the value of x × y + z as a single ternary operation, rounding the result once in round-
towards-zero mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns the rounded value of x × y + z as a single operation.
__fmaf_rz( ±∞ , ±0 , z) returns NaN.
__fmaf_rz( ±0 , ±∞ , z) returns NaN.
__fmaf_rz(x, y, -∞ ) returns NaN if x × y is an exact +.
__fmaf_rz(x, y, + ) returns NaN if x × y is an exact -∞.
__fmaf_rz(x, y, ±0) returns ±0 if x × y is exact ±0.
__fmaf_rz(x, y,0) returns +0 if x × y is exact ±0.
__fmaf_rz(x, y, z) returns +0 if x × y + z is exactly zero and z = 0.
If either argument is NaN, NaN is returned.
__device__ float2 __fmul2_rd(float2 x, float2 y)
Compute vector multiply operation x × y in round-down mode.
Numeric behavior per component is the same as __fmul_rd().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
__device__ float2 __fmul2_rn(float2 x, float2 y)
Compute vector multiply operation x × y in round-to-nearest-even mode.
Numeric behavior per component is the same as __fmul_rn().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
__device__ float2 __fmul2_ru(float2 x, float2 y)
Compute vector multiply operation x × y in round-up mode.
Numeric behavior per component is the same as __fmul_ru().
7.1. Functions
273
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
__device__ float2 __fmul2_rz(float2 x, float2 y)
Compute vector multiply operation x × y in round-towards-zero mode.
Numeric behavior per component is the same as __fmul_rz().
Note: This intrinsic requires compute capability >= 10.0.
Note: The vector variants may not always provide better performance.
__device__ float __fmul_rd(float x, float y)
Multiply two floating-point values in round-down mode.
Compute the product of x and y in round-down (to negative infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x * y.
sign of the product x * y is XOR of the signs of x and y when neither inputs nor
result are NaN.
__fmul_rd(x, y) is equivalent to __fmul_rd(y, x).
__fmul_rd(x, ±∞) returns of appropriate sign for x = 0.
__fmul_rd( ±0, ±∞) returns NaN.
__fmul_rd( ±0, y) returns 0 of appropriate sign for finite y.
If either argument is NaN, NaN is returned.
__device__ float __fmul_rn(float x, float y)
Multiply two floating-point values in round-to-nearest-even mode.
Compute the product of x and y in round-to-nearest-even mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
274
Chapter 7. Single Precision Intrinsics
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x * y.
sign of the product x * y is XOR of the signs of x and y when neither inputs nor
result are NaN.
__fmul_rn(x, y) is equivalent to __fmul_rn(y, x).
__fmul_rn(x, ±∞) returns of appropriate sign for x = 0.
__fmul_rn( ±0, ±∞) returns NaN.
__fmul_rn( ±0, y) returns 0 of appropriate sign for finite y.
If either argument is NaN, NaN is returned.
__device__ float __fmul_ru(float x, float y)
Multiply two floating-point values in round-up mode.
Compute the product of x and y in round-up (to positive infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x * y.
sign of the product x * y is XOR of the signs of x and y when neither inputs nor
result are NaN.
__fmul_ru(x, y) is equivalent to __fmul_ru(y, x).
__fmul_ru(x, ±∞) returns of appropriate sign for x = 0.
__fmul_ru( ±0, ±∞) returns NaN.
__fmul_ru( ±0, y) returns 0 of appropriate sign for finite y.
If either argument is NaN, NaN is returned.
__device__ float __fmul_rz(float x, float y)
Multiply two floating-point values in round-towards-zero mode.
Compute the product of x and y in round-towards-zero mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: This operation will never be merged into a single multiply-add instruction.
7.1. Functions
275
Returns
Returns x * y.
sign of the product x * y is XOR of the signs of x and y when neither inputs nor
result are NaN.
__fmul_rz(x, y) is equivalent to __fmul_rz(y, x).
__fmul_rz(x, ±∞) returns of appropriate sign for x = 0.
__fmul_rz( ±0, ±∞) returns NaN.
__fmul_rz( ±0, y) returns 0 of appropriate sign for finite y.
If either argument is NaN, NaN is returned.
__device__ float __frcp_rd(float x)
Compute1x in round-down mode.
Compute the reciprocal of x in round-down (to negative infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns1x .
__frcp_rd( ±0) returns ±∞.
__frcp_rd( ±∞) returns ±0.
__frcp_rd(NaN) returns NaN.
__device__ float __frcp_rn(float x)
Compute1x in round-to-nearest-even mode.
Compute the reciprocal of x in round-to-nearest-even mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns1x .
__frcp_rn( ±0) returns ±∞.
__frcp_rn( ±∞) returns ±0.
__frcp_rn(NaN) returns NaN.
__device__ float __frcp_ru(float x)
Compute1x in round-up mode.
Compute the reciprocal of x in round-up (to positive infinity) mode.
276
Chapter 7. Single Precision Intrinsics
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns1x .
__frcp_ru( ±0) returns ±∞.
__frcp_ru( ±∞) returns ±0.
__frcp_ru(NaN) returns NaN.
__device__ float __frcp_rz(float x)
Compute1x in round-towards-zero mode.
Compute the reciprocal of x in round-towards-zero mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns1x .
__frcp_rz( ±0) returns ±∞.
__frcp_rz( ±∞) returns ±0.
__frcp_rz(NaN) returns NaN.
__device__ float __frsqrt_rn(float x)
Compute 1/x in round-to-nearest-even mode.
Compute the reciprocal square root of x in round-to-nearest-even mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns 1/x.
__frsqrt_rn( ±0) returns ±∞.
__frsqrt_rn( +) returns +0.
__frsqrt_rn(x) returns NaN for x < 0.
__frsqrt_rn(NaN) returns NaN.
__device__ float __fsqrt_rd(float x)
Compute
x in round-down mode.
Compute the square root of x in round-down (to negative infinity) mode.
7.1. Functions
277
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns
x.
__fsqrt_rd( ±0) returns ±0.
__fsqrt_rd( +) returns +.
__fsqrt_rd(x) returns NaN for x < 0.
__fsqrt_rd(NaN) returns NaN.
__device__ float __fsqrt_rn(float x)
Compute
x in round-to-nearest-even mode.
Compute the square root of x in round-to-nearest-even mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns
x.
__fsqrt_rn( ±0) returns ±0.
__fsqrt_rn( +) returns +.
__fsqrt_rn(x) returns NaN for x < 0.
__fsqrt_rn(NaN) returns NaN.
__device__ float __fsqrt_ru(float x)
Compute
x in round-up mode.
Compute the square root of x in round-up (to positive infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns
x.
__fsqrt_ru( ±0) returns ±0.
__fsqrt_ru( +) returns +.
__fsqrt_ru(x) returns NaN for x < 0.
__fsqrt_ru(NaN) returns NaN.
278
Chapter 7. Single Precision Intrinsics
__device__ float __fsqrt_rz(float x)
Compute
x in round-towards-zero mode.
Compute the square root of x in round-towards-zero mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns
x.
__fsqrt_rz( ±0) returns ±0.
__fsqrt_rz( +) returns +.
__fsqrt_rz(x) returns NaN for x < 0.
__fsqrt_rz(NaN) returns NaN.
__device__ float __fsub_rd(float x, float y)
Subtract two floating-point values in round-down mode.
Compute the difference of x and y in round-down (to negative infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x - y.
__fsub_rd( ±∞, y) returns ±∞ for finite y.
__fsub_rd(x, ±∞) returns ∓∞ for finite x.
__fsub_rd( ±∞, ±∞) returns NaN.
__fsub_rd( ±∞, ∓∞) returns ±∞.
__fsub_rd( ±0,0) returns ±0.
__fsub_rd(x, x) returns -0 for finite x, including ±0.
If either argument is NaN, NaN is returned.
__device__ float __fsub_rn(float x, float y)
Subtract two floating-point values in round-to-nearest-even mode.
Compute the difference of x and y in round-to-nearest-even rounding mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
7.1. Functions
279
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x - y.
__fsub_rn( ±∞, y) returns ±∞ for finite y.
__fsub_rn(x, ±∞) returns ∓∞ for finite x.
__fsub_rn( ±∞, ±∞) returns NaN.
__fsub_rn( ±∞, ∓∞) returns ±∞.
__fsub_rn( ±0,0) returns ±0.
__fsub_rn(x, x) returns +0 for finite x, including ±0.
If either argument is NaN, NaN is returned.
__device__ float __fsub_ru(float x, float y)
Subtract two floating-point values in round-up mode.
Compute the difference of x and y in round-up (to positive infinity) mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x - y.
__fsub_ru( ±∞, y) returns ±∞ for finite y.
__fsub_ru(x, ±∞) returns ∓∞ for finite x.
__fsub_ru( ±∞, ±∞) returns NaN.
__fsub_ru( ±∞, ∓∞) returns ±∞.
__fsub_ru( ±0,0) returns ±0.
__fsub_ru(x, x) returns +0 for finite x, including ±0.
If either argument is NaN, NaN is returned.
__device__ float __fsub_rz(float x, float y)
Subtract two floating-point values in round-towards-zero mode.
Compute the difference of x and y in round-towards-zero mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
280
Chapter 7. Single Precision Intrinsics
Note: This operation will never be merged into a single multiply-add instruction.
Returns
Returns x - y.
__fsub_rz( ±∞, y) returns ±∞ for finite y.
__fsub_rz(x, ±∞) returns ∓∞ for finite x.
__fsub_rz( ±∞, ±∞) returns NaN.
__fsub_rz( ±∞, ∓∞) returns ±∞.
__fsub_rz( ±0,0) returns ±0.
__fsub_rz(x, x) returns +0 for finite x, including ±0.
If either argument is NaN, NaN is returned.
__device__ float __log10f(float x)
Calculate the fast approximate base 10 logarithm of the input argument.
Calculate the fast approximate base 10 logarithm of the input argument x.
See also:
log10f() for further special case behavior specification.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns an approximation to log10(x).
__device__ float __log2f(float x)
Calculate the fast approximate base 2 logarithm of the input argument.
Calculate the fast approximate base 2 logarithm of the input argument x.
See also:
log2f() for further special case behavior specification.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns an approximation to log2(x).
7.1. Functions
281
__device__ float __logf(float x)
Calculate the fast approximate base e logarithm of the input argument.
Calculate the fast approximate base e logarithm of the input argument x.
See also:
logf() for further special case behavior specification.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns an approximation to loge(x).
__device__ float __powf(float x, float y)
Calculate the fast approximate of xy.
Calculate the fast approximate of x, the first input argument, raised to the power of y, the second
input argument, xy.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns an approximation to xy.
__device__ float __saturatef(float x)
Clamp the input argument to [+0.0, 1.0].
Clamp the input argument x to be within the interval [+0.0, 1.0].
Returns
__saturatef(x) returns +0 if x ≤ 0.
__saturatef(x) returns 1 if x ≥ 1.
__saturatef(x) returns x if 0 < x < 1.
__saturatef(NaN) returns +0.
__device__ void __sincosf(float x, float *sptr, float *cptr)
Calculate the fast approximate of sine and cosine of the first input argument.
Calculate the fast approximate of sine and cosine of the first input argument x (measured in
radians). The results for sine and cosine are written into the second argument, sptr, and, re-
spectively, third argument, cptr.
See also:
__sinf() and __cosf().
282
Chapter 7. Single Precision Intrinsics
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: Denorm input/output is flushed to sign preserving 0.0.
__device__ float __sinf(float x)
Calculate the fast approximate sine of the input argument.
Calculate the fast approximate sine of the input argument x, measured in radians.
See also:
sinf() for further special case behavior specification.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: Output in the denormal range is flushed to sign preserving 0.0.
Returns
Returns the approximate sine of x.
__device__ float __tanf(float x)
Calculate the fast approximate tangent of the input argument.
Calculate the fast approximate tangent of the input argument x, measured in radians.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Note: The result is computed as the fast divide of __sinf() by __cosf(). Denormal output is flushed
to sign-preserving 0.0.
Returns
Returns the approximate tangent of x.
__device__ float __tanhf(float x)
Calculate the fast approximate hyperbolic tangent of the input argument.
Calculate the fast approximate hyperbolic tangent of the input argument x, measured in radians.
See also:
tanhf() for further special case behavior specification.
7.1. Functions
283
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Intrinsic Functions section.
Returns
Returns the approximate hyperbolic tangent of x.
284
Chapter 7. Single Precision Intrinsics
Chapter 8. Double Precision
Mathematical Functions
This section describes double precision mathematical functions.
To use these functions, you do not need to include any additional header file in your program.
Functions
__device__ double acos(double x)
Calculate the arc cosine of the input argument.
__device__ double acosh(double x)
Calculate the nonnegative inverse hyperbolic cosine of the input argument.
__device__ double asin(double x)
Calculate the arc sine of the input argument.
__device__ double asinh(double x)
Calculate the inverse hyperbolic sine of the input argument.
__device__ double atan(double x)
Calculate the arc tangent of the input argument.
__device__ double atan2(double y, double x)
Calculate the arc tangent of the ratio of first and second input arguments.
__device__ double atanh(double x)
Calculate the inverse hyperbolic tangent of the input argument.
__device__ double cbrt(double x)
Calculate the cube root of the input argument.
__device__ double ceil(double x)
Calculate ceiling of the input argument.
__device__ double copysign(double x, double y)
Create value with given magnitude, copying sign of second value.
__device__ double cos(double x)
Calculate the cosine of the input argument.
__device__ double cosh(double x)
Calculate the hyperbolic cosine of the input argument.
__device__ double cospi(double x)
Calculate the cosine of the input argument ×π .
285
__device__ double cyl_bessel_i0(double x)
Calculate the value of the regular modified cylindrical Bessel function of order 0 for the input
argument.
__device__ double cyl_bessel_i1(double x)
Calculate the value of the regular modified cylindrical Bessel function of order 1 for the input
argument.
__device__ double erf(double x)
Calculate the error function of the input argument.
__device__ double erfc(double x)
Calculate the complementary error function of the input argument.
__device__ double erfcinv(double x)
Calculate the inverse complementary error function of the input argument.
__device__ double erfcx(double x)
Calculate the scaled complementary error function of the input argument.
__device__ double erfinv(double x)
Calculate the inverse error function of the input argument.
__device__ double exp(double x)
Calculate the base e exponential of the input argument.
__device__ double exp10(double x)
Calculate the base 10 exponential of the input argument.
__device__ double exp2(double x)
Calculate the base 2 exponential of the input argument.
__device__ double expm1(double x)
Calculate the base e exponential of the input argument, minus 1.
__device__ double fabs(double x)
Calculate the absolute value of the input argument.
__device__ double fdim(double x, double y)
Compute the positive difference between x and y .
__device__ double floor(double x)
Calculate the largest integer less than or equal to x .
__device__ double fma(double x, double y, double z)
Compute x × y + z as a single operation.
__device__ double fmax(double, double)
Determine the maximum numeric value of the arguments.
__device__ double fmin(double x, double y)
Determine the minimum numeric value of the arguments.
__device__ double fmod(double x, double y)
Calculate the double-precision floating-point remainder of x / y .
__device__ double frexp(double x, int *nptr)
Extract mantissa and exponent of a floating-point value.
__device__ double hypot(double x, double y)
Calculate the square root of the sum of squares of two arguments.
__device__ int ilogb(double x)
Compute the unbiased integer exponent of the argument.
286
Chapter 8. Double Precision Mathematical Functions
__device__ __RETURN_TYPE isfinite(double a)
Determine whether argument is finite.
__device__ __RETURN_TYPE isinf(double a)
Determine whether argument is infinite.
__device__ __RETURN_TYPE isnan(double a)
Determine whether argument is a NaN.
__device__ double j0(double x)
Calculate the value of the Bessel function of the first kind of order 0 for the input argument.
__device__ double j1(double x)
Calculate the value of the Bessel function of the first kind of order 1 for the input argument.
__device__ double jn(int n, double x)
Calculate the value of the Bessel function of the first kind of order n for the input argument.
__device__ double ldexp(double x, int exp)
Calculate the value of x · 2exp .
__device__ double lgamma(double x)
Calculate the natural logarithm of the absolute value of the gamma function of the input argu-
ment.
__device__ long long int llrint(double x)
Round input to nearest integer value.
__device__ long long int llround(double x)
Round to nearest integer value.
__device__ double log(double x)
Calculate the base e logarithm of the input argument.
__device__ double log10(double x)
Calculate the base 10 logarithm of the input argument.
__device__ double log1p(double x)
Calculate the value of loge(1 + x) .
__device__ double log2(double x)
Calculate the base 2 logarithm of the input argument.
__device__ double logb(double x)
Calculate the floating-point representation of the exponent of the input argument.
__device__ long int lrint(double x)
Round input to nearest integer value.
__device__ long int lround(double x)
Round to nearest integer value.
__device__ double max(const float a, const double b)
Calculate the maximum value of the input float and double arguments.
__device__ double max(const double a, const float b)
Calculate the maximum value of the input double and float arguments.
__device__ double max(const double a, const double b)
Calculate the maximum value of the input float arguments.
__device__ double min(const float a, const double b)
Calculate the minimum value of the input float and double arguments.
287
__device__ double min(const double a, const double b)
Calculate the minimum value of the input float arguments.
__device__ double min(const double a, const float b)
Calculate the minimum value of the input double and float arguments.
__device__ double modf(double x, double *iptr)
Break down the input argument into fractional and integral parts.
__device__ double nan(const char *tagp)
Returns "Not a Number" value.
__device__ double nearbyint(double x)
Round the input argument to the nearest integer.
__device__ double nextafter(double x, double y)
Return next representable double-precision floating-point value after argument x in the direction
of y .
__device__ double norm(int dim, double const *p)
Calculate the square root of the sum of squares of any number of coordinates.
__device__ double norm3d(double a, double b, double c)
Calculate the square root of the sum of squares of three coordinates of the argument.
__device__ double norm4d(double a, double b, double c, double d)
Calculate the square root of the sum of squares of four coordinates of the argument.
__device__ double normcdf(double x)
Calculate the standard normal cumulative distribution function.
__device__ double normcdfinv(double x)
Calculate the inverse of the standard normal cumulative distribution function.
__device__ double pow(double x, double y)
Calculate the value of first argument to the power of second argument.
__device__ double rcbrt(double x)
Calculate reciprocal cube root function.
__device__ double remainder(double x, double y)
Compute double-precision floating-point remainder.
__device__ double remquo(double x, double y, int *quo)
Compute double-precision floating-point remainder and part of quotient.
__device__ double rhypot(double x, double y)
Calculate one over the square root of the sum of squares of two arguments.
__device__ double rint(double x)
Round to nearest integer value in floating-point.
__device__ double rnorm(int dim, double const *p)
Calculate the reciprocal of square root of the sum of squares of any number of coordinates.
__device__ double rnorm3d(double a, double b, double c)
Calculate one over the square root of the sum of squares of three coordinates.
__device__ double rnorm4d(double a, double b, double c, double d)
Calculate one over the square root of the sum of squares of four coordinates.
__device__ double round(double x)
Round to nearest integer value in floating-point.
288
Chapter 8. Double Precision Mathematical Functions
__device__ double rsqrt(double x)
Calculate the reciprocal of the square root of the input argument.
__device__ double scalbln(double x, long int n)
Scale floating-point input by integer power of two.
__device__ double scalbn(double x, int n)
Scale floating-point input by integer power of two.
__device__ __RETURN_TYPE signbit(double a)
Return the sign bit of the input.
__device__ double sin(double x)
Calculate the sine of the input argument.
__device__ void sincos(double x, double *sptr, double *cptr)
Calculate the sine and cosine of the first input argument.
__device__ void sincospi(double x, double *sptr, double *cptr)
Calculate the sine and cosine of the first input argument ×π .
__device__ double sinh(double x)
Calculate the hyperbolic sine of the input argument.
__device__ double sinpi(double x)
Calculate the sine of the input argument ×π .
__device__ double sqrt(double x)
Calculate the square root of the input argument.
__device__ double tan(double x)
Calculate the tangent of the input argument.
__device__ double tanh(double x)
Calculate the hyperbolic tangent of the input argument.
__device__ double tgamma(double x)
Calculate the gamma function of the input argument.
__device__ double trunc(double x)
Truncate input argument to the integral part.
__device__ double y0(double x)
Calculate the value of the Bessel function of the second kind of order 0 for the input argument.
__device__ double y1(double x)
Calculate the value of the Bessel function of the second kind of order 1 for the input argument.
__device__ double yn(int n, double x)
Calculate the value of the Bessel function of the second kind of order n for the input argument.
289
8.1. Functions
__device__ double acos(double x)
Calculate the arc cosine of the input argument.
Calculate the principal value of the arc cosine of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Result will be in radians, in the interval [0, π ] for x inside [-1, +1].
acos(1) returns +0.
acos(x) returns NaN for x outside [-1, +1].
acos(NaN) returns NaN.
__device__ double acosh(double x)
Calculate the nonnegative inverse hyperbolic cosine of the input argument.
Calculate the nonnegative inverse hyperbolic cosine of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Result will be in the interval [0, + ].
acosh(1) returns 0.
acosh(x) returns NaN for x in the interval [ -∞ , 1).
acosh( + ) returns +.
acosh(NaN) returns NaN.
__device__ double asin(double x)
Calculate the arc sine of the input argument.
Calculate the principal value of the arc sine of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Result will be in radians, in the interval [- π /2, + π /2] for x inside [-1, +1].
asin( ±0 ) returns ±0.
asin(x) returns NaN for x outside [-1, +1].
asin(NaN) returns NaN.
290
Chapter 8. Double Precision Mathematical Functions
__device__ double asinh(double x)
Calculate the inverse hyperbolic sine of the input argument.
Calculate the inverse hyperbolic sine of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
asinh( ±0 ) returns ±0.
asinh( ±∞ ) returns ±∞.
asinh(NaN) returns NaN.
__device__ double atan(double x)
Calculate the arc tangent of the input argument.
Calculate the principal value of the arc tangent of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Result will be in radians, in the interval [- π /2, + π /2].
atan( ±0 ) returns ±0.
atan( ±∞ ) returns ±π /2.
atan(NaN) returns NaN.
__device__ double atan2(double y, double x)
Calculate the arc tangent of the ratio of first and second input arguments.
Calculate the principal value of the arc tangent of the ratio of first and second input arguments
y / x. The quadrant of the result is determined by the signs of inputs y and x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Result will be in radians, in the interval [- π , + π ].
atan2( ±0 , -0) returns ±π.
atan2( ±0 , +0) returns ±0.
atan2( ±0 , x) returns ±π for x < 0.
atan2( ±0 , x) returns ±0 for x > 0.
atan2(y, ±0 ) returns /2 for y < 0.
8.1. Functions
291
atan2(y, ±0 ) returns π /2 for y > 0.
atan2( ±y , -∞ ) returns ±π for finite y > 0.
atan2( ±y , + ) returns ±0 for finite y > 0.
atan2( ±∞ , x) returns ±π /2 for finite x.
atan2( ±∞ , -∞ ) returns ±3π /4.
atan2( ±∞ , + ) returns ±π /4.
If either argument is NaN, NaN is returned.
__device__ double atanh(double x)
Calculate the inverse hyperbolic tangent of the input argument.
Calculate the inverse hyperbolic tangent of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
atanh( ±0 ) returns ±0.
atanh( ±1 ) returns ±∞.
atanh(x) returns NaN for x outside interval [-1, 1].
atanh(NaN) returns NaN.
__device__ double cbrt(double x)
Calculate the cube root of the input argument.
Calculate the cube root of x, x1/3.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns x1/3.
cbrt( ±0 ) returns ±0.
cbrt( ±∞ ) returns ±∞.
cbrt(NaN) returns NaN.
__device__ double ceil(double x)
Calculate ceiling of the input argument.
Compute the smallest integer value not less than x.
Returns
Returns ⌈x⌉ expressed as a floating-point number.
ceil( ±0 ) returns ±0.
292
Chapter 8. Double Precision Mathematical Functions
ceil( ±∞ ) returns ±∞.
ceil(NaN) returns NaN.
__device__ double copysign(double x, double y)
Create value with given magnitude, copying sign of second value.
Create a floating-point value with the magnitude x and the sign of y.
Returns
a value with the magnitude of x and the sign of y.
copysign(NaN, y) returns a NaN with the sign of y.
__device__ double cos(double x)
Calculate the cosine of the input argument.
Calculate the cosine of the input argument x (measured in radians).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
cos( ±0 ) returns 1.
cos( ±∞ ) returns NaN.
cos(NaN) returns NaN.
__device__ double cosh(double x)
Calculate the hyperbolic cosine of the input argument.
Calculate the hyperbolic cosine of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
cosh( ±0 ) returns 1.
cosh( ±∞ ) returns +.
cosh(NaN) returns NaN.
__device__ double cospi(double x)
Calculate the cosine of the input argument ×π.
Calculate the cosine of x ×π (measured in radians), where x is the input argument.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
8.1. Functions
293
Returns
cospi( ±0 ) returns 1.
cospi( ±∞ ) returns NaN.
cospi(NaN) returns NaN.
__device__ double cyl_bessel_i0(double x)
Calculate the value of the regular modified cylindrical Bessel function of order 0 for the input
argument.
Calculate the value of the regular modified cylindrical Bessel function of order 0 for the input
argument x, I0(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the value of the regular modified cylindrical Bessel function of order 0.
cyl_bessel_i0( ±0) returns +1.
cyl_bessel_i0( ±∞) returns +.
cyl_bessel_i0(NaN) returns NaN.
__device__ double cyl_bessel_i1(double x)
Calculate the value of the regular modified cylindrical Bessel function of order 1 for the input
argument.
Calculate the value of the regular modified cylindrical Bessel function of order 1 for the input
argument x, I1(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the value of the regular modified cylindrical Bessel function of order 1.
cyl_bessel_i1( ±0) returns ±0.
cyl_bessel_i1( ±∞) returns ±∞.
cyl_bessel_i1(NaN) returns NaN.
__device__ double erf(double x)
Calculate the error function of the input argument.
x
2
Calculate the value of the error function for the input argument x,
e-t2 dt.
π
0
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
294
Chapter 8. Double Precision Mathematical Functions
Returns
erf( ±0 ) returns ±0.
erf( ±∞ ) returns ±1.
erf(NaN) returns NaN.
__device__ double erfc(double x)
Calculate the complementary error function of the input argument.
Calculate the complementary error function of the input argument x, 1 - erf(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
erfc( -∞ ) returns 2.
erfc( + ) returns +0.
erfc(NaN) returns NaN.
__device__ double erfcinv(double x)
Calculate the inverse complementary error function of the input argument.
Calculate the inverse complementary error function erfc-1 (x), of the input argument x in the
interval [0, 2].
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
erfcinv( ±0 ) returns +.
erfcinv(2) returns -∞.
erfcinv(x) returns NaN for x outside [0, 2].
erfcinv(NaN) returns NaN.
__device__ double erfcx(double x)
Calculate the scaled complementary error function of the input argument.
Calculate the scaled complementary error function of the input argument x, ex2 · erfc(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
8.1. Functions
295
Returns
erfcx( -∞ ) returns +.
erfcx( + ) returns +0.
erfcx(NaN) returns NaN.
__device__ double erfinv(double x)
Calculate the inverse error function of the input argument.
Calculate the inverse error function erf-1 (x), of the input argument x in the interval [-1, 1].
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
erfinv( ±0 ) returns ±0.
erfinv(1) returns +.
erfinv(-1) returns -∞.
erfinv(x) returns NaN for x outside [-1, +1].
erfinv(NaN) returns NaN.
__device__ double exp(double x)
Calculate the base e exponential of the input argument.
Calculate ex , the base e exponential of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
exp( ±0 ) returns 1.
exp( -∞ ) returns +0.
exp( + ) returns +.
exp(NaN) returns NaN.
__device__ double exp10(double x)
Calculate the base 10 exponential of the input argument.
Calculate 10x , the base 10 exponential of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
296
Chapter 8. Double Precision Mathematical Functions
Returns
exp10( ±0 ) returns 1.
exp10( -∞ ) returns +0.
exp10( + ) returns +.
exp10(NaN) returns NaN.
__device__ double exp2(double x)
Calculate the base 2 exponential of the input argument.
Calculate 2x , the base 2 exponential of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
exp2( ±0 ) returns 1.
exp2( -∞ ) returns +0.
exp2( + ) returns +.
exp2(NaN) returns NaN.
__device__ double expm1(double x)
Calculate the base e exponential of the input argument, minus 1.
Calculate ex -1, the base e exponential of the input argument x, minus 1.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
expm1( ±0 ) returns ±0.
expm1( -∞ ) returns -1.
expm1( + ) returns +.
expm1(NaN) returns NaN.
__device__ double fabs(double x)
Calculate the absolute value of the input argument.
Calculate the absolute value of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
8.1. Functions
297
Returns
Returns the absolute value of the input argument.
fabs( ±∞ ) returns +.
fabs( ±0 ) returns +0.
fabs(NaN) returns an unspecified NaN.
__device__ double fdim(double x, double y)
Compute the positive difference between x and y.
Compute the positive difference between x and y. The positive difference is x - y when x > y and
+0 otherwise.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the positive difference between x and y.
fdim(x, y) returns x - y if x > y.
fdim(x, y) returns +0 if x y.
If either argument is NaN, NaN is returned.
__device__ double floor(double x)
Calculate the largest integer less than or equal to x.
Calculates the largest integer value which is less than or equal to x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns ⌊x⌋ expressed as a floating-point number.
floor( ±∞ ) returns ±∞.
floor( ±0 ) returns ±0.
floor(NaN) returns NaN.
__device__ double fma(double x, double y, double z)
Compute x × y + z as a single operation.
Compute the value of x×y +z as a single ternary operation. After computing the value to infinite
precision, the value is rounded once using round-to-nearest, ties-to-even rounding mode.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the rounded value of x × y + z as a single operation.
298
Chapter 8. Double Precision Mathematical Functions
fma( ±∞ , ±0 , z) returns NaN.
fma( ±0 , ±∞ , z) returns NaN.
fma(x, y, -∞ ) returns NaN if x × y is an exact +.
fma(x, y, + ) returns NaN if x × y is an exact -∞.
fma(x, y, ±0) returns ±0 if x × y is exact ±0.
fma(x, y,0) returns +0 if x × y is exact ±0.
fma(x, y, z) returns +0 if x × y + z is exactly zero and z = 0.
If either argument is NaN, NaN is returned.
__device__ double fmax(double, double)
Determine the maximum numeric value of the arguments.
Determines the maximum numeric value of the arguments x and y. Treats NaN arguments as
missing data. If one argument is a NaN and the other is legitimate numeric value, the numeric
value is chosen.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the maximum numeric values of the arguments x and y.
If both arguments are NaN, returns NaN.
If one argument is NaN, returns the numeric argument.
__device__ double fmin(double x, double y)
Determine the minimum numeric value of the arguments.
Determines the minimum numeric value of the arguments x and y. Treats NaN arguments as
missing data. If one argument is a NaN and the other is legitimate numeric value, the numeric
value is chosen.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the minimum numeric value of the arguments x and y.
If both arguments are NaN, returns NaN.
If one argument is NaN, returns the numeric argument.
__device__ double fmod(double x, double y)
Calculate the double-precision floating-point remainder of x / y.
Calculate the double-precision floating-point remainder of x / y. The floating-point remainder of
the division operation x / y calculated by this function is exactly the value x - n*y, where n is
x / y with its fractional part truncated. The computed value will have the same sign as x, and its
magnitude will be less than the magnitude of y.
8.1. Functions
299
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the floating-point remainder of x / y.
fmod( ±0 , y) returns ±0 if y is not zero.
fmod(x, ±∞ ) returns x if x is finite.
fmod(x, y) returns NaN if x is ±∞ or y is zero.
If either argument is NaN, NaN is returned.
__device__ double frexp(double x, int *nptr)
Extract mantissa and exponent of a floating-point value.
Decompose the floating-point value x into a component m for the normalized fraction element
and another term n for the exponent. The absolute value of m will be greater than or equal to 0.5
and less than 1.0 or it will be equal to 0; x = m · 2n. The integer exponent n will be stored in the
location to which nptr points.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the fractional component m.
frexp( ±0 , nptr) returns ±0 and stores zero in the location pointed to by nptr.
frexp( ±∞ , nptr) returns ±∞ and stores an unspecified value in the location
to which nptr points.
frexp(NaN, y) returns a NaN and stores an unspecified value in the location to
which nptr points.
__device__ double hypot(double x, double y)
Calculate the square root of the sum of squares of two arguments.
Calculate the length of the hypotenuse of a right triangle whose two sides have lengths x and y
without undue overflow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the length of the hypotenuse
x2 + y2.
hypot(x,y), hypot(y,x), and hypot(x, -y) are equivalent.
hypot(x, ±0 ) is equivalent to fabs(x).
hypot( ±∞ ,y) returns + , even if y is a NaN.
300
Chapter 8. Double Precision Mathematical Functions
hypot(NaN, y) returns NaN, when y is not ±∞.
__device__ int ilogb(double x)
Compute the unbiased integer exponent of the argument.
Calculates the unbiased integer exponent of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
If successful, returns the unbiased exponent of the argument.
ilogb( ±0 ) returns INT_MIN.
ilogb(NaN) returns INT_MIN.
ilogb( ±∞ ) returns INT_MAX.
Note: above behavior does not take into account FP_ILOGB0 nor FP_ILOGBNAN.
__device__ __RETURN_TYPE isfinite(double a)
Determine whether argument is finite.
Determine whether the floating-point value a is a finite value (zero, subnormal, or normal and not
infinity or NaN).
Returns
With Visual Studio 2013 host compiler: __RETURN_TYPE is ‘bool’. Returns true
if and only if a is a finite value.
With other host compilers: __RETURN_TYPE is ‘int’. Returns a nonzero value if
and only if a is a finite value.
__device__ __RETURN_TYPE isinf(double a)
Determine whether argument is infinite.
Determine whether the floating-point value a is an infinite value (positive or negative).
Returns
With Visual Studio 2013 host compiler: Returns true if and only if a is an infinite
value.
With other host compilers: Returns a nonzero value if and only if a is an infinite
value.
__device__ __RETURN_TYPE isnan(double a)
Determine whether argument is a NaN.
Determine whether the floating-point value a is a NaN.
Returns
8.1. Functions
301
With Visual Studio 2013 host compiler: __RETURN_TYPE is ‘bool’. Returns true
if and only if a is a NaN value.
With other host compilers: __RETURN_TYPE is ‘int’. Returns a nonzero value if
and only if a is a NaN value.
__device__ double j0(double x)
Calculate the value of the Bessel function of the first kind of order 0 for the input argument.
Calculate the value of the Bessel function of the first kind of order 0 for the input argument x,
J0(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the value of the Bessel function of the first kind of order 0.
j0( ±∞ ) returns +0.
j0(NaN) returns NaN.
__device__ double j1(double x)
Calculate the value of the Bessel function of the first kind of order 1 for the input argument.
Calculate the value of the Bessel function of the first kind of order 1 for the input argument x,
J1(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the value of the Bessel function of the first kind of order 1.
j1( ±0 ) returns ±0.
j1( ±∞ ) returns ±0.
j1(NaN) returns NaN.
__device__ double jn(int n, double x)
Calculate the value of the Bessel function of the first kind of order n for the input argument.
Calculate the value of the Bessel function of the first kind of order n for the input argument x,
Jn(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the value of the Bessel function of the first kind of order n.
jn(n, NaN) returns NaN.
jn(n, x) returns NaN for n < 0.
302
Chapter 8. Double Precision Mathematical Functions
jn(n, + ) returns +0.
__device__ double ldexp(double x, int exp)
Calculate the value of x · 2exp.
Calculate the value of x · 2exp of the input arguments x and exp.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
ldexp(x, exp) is equivalent to scalbn(x, exp).
__device__ double lgamma(double x)
Calculate the natural logarithm of the absolute value of the gamma function of the input argu-
ment.
Calculate the natural logarithm of the absolute value of the gamma function of the input argu-
ment x, namely the value of loge |Γ(x)|
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
lgamma(1) returns +0.
lgamma(2) returns +0.
lgamma(x) returns + if x 0 and x is an integer.
lgamma( -∞ ) returns +.
lgamma( + ) returns +.
lgamma(NaN) returns NaN.
__device__ long long int llrint(double x)
Round input to nearest integer value.
Round x to the nearest integer value, with halfway cases rounded to the nearest even integer
value. If the result is outside the range of the return type, the behavior is undefined.
Returns
Returns rounded integer value.
__device__ long long int llround(double x)
Round to nearest integer value.
Round x to the nearest integer value, with halfway cases rounded away from zero. If the result is
outside the range of the return type, the behavior is undefined.
8.1. Functions
303
Note: This function may be slower than alternate rounding methods. See llrint().
Returns
Returns rounded integer value.
__device__ double log(double x)
Calculate the base e logarithm of the input argument.
Calculate the base e logarithm of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
log( ±0 ) returns -∞.
log(1) returns +0.
log(x) returns NaN for x < 0.
log( + ) returns +.
log(NaN) returns NaN.
__device__ double log10(double x)
Calculate the base 10 logarithm of the input argument.
Calculate the base 10 logarithm of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
log10( ±0 ) returns -∞.
log10(1) returns +0.
log10(x) returns NaN for x < 0.
log10( + ) returns +.
log10(NaN) returns NaN.
__device__ double log1p(double x)
Calculate the value of loge(1 + x).
Calculate the value of loge(1 + x) of the input argument x.
304
Chapter 8. Double Precision Mathematical Functions
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
log1p( ±0 ) returns ±0.
log1p(-1) returns -∞.
log1p(x) returns NaN for x < -1.
log1p( + ) returns +.
log1p(NaN) returns NaN.
__device__ double log2(double x)
Calculate the base 2 logarithm of the input argument.
Calculate the base 2 logarithm of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
log2( ±0 ) returns -∞.
log2(1) returns +0.
log2(x) returns NaN for x < 0.
log2( + ) returns +.
log2(NaN) returns NaN.
__device__ double logb(double x)
Calculate the floating-point representation of the exponent of the input argument.
Calculate the floating-point representation of the exponent of the input argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
logb( ±0 ) returns -∞.
logb( ±∞ ) returns +.
logb(NaN) returns NaN.
8.1. Functions
305
__device__ long int lrint(double x)
Round input to nearest integer value.
Round x to the nearest integer value, with halfway cases rounded to the nearest even integer
value. If the result is outside the range of the return type, the behavior is undefined.
Returns
Returns rounded integer value.
__device__ long int lround(double x)
Round to nearest integer value.
Round x to the nearest integer value, with halfway cases rounded away from zero. If the result is
outside the range of the return type, the behavior is undefined.
Note: This function may be slower than alternate rounding methods. See lrint().
Returns
Returns rounded integer value.
__device__ double max(const float a, const double b)
Calculate the maximum value of the input float and double arguments.
Convert float argument a to double, followed by fmax().
Note, this is different from std:: specification
__device__ double max(const double a, const float b)
Calculate the maximum value of the input double and float arguments.
Convert float argument b to double, followed by fmax().
Note, this is different from std:: specification
__device__ double max(const double a, const double b)
Calculate the maximum value of the input float arguments.
Calculate the maximum value of the arguments a and b. Behavior is equivalent to fmax() function.
Note, this is different from std:: specification
__device__ double min(const float a, const double b)
Calculate the minimum value of the input float and double arguments.
Convert float argument a to double, followed by fmin().
Note, this is different from std:: specification
__device__ double min(const double a, const double b)
Calculate the minimum value of the input float arguments.
Calculate the minimum value of the arguments a and b. Behavior is equivalent to fmin() function.
Note, this is different from std:: specification
__device__ double min(const double a, const float b)
Calculate the minimum value of the input double and float arguments.
Convert float argument b to double, followed by fmin().
Note, this is different from std:: specification
306
Chapter 8. Double Precision Mathematical Functions
__device__ double modf(double x, double *iptr)
Break down the input argument into fractional and integral parts.
Break down the argument x into fractional and integral parts. The integral part is stored in the
argument iptr. Fractional and integral parts are given the same sign as the argument x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
modf( ±x , iptr) returns a result with the same sign as x.
modf( ±∞ , iptr) returns ±0 and stores ±∞ in the object pointed to by iptr.
modf(NaN, iptr) stores a NaN in the object pointed to by iptr and returns a
NaN.
__device__ double nan(const char *tagp)
Returns “Not a Number” value.
Return a representation of a quiet NaN. Argument tagp selects one of the possible representa-
tions.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
nan(tagp) returns NaN.
__device__ double nearbyint(double x)
Round the input argument to the nearest integer.
Round argument x to an integer value in double precision floating-point format. Uses round to
nearest rounding, with ties rounding to even.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
nearbyint( ±0 ) returns ±0.
nearbyint( ±∞ ) returns ±∞.
nearbyint(NaN) returns NaN.
8.1. Functions
307
__device__ double nextafter(double x, double y)
Return next representable double-precision floating-point value after argument x in the direction
of y.
Calculate the next representable double-precision floating-point value following x in the direction
of y. For example, if y is greater than x, nextafter() returns the smallest representable number
greater than x
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
nextafter(x, y) = y if x equals y.
nextafter(x, y) = NaN if either x or y are NaN.
__device__ double norm(int dim, double const *p)
Calculate the square root of the sum of squares of any number of coordinates.
Calculate the length of a vector p, dimension of which is passed as an argument without undue
overflow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
√∑dim-1
Returns the length of the dim-D vector
p2i.
i=0
In the presence of an exactly infinite coordinate + is returned, even if there
are NaNs.
returns +0, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
__device__ double norm3d(double a, double b, double c)
Calculate the square root of the sum of squares of three coordinates of the argument.
Calculate the length of three dimensional vector in Euclidean space without undue overflow or
underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the length of 3D vector
a2 + b2 + c2.
In the presence of an exactly infinite coordinate + is returned, even if there
are NaNs.
returns +0, when all coordinates are ±0.
308
Chapter 8. Double Precision Mathematical Functions
returns NaN, when at least one of the coordinates is NaN and none are infinite.
__device__ double norm4d(double a, double b, double c, double d)
Calculate the square root of the sum of squares of four coordinates of the argument.
Calculate the length of four dimensional vector in Euclidean space without undue overflow or
underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the length of 4D vector
a2 + b2 + c2 + d2.
In the presence of an exactly infinite coordinate + is returned, even if there
are NaNs.
returns +0, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
__device__ double normcdf(double x)
Calculate the standard normal cumulative distribution function.
Calculate the cumulative distribution function of the standard normal distribution for input ar-
gument x, Φ(x).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
normcdf( + ) returns 1.
normcdf( -∞ ) returns +0.
normcdf(NaN) returns NaN.
__device__ double normcdfinv(double x)
Calculate the inverse of the standard normal cumulative distribution function.
Calculate the inverse of the standard normal cumulative distribution function for input argument
x, Φ-1(x). The function is defined for input values in the interval (0, 1).
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
normcdfinv( ±0 ) returns -∞.
normcdfinv(1) returns +.
8.1. Functions
309
normcdfinv(x) returns NaN if x is not in the interval [0,1].
normcdfinv(NaN) returns NaN.
__device__ double pow(double x, double y)
Calculate the value of first argument to the power of second argument.
Calculate the value of x to the power of y.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
pow( ±0 , y) returns ±∞ for y an odd integer less than 0.
pow( ±0 , y) returns + for y less than 0 and not an odd integer.
pow( ±0 , y) returns ±0 for y an odd integer greater than 0.
pow( ±0 , y) returns +0 for y > 0 and not an odd integer.
pow(-1, ±∞ ) returns 1.
pow(+1, y) returns 1 for any y, even a NaN.
pow(x, ±0 ) returns 1 for any x, even a NaN.
pow(x, y) returns a NaN for finite x < 0 and finite non-integer y.
pow(x, -∞ ) returns + for |x| < 1.
pow(x, -∞ ) returns +0 for |x| > 1.
pow(x, + ) returns +0 for |x| < 1.
pow(x, + ) returns + for |x| > 1.
pow( -∞ , y) returns -0 for y an odd integer less than 0.
pow( -∞ , y) returns +0 for y < 0 and not an odd integer.
pow( -∞ , y) returns -∞ for y an odd integer greater than 0.
pow( -∞ , y) returns + for y > 0 and not an odd integer.
pow( + , y) returns +0 for y < 0.
pow( + , y) returns + for y > 0.
pow(x, y) returns NaN if either x or y or both are NaN and x = +1 and y = ±0.
__device__ double rcbrt(double x)
Calculate reciprocal cube root function.
Calculate reciprocal cube root function of x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
310
Chapter 8. Double Precision Mathematical Functions
Returns
rcbrt( ±0 ) returns ±∞.
rcbrt( ±∞ ) returns ±0.
rcbrt(NaN) returns NaN.
__device__ double remainder(double x, double y)
Compute double-precision floating-point remainder.
Compute double-precision floating-point remainder r of dividing x by y for nonzero y. Thus r =
x - ny. The value n is the integer value nearest xy. In the case when |n - xy| = 12 , the even n value
is chosen.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
remainder(x, ±0 ) returns NaN.
remainder( ±∞ , y) returns NaN.
remainder(x, ±∞ ) returns x for finite x.
If either argument is NaN, NaN is returned.
__device__ double remquo(double x, double y, int *quo)
Compute double-precision floating-point remainder and part of quotient.
Compute a double-precision floating-point remainder in the same way as the remainder() func-
tion. Argument quo returns part of quotient upon division of x by y. Value quo has the same
sign asxy and may not be the exact quotient but agrees with the exact quotient in the low order
3 bits.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns the remainder.
remquo(x, ±0 , quo) returns NaN and stores an unspecified value in the location
to which quo points.
remquo( ±∞ , y, quo) returns NaN and stores an unspecified value in the loca-
tion to which quo points.
remquo(x, y, quo) returns NaN and stores an unspecified value in the location
to which quo points if either of x or y is NaN.
remquo(x, ±∞ , quo) returns x and stores zero in the location to which quo
points for finite x.
8.1. Functions
311
__device__ double rhypot(double x, double y)
Calculate one over the square root of the sum of squares of two arguments.
Calculate one over the length of the hypotenuse of a right triangle whose two sides have lengths
x and y without undue overflow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
1
Returns one over the length of the hypotenuse
x2+y2
rhypot(x,y), rhypot(y,x), and rhypot(x, -y) are equivalent.
rhypot( ±∞ ,y) returns +0, even if y is a NaN.
rhypot( ±0, ±0) returns +.
rhypot(NaN, y) returns NaN, when y is not ±∞.
__device__ double rint(double x)
Round to nearest integer value in floating-point.
Round x to the nearest integer value in floating-point format, with halfway cases rounded to the
nearest even integer value.
Returns
Returns rounded integer value.
rint( ±0 ) returns ±0.
rint( ±∞ ) returns ±∞.
rint(NaN) returns NaN.
__device__ double rnorm(int dim, double const *p)
Calculate the reciprocal of square root of the sum of squares of any number of coordinates.
Calculates one over the length of vector p, dimension of which is passed as an argument, in
Euclidean space without undue overflow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
1
Returns one over the length of the vector
di
m-1
i=0
p2
i
In the presence of an exactly infinite coordinate +0 is returned, even if there are
NaNs.
returns +, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
312
Chapter 8. Double Precision Mathematical Functions
__device__ double rnorm3d(double a, double b, double c)
Calculate one over the square root of the sum of squares of three coordinates.
Calculate one over the length of three dimensional vector in Euclidean space without undue over-
flow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
1
Returns one over the length of the 3D vector
a2+b2+c2
In the presence of an exactly infinite coordinate +0 is returned, even if there are
NaNs.
returns +, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
__device__ double rnorm4d(double a, double b, double c, double d)
Calculate one over the square root of the sum of squares of four coordinates.
Calculate one over the length of four dimensional vector in Euclidean space without undue over-
flow or underflow.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
1
Returns one over the length of the 3D vector
a2+b2+c2+d2
In the presence of an exactly infinite coordinate +0 is returned, even if there are
NaNs.
returns +, when all coordinates are ±0.
returns NaN, when at least one of the coordinates is NaN and none are infinite.
__device__ double round(double x)
Round to nearest integer value in floating-point.
Round x to the nearest integer value in floating-point format, with halfway cases rounded away
from zero.
Note: This function may be slower than alternate rounding methods. See rint().
Returns
Returns rounded integer value.
round( ±0 ) returns ±0.
round( ±∞ ) returns ±∞.
round(NaN) returns NaN.
8.1. Functions
313
__device__ double rsqrt(double x)
Calculate the reciprocal of the square root of the input argument.
Calculate the reciprocal of the nonnegative square root of x, 1/x.
Note: For accuracy information, see the CUDA C++ Programming Guide, Mathematical Functions
Appendix, Double-Precision Floating-Point Functions section.
Returns
Returns 1/x.
rsqrt( + ) returns +0.
rsqrt( ±0 ) returns ±∞.
rsqrt(x) returns NaN if x is less than 0.
rsqrt(NaN) returns NaN.
__device__ double scalbln(double x, long int n)
Scale floating-point input by integer power of two.
Scale x by 2n by efficient manipulation of the floating-point exponent.
Returns
Returns x * 2n.
scalbln( ±0 , n) returns ±0.
scalbln(x, 0) returns x.
scalbln( ±∞ , n) returns ±∞.
scalbln(NaN, n) returns NaN.
__device__ double scalbn(double x, int n)
Scale floating-point input by integer power of two.
Scale x by 2n by efficient manipulation of the floating-point exponent.
Returns
Returns x * 2n.
scalbn( ±0 , n) returns ±0.
scalbn(x, 0) returns x.
scalbn( ±∞ , n) returns ±∞.
scalbn(NaN, n) returns NaN.
__device__ __RETURN_TYPE signbit(double a)
Return the sign bit of the input.
Determine whether the floating-point value a is negative.
Returns
Reports the sign bit of all values including infinities, zeros, and NaNs.
With Visual Studio 2013 host compiler: __RETURN_TYPE is ‘bool’. Returns true
if and only if a is negative.
314
Chapter 8. Double Precision Mathematical Functions

 

 

 

 

 

 

 

Content      ..     2      3      4      5     ..