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

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

IMF Device Library Miscellaneous Functions

The IMF Device Library supports the following miscellaneous functions:

copysign

Description: The copysign(x, y) function creates value with a given x magnitude and a copying sign of a second value y.

Calling Interfaces:

Default accuracy:

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

fdim

Description: The fdim(x, y) function returns the positive difference value x - y for x > y, or zero for x <= y.

Special Values:

Argument x Argument y Result fdim(y,x)
any S/QNAN QNAN
S/QNAN any QNAN

Calling Interfaces:

Default accuracy:

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

fmod

Description: The fmod(x, y) function performs a computation of the modulus function of x with respect to y.

The fmod(x, y) function returns the value x - n·y for the integer n. If y is nonzero, the result has the same sign as x and magnitude less than the magnitude of y. The fmod(x, y) function is similar to remainder excepts that it rounds the internal quotient n towards zero to an integer instead of to the nearest integer.

Special Values:

Argument x Argument y Result fmod(y,x)
x not S/QNAN +/-0 QNAN
+/-∞ y not S/QNAN QNAN
+/-0 y not 0 or S/QNAN +/-0
x finite +/-∞ x
S/QNAN any QNAN
any S/QNAN QNAN

Calling Interfaces:

Default accuracy:

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

frexp

Description: The frexp(x, exp) function extracts a mantissa and an exponent of a floating-point value.

This function converts a floating-point number x into signed normalized fraction in (1/2, 1) multiplied by an integral power of two. The signed normalized fraction is returned, and the integer exponent is stored at location exp.

Special Values:

Argument x Return frexp(x,exp) Result exp
+/-0 +/-0 0
+/-∞ +/-∞ undef
S/QNAN QNAN undef

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::frexp ( float x, int* exp );
double      sycl::ext::intel::math::frexp ( double x, int* exp );

isfinite

Description: The isfinite(x) function determines if the given floating-point number x has finite value, for example normal, subnormal or zero, but not infinite or not-a-number (NaN).

Special Values:

Argument x Result isfinite(x)
x finite +1
+/-∞ or S/QNAN +0

Calling Interfaces:

Default accuracy:

int       sycl::ext::intel::math::isfinite ( float x );
int       sycl::ext::intel::math::isfinite ( double x );

isinf

Description: The isinf(x) function determines if the given floating-point number x is a positive or negative infinity.

Special Values:

Argument x Result isinf(x)
+/-∞ +1
not +/-∞ +0

Calling Interfaces:

Default accuracy:

int       sycl::ext::intel::math::isinf ( float x );
int       sycl::ext::intel::math::isinf ( double x );

isnan

Description: The isnan(x) function determines if the given floating-point number x is a NaN value.

Special Values:

Argument x Result isnan(x)
S/QNAN +1
not S/QNAN +0

Calling Interfaces:

Default accuracy:

int       sycl::ext::intel::math::isnan ( float x );
int       sycl::ext::intel::math::isnan ( double x );

ldexp

Description: The ldexp(x, exp) multiplies a floating-point value x by the number 2 raised to the exp power.

This function returns x·2^exp result, where exp is an integer value. On binary systems (where FLT_RADIX is 2), the ldexp function is equivalent to scalbn.

Special Values:

Argument x Argument exp Result ldexp(x,exp)
+/-0 any +/-0
+/-∞ any +/-∞
any 0 x

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::ldexp ( float x, int exp );
double      sycl::ext::intel::math::ldexp ( double x, int exp );

modf

Description: The modf(x, intptr) function splits a floating-point x value into fractional and integer parts.

This function breaks down the floating-point value x into fractional and integer parts, each of which has the same sign as x. The signed fractional portion of x is returned. The integer portion is stored as a floating-point value at the intptr pointer.

Special Values:

Argument x Return modf(x,exp) Result intptr
+/-0 +/-0 +/-0
+/-∞ +/-0 +/-∞

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::modf ( float x, float* intptr );
double      sycl::ext::intel::math::modf ( double x, double* intptr );

nan

Description: The nan(tagp) function returns a NaN value.

This function returns a representation of a quiet NaN. The argument tagp selects one of the possible representations.

Calling Interfaces:

Default accuracy:

float      sycl::ext::intel::math::nanf ( const char* x );
double     sycl::ext::intel::math::nan  ( const char* x );

nextafter

Description: The nextafter(x, y) function returns the next representable floating-point value after x in the direction of y.

This function calculates the next representable floating-point value following x in the direction of y. For example, if y is greater than x, the nextafter() returns the smallest representable number greater than x. The returned value is independent of the execution device's current rounding mode.

Special Values:

Argument x Argument y Result nextafter(y,x)
-0 +0 +0
+0 -0 -0

Calling Interfaces:

Default accuracy:

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

remainder

Description: The remainder(x, y) function returns the value of x REM y as required by the IEEE754 standard.

The remainder(x, y) function computes the value x - n·y where n is the integer nearest to the exact value of x / y. If two integers are equally close to x / y, n is the even one. If n is zero, it has the same sign as x. The remainder(x, y) function is similar to fmod, except that it rounds the internal quotient n to the nearest integer instead of towards zero to an integer.

Special Values:

Argument x Argument y Result remainder(y,x)
x not S/QNAN +/-0 QNAN
+/-∞ y not S/QNAN QNAN
+/-0 y not 0 or S/QNAN +/-0
x finite +/-∞ x
S/QNAN any QNAN
any S/QNAN QNAN

Calling Interfaces:

Default accuracy:

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

remquo

Description: The remquo(x, y, quo) function computes floating-point remainder and part of a quotient.

This function computes a floating-point remainder in the same way as the remainder(x, y, quo) function. It also returns a part of a quotient upon division of x by y through the quo pointer. The value quo has the same sign as and may not be the exact quotient, but agrees with the exact quotient in the low order 3 bits that are sufficient to determine the octant of the result within a period.

Special Values:

Argument x Argument y Return remquo(y,x,quo) Result quo
x not S/QNAN +/-0 QNAN undef
+/-∞ y not S/QNAN QNAN undef
+/-0 y not 0 or S/QNAN +/-0 0
x finite +/-∞ x 0
S/QNAN any QNAN undef
any S/QNAN QNAN undef

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::remquo ( float x, float y, int* quo );
double      sycl::ext::intel::math::remquo ( double x, double y, int* quo );

saturate

Description: The saturate(x) function clamps the input argument x to the [+0.0, 1.0] range.

Special Values:

Argument x Result saturate(x)
x < +0 +0
x > +1 +1
0 <= x <= 1 x
S/QNAN +0

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::saturate ( float x );

scalbn

Description: The scalbn(x, exp) multiplies a floating-point value x by FLT_RADIX raised to the power exp.

This function returns a x·FLT_RADIX^exp result, where exp is an integer value. On binary systems (where FLT_RADIX is 2), the scalbn function is equivalent to ldexp.

Special Values:

Argument x Argument exp Result scalbn(x,exp)
+/-0 any +/-0
+/-∞ any +/-∞
any 0 x

Calling Interfaces:

Default accuracy:

float       sycl::ext::intel::math::scalbn ( float x, int exp );
double      sycl::ext::intel::math::scalbn ( double x, int exp );

signbit

Description: The signbit(x) function determines if the given floating-point number x is negative.

This function detects the sign bit of both finite and infinite values including zeroes, infinities, and NaNs.

Special Values:

Argument x Result signbit(x)
x neg. +1
x pos. +0

Calling Interfaces:

Default accuracy:

int       sycl::ext::intel::math::signbit ( float x );
int       sycl::ext::intel::math::signbit ( double x );