Intel® oneAPI DPC++/C++ Compiler

Developer Guide and Reference

ID 767253
Date 3/31/2025
Public

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

Document Table of Contents

Basic Arithmetic Operations and Simple Math Functions

The compiler supports the following basic arithmetic operations and simple math functions:

abs

Description: Computes the absolute value of the integer number x for int type. In normal CPU programming, the C standard library provides functions to return the absolute value for integer values, these functions are declared in <stdlib.h>. The compiler supports these functions in SYCL device code.

Calling Interface:

int abs(int x)

labs

Description: Computes the absolute value of the integer number x for long type. In normal CPU programming, the C standard library provides functions to return the absolute value for integer values, these functions are declared in <stdlib.h>. The compiler supports these functions in SYCL device code.

Calling Interface:

long labs(long x)

llabs

Description: Computes the absolute value of the integer number x for long long type. In normal CPU programming, the C standard library provides functions to return the absolute value for integer values, these functions are declared in <stdlib.h>. The compiler supports these functions in SYCL device code.

Calling Interface:

long long llabs(long long x)

cpolar

Description: Returns a double complex number with a magnitude of rho and phase angle of theta.

In standard CPU programming, the C99 standard library provides a set of functions supporting complex number arithmetic. You can include <complex.h> to use them. These complex math functions are provided in SYCL device code.

Calling Interface:

double __complex__ __devicelib_cpolar(double rho, double theta)

cpolarf

Description: Returns a float complex number with a magnitude of rho and a phase angle of theta.

Calling Interface:

float __complex__ cpolarf(float rho, float theta)

div

Description: Computes both the quotient and the remainder of the division of the numerator x of type int by the denominator y of type int. The returned type has the following definitions:

struct div_t { int quot; int rem; };

Calling Interface:

div_t div(int x, int y)

ldiv

Description: Computes both the quotient and the remainder of the division of the numerator x of type long by the denominator y of type long. The returned type has the following definitions:

struct ldiv_t { long quot; long rem; };

Calling Interface:

ldiv_t ldiv(long x, long y)

lldiv

Description: Computes both the quotient and the remainder of the division of the numerator x of type long long by the denominator y of type long long. The returned type has the following definitions:

struct lldiv_t { long long quot; long long rem; };

Calling Interface:

lldiv_t lldiv(long long x, long long y)

__divdc3

Description: Returns the double complex quotient of (a + ib) / (c + id). During compilation, the compiler may insert reference to these two functions in your code and the linker resolves the undefined reference later.

Calling Interface:

double __complex__ __divdc3(double __a, double __b, double __c, double __d)

__divsc3

Description: Returns the float complex quotient of (a + ib) / (c + id). During compilation, the compiler may insert reference to these two functions in your code and the linker resolves the undefined reference later.

Calling Interface:

float __complex__ __divsc3(float __a, float __b, float __c, float __d)

__muldc3

Description: Returns the double complex product of (a + ib) * (c + id).

Calling Interface:

double __complex__ __muldc3(double __a, double __b, double __c, double __d)

__mulsc3

Description: Returns the float complex product of (a + ib) * (c + id).

Calling Interface:

float __complex__ __mulsc3(float __a, float __b, float __c, float __d)