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

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

Basic Arithmetic Operations and Simple Math Functions

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

cpolarf

Prototype:

float __complex__ cpolarf(float rho, float theta)

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

cpolar

Prototype:

double __complex__ __devicelib_cpolar(double rho, double theta)

Description: Returns a 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.

__divsc3, __divdc3

Prototype:

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

Description: Returns the 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.

__mulsc3, __muldc3

Prototype:

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

Description: Returns the product of a + ib and c + id.

labs, llabs

Prototype:

int abs(int x)
long labs(long x)
long long llabs(long long x)

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

ldiv, lldiv

Prototype:

div_t div(int x, int y)
ldiv_t ldiv(long x, long y)
lldiv_t lldiv(long long x, long long y)

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

struct div_t { int quot; int rem; };
struct ldiv_t { long quot; long rem; };
struct lldiv_t { long long quot; long long rem; };