Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 6/24/2024
Public
Document Table of Contents

IMF Device Library Power Functions

The IMF Device Library supports the following power and inverse power functions:

cbrt

Description: The cbrt(x) inlined function returns a cube root of x: x^(1/3).

This function is not equivalent to pow(x, 1.0/3.0) because the rational number 1/3 is not equal to the floating point number 1.0/3.0. The cbrt(x) usually gives more accurate result than pow(x, 1.0/3.0).

Special Values:

Argument x Result cbrt(x)
+/-∞ +/-∞
+/-0 +/-0

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::cbrt ( float x );
double      sycl::ext::intel::math::cbrt ( double x );

hypot

Description: The hypot(y, x) returns a square root of sum of two squared elements: sqrt( x^2 + y^2 ).

The function calculates the length of the hypotenuse of a right triangle whose two sides have lengths x and y without undue overflow or underflow.

Special Values:

Argument x Argument y Result hypot(x,y)
+/-0 +/-0 +0
+/-∞ any y +∞
any x +/-∞ +∞

Calling Interfaces:

  • Default accuracy:
    float       sycl::ext::intel::math::hypot ( float x, float y );
    double      sycl::ext::intel::math::hypot ( double x, double y );
  • High accuracy (HA):
    float       sycl::ext::intel::math::ha::hypot ( float x, float y );
    double      sycl::ext::intel::math::ha::hypot ( double x, double y );
  • Low accuracy (LA):
    float       sycl::ext::intel::math::la::hypot ( float x, float y );
    double      sycl::ext::intel::math::la::hypot ( double x, double y );

inv

Description: The inv(x) inlined function returns the inversion of x: 1/x.

Special Values:

Argument x Result inv(x)
+/-0 +/-∞
+/-∞ +/-0
NOTE:
The special values processing rules of inlined functions inv may be affected by the -f[no-]fast-math compiler switch.

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::inv ( float x );
double      sycl::ext::intel::math::inv ( double x );

norm

Description: The norm(dim, x) function returns the square root of the sum of squares of any number of coordinates: sqrt( x[0]^2 + x[1]^2 + ... + x[dim-1]^2 ).

This function calculates the length of the dim-D vector, where the dimension of what is passed as an argument is without undue overflow or underflow.

Special Values:

Any x[i] Result norm(dim, x)
+/-∞ +∞

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::norm ( int dim, float* x );
double      sycl::ext::intel::math::norm ( int dim, double* x );

norm3d

Description: The norm3d(x, y, z) function returns the square root of the sum of squares of three coordinates: sqrt( x^2 + y^2 + z^2 ).

This function calculates the length of the 3-D vector without undue overflow or underflow.

Special Values:

Any x,y,z Result norm3d(x,y,z)
+/-∞ +∞

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::norm3d ( float x, float y, float z );
double      sycl::ext::intel::math::norm3d ( double x, double y, double z );

norm4d

Description: The norm4d(w, x, y, z) function returns the square root of the sum of squares of four coordinates: sqrt( x^2 + x^2 + y^2 + z^2 ).

This function calculates the length of the 4-D vector without undue overflow or underflow.

Special Values:

Any w,x,y,z Result norm4d(w,x,y,z)
+/-∞ +∞

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::norm4d ( float w, float x, float y, float z );
double      sycl::ext::intel::math::norm4d ( double w, double x, double y, double z );

pow

Description: The pow(x, y) returns x raised to the power of y: x^y.

Special Values:

Argument x Argument y Result pow(x,y)
-∞ +∞ +∞
-∞ -∞ +0
-∞ neg. odd int -0
-∞ neg. even int +0
-∞ neg. non-int +0
-∞ pos. odd int -∞
-∞ pos. even int +∞
-∞ pos. non-int +∞
-∞ +/-0 +1
-1 +/-∞ +1
x < +0 non-int QNAN
-0 neg. non-int +∞
+/-0 neg. odd int +/-∞
+/-0 neg. even int +∞
+/-0 pos. even int +0
+/-0 pos. non-int +0
+/-0 +∞ +0
+/-0 pos. odd int +/-0
+/-0 -∞ +∞
+/-0 -0 +1
+/-0 +0 +1
|x| < 1 -∞ +∞
|x| < 1 +∞ +0
+1 any y +1
+1 +/-0 +1
+1 +/-∞ +1
+1 S/QNAN +1
|x| > 1 -∞ +0
|x| > 1 +∞ +∞
+∞ +/-0 +1
+∞ y < +0 +0
+∞ y > +0 +∞
+∞ -∞ +0
+∞ +∞ +∞
any x +0 +1
any x -0 +1
S/QNAN +0 +1
S/QNAN -0 +1

Useful Identities:

pow(x, y) = exp( y·log(x) ), in low accuracy and possible special values processing incompliance

Calling Interfaces:

  • Default accuracy:
    float       sycl::ext::intel::math::pow ( float x, float y );
    double      sycl::ext::intel::math::pow ( double x, double y );
  • High accuracy (HA):
    float       sycl::ext::intel::math::ha::pow ( float x, float y );
    double      sycl::ext::intel::math::ha::pow ( double x, double y );
  • Low accuracy (LA):
    float       sycl::ext::intel::math::la::pow ( float x, float y );
    double      sycl::ext::intel::math::la::pow ( double x, double y );
  • Enhanced performance:
    float       sycl::ext::intel::math::ep::pow ( float x, float y );

powi

Description: The powi(y, n) returns x raised to the integer power of n: x^n.

Special Values:

Argument x Argument n Result powi(x,n)
-∞ neg. odd int -0
-∞ neg. even int +0
-∞ pos. odd int -∞
-∞ pos. even int +∞
-∞ 0 +1
+/-0 neg. odd int +/-∞
+/-0 neg. even int +∞
+/-0 pos. even int +0
+/-0 pos. odd int +/-0
+/-0 0 +1
+1 any n +1
+1 0 +1
+∞ 0 +1
+∞ n < 0 +0
+∞ n > 0 +∞
any x 0 +1
S/QNAN 0 +1

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::powi ( float x, int n );
double      sycl::ext::intel::math::powi ( double x, int n );

rcbrt

Description: The rcbrt(x) inlined function returns the inverse cube root of x: x^(-1/3).

This function is not equivalent to pow(x, -1.0/3.0) because the rational number -1/3 is not equal to the floating point number -1.0/3.0. The rcbrt(x) usually gives more accurate result than pow(x, -1.0/3.0).

Special Values:

Argument x Result rcbrt(x)
+/-0 +/-∞
+/-∞ +/-0

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::rcbrt ( float x );
double      sycl::ext::intel::math::rcbrt ( double x );

rhypot

Description: The rhypot(y, x) returns an inverse square root of sum of two squared elements: 1 / sqrt( x^2 + y^2 ).

The function calculates 1.0 over the length of the hypotenuse of a right triangle whose two sides have lengths x and y without undue overflow or underflow.

Special Values:

Argument x Argument y Result rhypot(x,y)
+/-0 +/-0 +∞
+/-∞ any y +0
any x +/-∞ +0

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::rhypot ( float x, float y );
double      sycl::ext::intel::math::rhypot ( double x, double y );

rnorm

Description: The rnorm(dim, x) function returns the inverse square root of the sum of squares of any number of coordinates: 1 / sqrt( x[0]^2 + x[1]^2 + ... + x[dim-1]^2 ).

This function calculates one over the length of the dim-D vector, dimension of which is passed as an argument without undue overflow or underflow.

Special Values:

Any x[i] Result rnorm(dim, x)
+/-∞ +0

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::rnorm ( int dim, float* x );
double      sycl::ext::intel::math::rnorm ( int dim, double* x );

rnorm3d

Description: The rnorm3d(x, y, z) function returns the inverse square root of the sum of squares of three coordinates: 1 / sqrt( x^2 + y^2 + z^2 ).

This function calculates one over the length of the 3-D vector without undue overflow or underflow.

Special Values:

Any x,y,z Result rnorm3d(x,y,z)
+/-∞ +0

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::rnorm3d ( float x, float y, float z );
double      sycl::ext::intel::math::rnorm3d ( double x, double y, double z );

rnorm4d

Description: The rnorm4d(w, x, y, z) function returns the inverse square root of the sum of squares of four coordinates: 1 / sqrt( w^2 + x^2 + y^2 + z^2 ).

This function calculates one over the length of the 4-D vector without undue overflow or underflow.

Special Values:

Any w,x,y,z Result rnorm4d(w,x,y,z)
+/-∞ +0

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::rnorm4d ( float w, float x, float y, float z );
double      sycl::ext::intel::math::rnorm4d ( double w, double x, double y, double z );

rsqrt

Description: The rsqrt(x) inlined function returns inverse square root of x: x^(-1/2).

Special Values:

Argument x Result rsqrt(x)
-∞ QNAN
x < +0 QNAN
+/-0 +/-∞
+∞ +0
NOTE:
Special values processing rules of inlined functions rsqrt may be affected by -f[no-]fast-math compiler switch.

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::rsqrt ( float x );
double      sycl::ext::intel::math::rsqrt ( double x );

sqrt

Description: The sqrt(x) inlined function returns square root of x: x^(1/2).

Special Values:

Argument x Result sqrt(x)
-∞ QNAN
x < +0 QNAN
+/-0 +/-0
+∞ +∞
NOTE:
Special values processing rules of inlined functions sqrt may be affected by -f[no-]fast-math compiler switch.

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::sqrt ( float x );
double      sycl::ext::intel::math::sqrt ( double x );