This document includes math equations (highlighted in red) which are best viewed with Firefox version 4.0 or higher, or another MathML-aware browser. There is also a PDF version of this document.
CUDA Math API (PDF) - CUDA Toolkit v5.5 (older) - Last updated May 11, 2013 - Send Feedback

1.2. Single Precision Mathematical Functions

This section describes single precision mathematical functions.

Functions

__device__ ​ float acosf ( float  x )
Calculate the arc cosine of the input argument.
__device__ ​ float acoshf ( float  x )
Calculate the nonnegative arc hyperbolic cosine of the input argument.
__device__ ​ float asinf ( float  x )
Calculate the arc sine of the input argument.
__device__ ​ float asinhf ( float  x )
Calculate the arc hyperbolic sine of the input argument.
__device__ ​ float atan2f ( float  x, float  y )
Calculate the arc tangent of the ratio of first and second input arguments.
__device__ ​ float atanf ( float  x )
Calculate the arc tangent of the input argument.
__device__ ​ float atanhf ( float  x )
Calculate the arc hyperbolic tangent of the input argument.
__device__ ​ float cbrtf ( float  x )
Calculate the cube root of the input argument.
__device__ ​ float ceilf ( float  x )
Calculate ceiling of the input argument.
__device__ ​ float copysignf ( float  x, float  y )
Create value with given magnitude, copying sign of second value.
__device__ ​ float cosf ( float  x )
Calculate the cosine of the input argument.
__device__ ​ float coshf ( float  x )
Calculate the hyperbolic cosine of the input argument.
__device__ ​ float cospif ( float  x )
Calculate the cosine of the input argument × π .
__device__ ​ float erfcf ( float  x )
Calculate the complementary error function of the input argument.
__device__ ​ float erfcinvf ( float  y )
Calculate the inverse complementary error function of the input argument.
__device__ ​ float erfcxf ( float  x )
Calculate the scaled complementary error function of the input argument.
__device__ ​ float erff ( float  x )
Calculate the error function of the input argument.
__device__ ​ float erfinvf ( float  y )
Calculate the inverse error function of the input argument.
__device__ ​ float exp10f ( float  x )
Calculate the base 10 exponential of the input argument.
__device__ ​ float exp2f ( float  x )
Calculate the base 2 exponential of the input argument.
__device__ ​ float expf ( float  x )
Calculate the base e exponential of the input argument.
__device__ ​ float expm1f ( float  x )
Calculate the base e exponential of the input argument, minus 1.
__device__ ​ float fabsf ( float  x )
Calculate the absolute value of its argument.
__device__ ​ float fdimf ( float  x, float  y )
Compute the positive difference between x and y.
__device__ ​ float fdividef ( float  x, float  y )
Divide two floating point values.
__device__ ​ float floorf ( float  x )
Calculate the largest integer less than or equal to x.
__device__ ​ float fmaf ( float  x, float  y, float  z )
Compute x × y + z as a single operation.
__device__ ​ float fmaxf ( float  x, float  y )
Determine the maximum numeric value of the arguments.
__device__ ​ float fminf ( float  x, float  y )
Determine the minimum numeric value of the arguments.
__device__ ​ float fmodf ( float  x, float  y )
Calculate the floating-point remainder of x / y.
__device__ ​ float frexpf ( float  x, int* nptr )
Extract mantissa and exponent of a floating-point value.
__device__ ​ float hypotf ( float  x, float  y )
Calculate the square root of the sum of squares of two arguments.
__device__ ​ int ilogbf ( float  x )
Compute the unbiased integer exponent of the argument.
__device__ ​ int isfinite ( float  a )
Determine whether argument is finite.
__device__ ​ int isinf ( float  a )
Determine whether argument is infinite.
__device__ ​ int isnan ( float  a )
Determine whether argument is a NaN.
__device__ ​ float j0f ( float  x )
Calculate the value of the Bessel function of the first kind of order 0 for the input argument.
__device__ ​ float j1f ( float  x )
Calculate the value of the Bessel function of the first kind of order 1 for the input argument.
__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.
__device__ ​ float ldexpf ( float  x, int  exp )
Calculate the value of x 2 e x p .
__device__ ​ float lgammaf ( float  x )
Calculate the natural logarithm of the absolute value of the gamma function of the input argument.
__device__ ​ long long int llrintf ( float  x )
Round input to nearest integer value.
__device__ ​ long long int llroundf ( float  x )
Round to nearest integer value.
__device__ ​ float log10f ( float  x )
Calculate the base 10 logarithm of the input argument.
__device__ ​ float log1pf ( float  x )
Calculate the value of l o g e ( 1 + x ) .
__device__ ​ float log2f ( float  x )
Calculate the base 2 logarithm of the input argument.
__device__ ​ float logbf ( float  x )
Calculate the floating point representation of the exponent of the input argument.
__device__ ​ float logf ( float  x )
Calculate the natural logarithm of the input argument.
__device__ ​ long int lrintf ( float  x )
Round input to nearest integer value.
__device__ ​ long int lroundf ( float  x )
Round to nearest integer value.
__device__ ​ float modff ( float  x, float* iptr )
Break down the input argument into fractional and integral parts.
__device__ ​ float nanf ( const char* tagp )
Returns "Not a Number" value.
__device__ ​ float nearbyintf ( float  x )
Round the input argument to the nearest integer.
__device__ ​ float nextafterf ( float  x, float  y )
Return next representable single-precision floating-point value afer argument.
__device__ ​ float normcdff ( float  y )
Calculate the standard normal cumulative distribution function.
__device__ ​ float normcdfinvf ( float  y )
Calculate the inverse of the standard normal cumulative distribution function.
__device__ ​ float powf ( float  x, float  y )
Calculate the value of first argument to the power of second argument.
__device__ ​ float rcbrtf ( float  x )
Calculate reciprocal cube root function.
__device__ ​ float remainderf ( float  x, float  y )
Compute single-precision floating-point remainder.
__device__ ​ float remquof ( float  x, float  y, int* quo )
Compute single-precision floating-point remainder and part of quotient.
__device__ ​ float rintf ( float  x )
Round input to nearest integer value in floating-point.
__device__ ​ float roundf ( float  x )
Round to nearest integer value in floating-point.
__device__ ​ float rsqrtf ( float  x )
Calculate the reciprocal of the square root of the input argument.
__device__ ​ float scalblnf ( float  x, long int  n )
Scale floating-point input by integer power of two.
__device__ ​ float scalbnf ( float  x, int  n )
Scale floating-point input by integer power of two.
__device__ ​ int signbit ( float  a )
Return the sign bit of the input.
__device__ ​ void sincosf ( float  x, float* sptr, float* cptr )
Calculate the sine and cosine of the first input argument.
__device__ ​ void sincospif ( float  x, float* sptr, float* cptr )
Calculate the sine and cosine of the first input argument × π .
__device__ ​ float sinf ( float  x )
Calculate the sine of the input argument.
__device__ ​ float sinhf ( float  x )
Calculate the hyperbolic sine of the input argument.
__device__ ​ float sinpif ( float  x )
Calculate the sine of the input argument × π .
__device__ ​ float sqrtf ( float  x )
Calculate the square root of the input argument.
__device__ ​ float tanf ( float  x )
Calculate the tangent of the input argument.
__device__ ​ float tanhf ( float  x )
Calculate the hyperbolic tangent of the input argument.
__device__ ​ float tgammaf ( float  x )
Calculate the gamma function of the input argument.
__device__ ​ float truncf ( float  x )
Truncate input argument to the integral part.
__device__ ​ float y0f ( float  x )
Calculate the value of the Bessel function of the second kind of order 0 for the input argument.
__device__ ​ float y1f ( float  x )
Calculate the value of the Bessel function of the second kind of order 1 for the input argument.
__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.

Functions

__device__ ​ float acosf ( float  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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Result will be in radians, in the interval [0, π ] for x inside [-1, +1].

  • acosf(1) returns +0.
  • acosf(x) returns NaN for x outside [-1, +1].

__device__ ​ float acoshf ( float  x )

Calculate the nonnegative arc hyperbolic cosine of the input argument. Calculate the nonnegative arc hyperbolic cosine of the input argument x.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Result will be in the interval [0, + ].

  • acoshf(1) returns 0.
  • acoshf(x) returns NaN for x in the interval [ , 1).

__device__ ​ float asinf ( float  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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Result will be in radians, in the interval [- π / 2 , + π / 2 ] for x inside [-1, +1].

  • asinf(0) returns +0.
  • asinf(x) returns NaN for x outside [-1, +1].

__device__ ​ float asinhf ( float  x )

Calculate the arc hyperbolic sine of the input argument. Calculate the arc hyperbolic sine of the input argument x.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • asinhf(0) returns 1.

__device__ ​ float atan2f ( float  x, float  y )

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 x / y. The quadrant of the result is determined by the signs of inputs x and y.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Result will be in radians, in the interval [- π , + π ].

  • atan2f(0, 1) returns +0.

__device__ ​ float atanf ( float  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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Result will be in radians, in the interval [- π / 2 , + π / 2 ].

  • atanf(0) returns +0.

__device__ ​ float atanhf ( float  x )

Calculate the arc hyperbolic tangent of the input argument. Calculate the arc hyperbolic tangent of the input argument x.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • atanhf( ± 0 ) returns ± 0 .
  • atanhf( ± 1 ) returns ± .
  • atanhf(x) returns NaN for x outside interval [-1, 1].

__device__ ​ float cbrtf ( float  x )

Calculate the cube root of the input argument. Calculate the cube root of x, x 1 / 3 .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns x 1 / 3 .

  • cbrtf( ± 0 ) returns ± 0 .
  • cbrtf( ± ) returns ± .

__device__ ​ float ceilf ( float  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.

  • ceilf( ± 0 ) returns ± 0 .
  • ceilf( ± ) returns ± .

__device__ ​ float copysignf ( float  x, float  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

Returns a value with the magnitude of x and the sign of y.

__device__ ​ float cosf ( float  x )

Calculate the cosine of the input argument. Calculate the cosine of the input argument x (measured in radians).

Note:
  • For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

  • This function is affected by the --use_fast_math compiler flag. See the CUDA C Programming Guide, Appendix C, Table C-3 for a complete list of functions affected.

Returns

  • cosf(0) returns 1.
  • cosf( ± ) returns NaN.

__device__ ​ float coshf ( float  x )

Calculate the hyperbolic cosine of the input argument. Calculate the hyperbolic cosine of the input argument x.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • coshf(0) returns 1.
  • coshf( ± ) returns NaN.

__device__ ​ float cospif ( float  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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • cospif( ± 0 ) returns 1.
  • cospif( ± ) returns NaN.

__device__ ​ float erfcf ( float  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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • erfcf( ) returns 2.
  • erfcf( + ) returns +0.

__device__ ​ float erfcinvf ( float  y )

Calculate the inverse complementary error function of the input argument. Calculate the inverse complementary error function of the input argument y, for y in the interval [0, 2]. The inverse complementary error function find the value x that satisfies the equation y = erfc(x), for 0 y 2 , and x .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • erfcinvf(0) returns + .
  • erfcinvf(2) returns .

__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, e x 2 erfc ( x ) .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • erfcxf( - ) returns +
  • erfcxf( + ) returns +0
  • erfcxf(x) returns + if the correctly calculated value is outside the single floating point range.

__device__ ​ float erff ( float  x )

Calculate the error function of the input argument. Calculate the value of the error function for the input argument x, 2 π 0 x e t 2 d t .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • erff( ± 0 ) returns ± 0 .
  • erff( ± ) returns ± 1 .

__device__ ​ float erfinvf ( float  y )

Calculate the inverse error function of the input argument. Calculate the inverse error function of the input argument y, for y in the interval [-1, 1]. The inverse error function finds the value x that satisfies the equation y = erf(x), for 1 y 1 , and x .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • erfinvf(1) returns + .
  • erfinvf(-1) returns .

__device__ ​ float exp10f ( float  x )

Calculate the base 10 exponential of the input argument. Calculate the base 10 exponential of the input argument x.

Note:
  • For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

  • This function is affected by the --use_fast_math compiler flag. See the CUDA C Programming Guide, Appendix C, Table C-3 for a complete list of functions affected.

Returns

Returns 10 x .

__device__ ​ float exp2f ( float  x )

Calculate the base 2 exponential of the input argument. Calculate the base 2 exponential of the input argument x.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns 2 x .

__device__ ​ float expf ( float  x )

Calculate the base e exponential of the input argument. Calculate the base e exponential of the input argument x, e x .

Note:
  • For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

  • This function is affected by the --use_fast_math compiler flag. See the CUDA C Programming Guide, Appendix C, Table C-3 for a complete list of functions affected.

Returns

Returns e x .

__device__ ​ float expm1f ( float  x )

Calculate the base e exponential of the input argument, minus 1. Calculate the base e exponential of the input argument x, minus 1.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns e x 1 .

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns the absolute value of its argument.

  • fabs( ± ) returns + .
  • fabs( ± 0 ) returns 0.

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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.

__device__ ​ float fdividef ( float  x, float  y )

Divide two floating point values. Compute x divided by y. If --use_fast_math is specified, use __fdividef() for higher performance, otherwise use normal division.

Note:
  • For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

  • This function is affected by the --use_fast_math compiler flag. See the CUDA C Programming Guide, Appendix C, Table C-3 for a complete list of functions affected.

Returns

Returns x / y.

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns l o g e ( 1 + x ) expressed as a floating-point number.

  • floorf( ± ) returns ± .
  • floorf( ± 0 ) returns ± 0 .

__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.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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 .

__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.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns the minimum 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 fmodf ( float  x, float  y )

Calculate the floating-point remainder of x / y. Calculate the floating-point remainder of x / y. The absolute value of the computed value is always less than y's absolute value and will have the same sign as x.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • Returns the floating point remainder of x / y.
  • fmodf( ± 0 , y) returns ± 0 if y is not zero.
  • fmodf(x, y) returns NaN and raised an invalid floating point exception if x is ± or y is zero.
  • fmodf(x, y) returns zero if y is zero or the result would overflow.
  • fmodf(x, ± ) returns x if x is finite.
  • fmodf(x, 0) returns NaN.

__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 2 n . The integer exponent n will be stored in the location to which nptr points.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns the fractional component m.

  • frexp(0, nptr) returns 0 for the fractional component and zero for the integer component.
  • 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__ ​ 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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns the length of the hypotenuse x 2 + y 2 . If the correct value would overflow, returns + . If the correct value would underflow, returns 0.

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • If successful, returns the unbiased exponent of the argument.
  • ilogbf(0) returns INT_MIN.
  • ilogbf(NaN) returns NaN.
  • ilogbf(x) returns INT_MAX if x is or the correct value is greater than INT_MAX.
  • ilogbf(x) return INT_MIN if the correct value is less than INT_MIN.

__device__ ​ int 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

Returns a nonzero value if and only if a is a finite value.

__device__ ​ int isinf ( float  a )

Determine whether argument is infinite. Determine whether the floating-point value a is an infinite value (positive or negative).

Returns

Returns a nonzero value if and only if a is a infinite value.

__device__ ​ int isnan ( float  a )

Determine whether argument is a NaN. Determine whether the floating-point value a is a NaN.

Returns

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, J 0 ( x ) .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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, J 1 ( x ) .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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, J n ( x ) .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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 2 e x p . Calculate the value of x 2 e x p of the input arguments x and exp.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • ldexpf(x) returns ± if the correctly calculated value is outside the single floating point range.

__device__ ​ float lgammaf ( float  x )

Calculate the natural logarithm of the absolute value of the gamma function of the input argument. Calculate the natural logarithm of the absolute value of the gamma function of the input argument x, namely the value of l o g e |   0 e t t x 1 d t | .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • lgammaf(1) returns +0.
  • lgammaf(2) returns +0.
  • lgammaf(x) returns ± if the correctly calculated value is outside the single floating point range.
  • lgammaf(x) returns + if x 0.
  • lgammaf( ) returns .
  • lgammaf( + ) returns + .

__device__ ​ long long int llrintf ( float  x )

Round input to nearest integer value. Round x to the nearest integer value, with halfway cases rounded towards zero. If the result is outside the range of the return type, the result 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 result 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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • log10f( ± 0 ) returns .
  • log10f(1) returns +0.
  • log10f(x) returns NaN for x < 0.
  • log10f( + ) returns + .

__device__ ​ float log1pf ( float  x )

Calculate the value of l o g e ( 1 + x ) . Calculate the value of l o g e ( 1 + x ) of the input argument x.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • log1pf( ± 0 ) returns .
  • log1pf(-1) returns +0.
  • log1pf(x) returns NaN for x < -1.
  • log1pf( + ) returns + .

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • log2f( ± 0 ) returns .
  • log2f(1) returns +0.
  • log2f(x) returns NaN for x < 0.
  • log2f( + ) returns + .

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • logbf ± 0 returns
  • logbf + returns +

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • logf( ± 0 ) returns .
  • logf(1) returns +0.
  • logf(x) returns NaN for x < 0.
  • logf( + ) returns + .

__device__ ​ long int lrintf ( float  x )

Round input to nearest integer value. Round x to the nearest integer value, with halfway cases rounded towards zero. If the result is outside the range of the return type, the result 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 result is undefined.

Note:

This function may be slower than alternate rounding methods. See lrintf().

Returns

Returns rounded integer value.

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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.

__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 representations.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • nearbyintf( ± 0 ) returns ± 0 .
  • nearbyintf( ± ) returns ± .

__device__ ​ float nextafterf ( float  x, float  y )

Return next representable single-precision floating-point value afer argument. 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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • nextafterf( ± , y) returns ± .

__device__ ​ float normcdff ( float  y )

Calculate the standard normal cumulative distribution function. Calculate the cumulative distribution function of the standard normal distribution for input argument y, Φ ( y ) .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • normcdff( + ) returns 1
  • normcdff( ) returns +0

__device__ ​ float normcdfinvf ( float  y )

Calculate the inverse of the standard normal cumulative distribution function. Calculate the inverse of the standard normal cumulative distribution function for input argument y, Φ 1 ( y ) . The function is defined for input values in the interval ( 0 , 1 ) .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • normcdfinvf(0) returns .
  • normcdfinvf(1) returns + .
  • normcdfinvf(x) returns NaN if x is not in the interval [0,1].

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • powf( ± 0 , y) returns ± for y an integer less than 0.
  • powf( ± 0 , y) returns ± 0 for y an odd integer greater than 0.
  • powf( ± 0 , y) returns +0 for y > 0 and not and 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.

__device__ ​ float rcbrtf ( float  x )

Calculate reciprocal cube root function. Calculate reciprocal cube root function of x

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • rcbrt( ± 0 ) returns ± .
  • rcbrt( ± ) returns ± 0 .

__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 n y . The value n is the integer value nearest x y . In the case when | n x y | = 1 2 , the even n value is chosen.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • remainderf(x, 0) returns NaN.
  • remainderf( ± , y) returns NaN.
  • remainderf(x, ± ) returns x for finite x.

__device__ ​ float remquof ( float  x, float  y, int* quo )

Compute single-precision floating-point remainder and part of quotient. Compute a double-precision floating-point remainder in the same way as the remainderf() function. Argument quo returns part of quotient upon division of x by y. Value quo has the same sign as x y and may not be the exact quotient but agrees with the exact quotient in the low order 3 bits.

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns the remainder.

  • remquof(x, 0, quo) returns NaN.
  • remquof( ± , y, quo) returns NaN.
  • remquof(x, ± , quo) returns x.

__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 towards zero.

Returns

Returns rounded integer value.

__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.

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns 1 / x .

  • rsqrtf( + ) returns +0.
  • rsqrtf( ± 0 ) returns ± .
  • rsqrtf(x) returns NaN if x is less than 0.

__device__ ​ float scalblnf ( float  x, long int  n )

Scale floating-point input by integer power of two. Scale x by 2 n by efficient manipulation of the floating-point exponent.

Returns

Returns x * 2 n .

  • scalblnf( ± 0 , n) returns ± 0 .
  • scalblnf(x, 0) returns x.
  • scalblnf( ± , n) returns ± .

__device__ ​ float scalbnf ( float  x, int  n )

Scale floating-point input by integer power of two. Scale x by 2 n by efficient manipulation of the floating-point exponent.

Returns

Returns x * 2 n .

  • scalbnf( ± 0 , n) returns ± 0 .
  • scalbnf(x, 0) returns x.
  • scalbnf( ± , n) returns ± .

__device__ ​ int signbit ( float  a )

Return the sign bit of the input. Determine whether the floating-point value a is negative.

Returns

Returns a nonzero value if and only if a is negative. Reports the sign bit of all values including infinities, zeros, and NaNs.

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

  • This function is affected by the --use_fast_math compiler flag. See the CUDA C Programming Guide, Appendix C, Table C-3 for a complete list of functions affected.

Returns

  • none

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • none

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

  • This function is affected by the --use_fast_math compiler flag. See the CUDA C Programming Guide, Appendix C, Table C-3 for a complete list of functions affected.

Returns

  • sinf( ± 0 ) returns ± 0 .
  • sinf( ± ) 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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • sinhf( ± 0 ) returns ± 0 .
  • sinhf( ± ) 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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • sinpif( ± 0 ) returns ± 0 .
  • sinpif( ± ) 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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

Returns x .

  • sqrtf( ± 0 ) returns ± 0 .
  • sqrtf( + ) returns + .
  • sqrtf(x) returns NaN if x is less than 0.

__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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

  • This function is affected by the --use_fast_math compiler flag. See the CUDA C Programming Guide, Appendix C, Table C-3 for a complete list of functions affected.

Returns

  • tanf( ± 0 ) returns ± 0 .
  • tanf( ± ) 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 for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • tanhf( ± 0 ) returns ± 0 .

__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 0 e t t x 1 d t .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

Returns

  • tgammaf( ± 0 ) returns ± .
  • tgammaf(2) returns +0.
  • tgammaf(x) returns ± if the correctly calculated value is outside the single floating point range.
  • tgammaf(x) returns NaN if x < 0.
  • tgammaf( ) returns NaN.
  • tgammaf( + ) returns + .

__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.

Returns

Returns truncated integer value.

__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, Y 0 ( x ) .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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, Y 1 ( x ) .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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, Y n ( x ) .

Note:

For accuracy information for this function see the CUDA C Programming Guide, Appendix C, Table C-1.

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.


CUDA Math API (PDF) - CUDA Toolkit v5.5 (older) - Last updated May 11, 2013 - Send Feedback