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

ID 767253
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

IMF Device Library Trigonometric Functions

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

acos

Description: The acos(x) function returns the principal value of the inverse cosine of x in the range [ 0 , π ] radians for x in the interval [ -1 , 1 ].

Special Values:

Argument x Result acos(x)
-1
+/-0 +π/2
+1 +0
|x| > 1 QNAN
+/-∞ QNAN

Useful Identities:

acos(x) = asin( sqrt(1 - x^2) ), 0 <= x <= 1
acos(x) = atan( sqrt(1 - x^2) / x )

Calling Interfaces:

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

asin

Description: The asin(x) function returns the principal value of the inverse sine of x in the range [ -π/2 , +π/2 ] radians for x in the interval [ -1 ,1 ].

Special Values:

Argument x Result asin(x)
-1 -π/2
+/-0 +/-0
+1 +π/2
|x| > 1 QNAN
+/-∞ QNAN

Useful Identities:

asin(x) = 0.5 · acos( 1 - 2·x^2 ), 0 <= x <= 1
asin(x) = atan( x / sqrt(1 - x^2) )

Calling Interfaces

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

atan

Description: The atan(x) returns the principal value of the inverse tangent of x in the range [ -π/2 , +π/2 ] radians.

Special Values:

Argument x Result atan(x)
+/-0 +/-0
+/-∞ +/-π/2

Useful Identities:

atan(x) = asin( x / sqrt(1 + x^2) )
atan(x) = acos(sqrt (1 / (1 + x^2))) , x >= 0

Calling Interfaces:

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

atan2

Description: The atan2(y, x) returns the principal value of the inverse tangent of y/x in the range [ -π , +π ] radians.

Special Values:

Argument y Argument x Result atan2(y,x)
-∞ -∞ -3*π/2
-∞ x < +0 -π/2
-∞ -0 -π/2
-∞ +0 -π/2
-∞ x > +0 -π/2
-∞ +∞ -π/4
y < +0 -∞
y < +0 -0 -π/2
y < +0 +0 -π/2
y < +0 +∞ -0
-0 -∞
-0 x < +0
-0 -0
-0 +0 -0
-0 x > +0 -0
-0 +∞ -0
+0 -∞
+0 x < +0
+0 -0
+0 +0 +0
+0 x > +0 +0
+0 +∞ +0
y > +0 -∞
y > +0 -0 +π/2
y > +0 +0 +π/2
y > +0 +∞ +0
+∞ -∞ +3*π/4
+∞ x < +0 +π/2
+∞ -0 +π/2
+∞ +0 +π/2
+∞ x > +0 +π/2
+∞ +∞ +π/4
any y S/QNAN QNAN
S/QNAN any x QNAN

Calling Interfaces

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

cos

Description: The cos(x) function returns the cosine of x measured in radians.

Special Values:

Argument x Result cos(x)
+/-0 +1
+/-∞ QNAN

Calling Interfaces

  • Default accuracy:
    sycl::half  sycl::ext::intel::math::cos ( sycl::half x );
    float       sycl::ext::intel::math::cos ( float x );
    double      sycl::ext::intel::math::cos ( double x );
  • High accuracy (HA):
    float       sycl::ext::intel::math::ha::cos ( float x );
    double      sycl::ext::intel::math::ha::cos ( double x );
  • Low accuracy (LA):
    float       sycl::ext::intel::math::la::cos ( float x );
    double      sycl::ext::intel::math::la::cos ( double x );
  • Enhanced performance (EP):
    float       sycl::ext::intel::math::ep::cos ( float x );
    double      sycl::ext::intel::math::ep::cos ( double x );

cospi

Description: The cospi(x) function returns the cosine of x multiplied by π: cos(x·π).

Special Values:

Argument x Result cospi(x)
+/-0 +1
n + 0.5 +0
+/-∞ QNAN
NOTE:
n is any integer number where n + 0.5 is representable.

Useful Identities

cospi(x) = cos(x·PI)

Calling Interfaces

Default accuracy:

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

sin

Description: The sin(x) function returns the sine of x measured in radians.

Special Values:

Argument x Result sin(x)
+/-0 +/-0
+/-∞ QNAN

Calling Interfaces

  • Default accuracy:
    sycl::half  sycl::ext::intel::math::sin ( sycl::half x );
    float       sycl::ext::intel::math::sin ( float x );
    double      sycl::ext::intel::math::sin ( double x );
  • High accuracy (HA):
    float       sycl::ext::intel::math::ha::sin ( float x );
    double      sycl::ext::intel::math::ha::sin ( double x );
  • Low accuracy (LA):
    float       sycl::ext::intel::math::la::sin ( float x );
    double      sycl::ext::intel::math::la::sin ( double x );
  • Enhanced performance (EP):
    float       sycl::ext::intel::math::ep::sin ( float x );
    double      sycl::ext::intel::math::ep::sin ( double x );

sincos

Description: The sincos(x, &s, &c) function returns the sine and cosine of x measured in radians: s=sin(x), c=cos(x).

Special Values:

Argument x Result s=sin(x) Result c=cos(x)
+/-0 +/-0 +1
+/-∞ QNAN QNAN

Calling Interfaces

  • Default accuracy:
    float       sycl::ext::intel::math::sincos ( float x, float* s, float* c );
    double      sycl::ext::intel::math::sincos ( double x, double* s, double* c );
  • High accuracy (HA):
    float       sycl::ext::intel::math::ha::sincos ( float x );
    double      sycl::ext::intel::math::ha::sincos ( double x );
  • Low accuracy (LA):
    float       sycl::ext::intel::math::la::sincos ( float x );
    double      sycl::ext::intel::math::la::sincos ( double x );
  • Enhanced performance (EP):
    double      sycl::ext::intel::math::ep::sincos ( double x );

sincospi

Description: The sincospi(x, &s, &c) function returns the sine and cosine of x multiplied by π: s=sin(x·π), c=cos(x·π).

Special Values:

Argument x Result s=sinpi(x) Result c=cospi(x)
+/-0 +/-0 +1
+/-n (n is any integer number) +/-0 cospi(x)
n + 0.5 (n is any integer number where n + 0.5 is representable) sinpi(x) +0
+/-∞ QNAN QNAN

Calling Interfaces

Default accuracy:

float       sycl::ext::intel::math::sincospi ( float x, float* s, float* c );
double      sycl::ext::intel::math::sincospi ( double x, double* s, double* c );

sinpi

Description: The sinpi(x) function returns the sine of x multiplied by π: sin(x·π).

Special Values:

Argument x Result sinpi(x)
+/-0 +/-0
+/-n* +/-0
+/-∞ QNAN

Useful Identities:

sinpi(x) = sin(x·PI)

Calling Interfaces

Default accuracy:

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

tan

Description: The tan(x) function returns the tangent of x measured in radians.

Special Values:

Argument x Result tan(x)
+/-0 +/-0
+/-∞ QNAN

Useful Identities

tan(x) = sin(x) / cos(x)

Calling Interfaces

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