Arithmetic functions

The following sections describe all the arithmetic built-in functions, categorized by their number of operands:

Unary functions

Unary functions operate on a single input operand. These functions are listed in Table 14.

Table 14. Unary functions
Function Parallel convert to integer: __fpctiw
Purpose Converts in parallel the primary and secondary elements of operand a to 32-bit integers. After a call to this function, use the __stfpiw function to store the converted integers in parallel, as described in Load and store functions.
Formula
primary(result) = primary(a)
secondary(result) = secondary(a)
C/C++ prototype double _Complex __fpctiw (double _Complex a);
Fortran description FPCTIW(A)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel convert to integer and round to zero: __fpctiwz
Purpose Converts in parallel the primary and secondary elements of operand a to 32 bit integers and rounds the results to zero. After a call to this function, you will want to use the __stfpiw function to store the converted integers in parallel, as described in Load and store functions.
Formula
primary(result) = primary(a)
secondary(result) = secondary(a)
C/C++ prototype double _Complex __fpctiwz(double _Complex a);
Fortran description FPCTIWZ(A)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel round double-precision to single-precision: __fprsp
Purpose Rounds in parallel the primary and secondary elements of double-precision operand a to single precision.
Formula
primary(result) = primary(a)
secondary(result) = secondary(a)
C/C++ prototype double _Complex __fprsp (double _Complex a);
Fortran description FPRSP(A)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel reciprocal estimate: __fpre
Purpose Calculates in parallel double-precision estimates of the reciprocal of the primary and secondary elements of operand a.
Formula
primary(result) = primary(a)
secondary(result) = secondary(a)
C/C++ prototype double _Complex __fpre(double _Complex a);
Fortran description FPRE(A)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel reciprocal square root: __fprsqrte
Purpose Calculates in parallel double-precision estimates of the reciprocals of the square roots of the primary and secondary elements of operand a.
Formula
primary(result) = primary(a)
secondary(result) = secondary(a)
C/C++ prototype double _Complex __fprsqrte (double _Complex a);
Fortran description FPRSQRTE(A)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel negate: __fpneg
Purpose Calculates in parallel the negative absolute values of the primary and secondary elements of operand a.
Formula
primary(result) = primary(a)
secondary(result) = secondary(a)
C/C++ prototype double _Complex __fpneg (double _Complex a);
Fortran description FPNEG(A)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel absolute: __fpabs
Purpose Calculates in parallel the absolute values of the primary and secondary elements of operand a.
Formula
primary(result) = primary(a)
secondary(result) = secondary(a)
C/C++ prototype double _Complex __fpabs (double _Complex a);
Fortran description FPABS(A)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel negate absolute: __fpnabs
Purpose Calculates in parallel the negative absolute values of the primary and secondary elements of operand a.
Formula
primary(result) = primary(a)
secondary(result) = secondary(a)
C/C++ prototype double _Complex __fpnabs (double _Complex a);
Fortran description FPNABS(A)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)

Binary functions

Binary functions operate on two input operands. The functions are listed in Table 15.

Table 15.
Function Parallel add: __fpadd
Purpose Adds in parallel the primary and secondary elements of operands a and b.
Formula
primary(result) = primary(a) + primary(b)
secondary(result) = secondary(a) + secondary(b)
C/C++ prototype double _Complex __fpadd (double _Complex a, double _Complex b);
Fortran description FPADD(A,B)
where A is of type COMPLEX(8)  
where B is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel subtract: __fpsub
Purpose Subtracts in parallel the primary and secondary elements of operand b from the corresponding primary and secondary elements of operand a.
Formula
primary(result) = primary(a) - primary(b)
secondary(result) = secondary(a) - secondary(b)
C/C++ prototype double _Complex __fpsub (double _Complex a, double _Complex b);
Fortran description FPSUB(A,B)
where A is of type COMPLEX(8)  
where B is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel multiply: __fpmul
Purpose Multiples in parallel the values of primary and secondary elements of operands a and b.
Formula
primary(result) = primary(a) × primary(b)
secondary(result) = secondary(a) × secondary(b)
C/C++ prototype double _Complex __fpmul (double _Complex a, double _Complex b);
Fortran description FPMUL(A,B)
where A is of type COMPLEX(8)  
where B is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Cross multiply: __fxmul
Purpose The product of the secondary element of a and the primary element of b is stored as the primary element of the return value. The product of the primary element of a and the secondary element of b is stored as the secondary element of the return value.
Formula
primary(result) = secondary(a) x primary(b)
secondary(result) = primary(a) × secondary(b)
C/C++ prototype double _Complex __fxmul (double _Complex a, double _Complex b);
Fortran description FXMUL(A,B)
where A is of type COMPLEX(8)  
where B is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Cross copy multiply: _fxpmul, __fxsmul
Purpose Both of these functions can be used to achieve the same result. The product of a and the primary element of b is stored as the primary element of the return value. The product of a and the secondary element of b is stored as the secondary element of the return value.
Formula
primary(result) = a x primary(b)
secondary(result) = a x secondary(b)
C/C++ prototype
double _Complex __fxpmul (double _Complex b, double a);
double _Complex __fxsmul (double _Complex b, double a);
Fortran description FXPMUL(B,A) or FXSMUL(B,A)
where B is of type COMPLEX(8)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)

Multiply-add functions

Multiply-add functions take three input operands, multiply the first two, and add or subtract the third.

Table 16.
Function Parallel multiply-add: __fpmadd
Purpose The sum of the product of the primary elements of a and b, added to the primary element of c, is stored as the primary element of the return value. The sum of the product of the secondary elements of a and b, added to the secondary element of c, is stored as the secondary element of the return value.
Formula
primary(result) = primary(a) × primary(b) + primary(c)
secondary(result) = secondary(a) × secondary(b) + secondary(c)
C/C++ prototype double _Complex __fpmadd (double _Complex c, double _Complex b, double _Complex a);
Fortran description FPMADD(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel negative multiply-add: __fpnmadd
Purpose The sum of the product of the primary elements of a and b, added to the primary element of c, is negated and stored as the primary element of the return value. The sum of the product of the secondary elements of a and b, added to the secondary element of c, is negated and stored as the secondary element of the return value.
Formula
primary(result) = -(primary(a) × primary(b) + primary(c))
secondary(result) = -(secondary(a) × secondary(b) + secondary(c))
C/C++ prototype double _Complex __fpnmadd (double _Complex c, double _Complex b, double _Complex a);
Fortran description FPNMADD(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel multiply-subtract: __fpmsub
Purpose The difference of the primary element of c, subtracted from the product of the primary elements of a and b, is stored as the primary element of the return value. The difference of the secondary element of c, subtracted from the product of the secondary elements of a and b, is stored as the secondary element of the return value.
Formula
primary(result) = primary(a) × primary(b) - primary(c)
secondary(result) = secondary(a) × secondary(b) - secondary(c)
C/C++ prototype double _Complex __fpmsub (double _Complex c, double _Complex b, double _Complex a);
Fortran description FPMSUB(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Parallel negative multiply-subtract: __fpnmsub
Purpose The difference of the primary element of c, subtracted from the product of the primary elements of a and b, is negated and stored as the primary element of the return value. The difference of the secondary element of c, subtracted from the product of the secondary elements of a and b, is negated and stored as the secondary element of the return value.
Formula
primary(result) = -(primary(a) × primary(b) - primary(c))
secondary(result) = -(secondary(a) × secondary(b) - secondary(c))
C/C++ prototype double _Complex __fpnmsub (double _Complex c, double _Complex b, double _Complex a);
Fortran description FPNMSUB(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Cross multiply-add: __fxmadd
Purpose The sum of the product of the secondary element of a and the primary element of b, added to the primary element of c, is stored as the primary element of the return value. The sum of the product of the primary element of a and the secondary b, added to the secondary element of c, is stored as the secondary element of the return value.
Formula
primary(result) = secondary(a) × primary(b) + primary(c)
secondary(result) = primary(a) × secondary(b) + secondary(c)
C/C++ prototype double _Complex __fxmadd (double _Complex c, double _Complex b, double _Complex a);
Fortran description FXMADD(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Cross negative multiply-add: __fxnmadd
Purpose The sum of the product of the secondary element of a and the primary element of b , added to the primary element of c, is negated and stored as the primary element of the return value. The sum of the product of the primary element of a and the secondary element of b, added to the secondary element of c, is negated and stored as the secondary element of the return value.
Formula
primary(result) = -(secondary(a) × primary(b) + primary(c))
secondary(result) = -(primary(a) × secondary(b) + secondary(c))
C/C++ prototype double _Complex __fxnmadd (double _Complex c, double _Complex b, double _Complex a);
Fortran description FXNMADD(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Cross multiply-subtract: __fxmsub
Purpose The difference of the primary element of c, subtracted from the product of the secondary element of a and the primary element of b , is stored as the primary element of the return primary element of a and the secondary element of b is stored as the secondary element of the return value.
Formula
primary(result) = secondary(a) × primary(b) - primary(c)
secondary(result) = primary(a) × secondary(b) - secondary(c)
C/C++ prototype double _Complex __fxmsub (double _Complex c, double _Complex b, double _Complex a);
Fortran description FXMSUB(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Cross negative multiply-subtract: __fxnmsub
Purpose The difference of the primary element of c, subtracted from the product of the secondary element of a and the primary element of b , is negated and stored as the primary element of the return value. The difference of the secondary element of c, subtracted from the product of the primary element of a and the secondary element of b , is negated and stored as the secondary element of the return value.
Formula
primary(result) = -(secondary(a) × primary(b) - primary(c))
secondary(result) = -(primary(a) × secondary(b) - secondary(c))
C/C++ prototype double _Complex __fxnmsub (double _Complex c, double _Complex b, double _Complex a);
Fortran description FXNMSUB(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type COMPLEX(8)
result is of type COMPLEX(8)
Function Cross copy multiply-add: __fxcpmadd, __fxcsmadd
Purpose Both of these functions can be used to achieve the same result. The sum of the product of a and the primary element of b, added to the primary element of c , is stored as the primary element of the return value. The sum of the product of a and the secondary element of b, added to the secondary element of c , is stored as the secondary element of the return value.
Formula
primary(result) = a x primary(b) + primary(c)
secondary(result) = a x secondary(b) + secondary(c)
C/C++ prototype
double _Complex __fxcpmadd (double _Complex c, double
          _Complex b, double a);
double _Complex __fxcsmadd (double _Complex c, double
          _Complex b, double a);
Fortran description FXCPMADD(C,B,A) or FXCSMADD(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type REAL(8)
result is of type COMPLEX(8)
Function Cross copy negative multiply-add: __fxcpnmadd, __fxcsnmadd
Purpose Both of these functions can be used to achieve the same result. The difference of the primary element of c, subtracted from the product of a and the primary element of b, is negated and stored as the primary element of the return value. The difference of the secondary element of c , subtracted from the product of a and the secondary element of b, is negated stored as the secondary element of the return value.
Formula
primary(result) = -(a x primary(b) + primary(c))
secondary(result) = -(a x secondary(b) + secondary(c))
C/C++ prototype
double _Complex __fxcpnmadd (double _Complex c,
          double _Complex b, double a);
double _Complex __fxcsnmadd (double _Complex c, double
          _Complex b, double a);
Fortran description FXCPNMADD(C,B,A) or FXCSNMADD(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type REAL(8)
result is of type COMPLEX(8)
Function Cross copy multiply-subtract: __fxcpmsub, __fxcsmsub
Purpose Both of these functions can be used to achieve the same result. The difference of the primary element of c, subtracted from the product of a and the primary element of b, is stored as the primary element of the return value. The difference of the secondary element of c, subtracted from the product of a and the secondary element of b, is stored as the secondary element of the return value.
Formula
primary(result) = a x primary(b) - primary(c)
secondary(result) = a x secondary(b) - secondary(c)
C/C++ prototype
double _Complex __fxcpmsub (double _Complex c, double
          _Complex b, double a);
double _Complex __fxcsmsub (double _Complex c, double
          _Complex b, double a);
Fortran description FXCPMSUB(C,B,A) or FXCSMSUB(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type REAL(8)
result is of type COMPLEX(8)
Function Cross copy negative multiply-subtract: __fxcpnmsub, __fxcsnmsub
Purpose Both of these functions can be used to achieve the same result. The difference of the primary element of c, subtracted from the product of a and the primary element of b, is negated and stored as the primary element of the return value. The difference of the secondary element of c, subtracted from the product of a and the secondary element of b, is negated stored as the secondary element of the return value.
Formula
primary(result) = -(a x primary(b) - primary(c))
secondary(result) = -(a x secondary(b) - secondary(c))
C/C++ prototype
double _Complex __fxcpnmsub (double _Complex c, double
          _Complex b, double a);
double _Complex __fxcsnmsub (double _Complex c, double
          _Complex b, double a);
Fortran description FXCPNMSUB(C,B,A) or FXCSNMSUB(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type REAL(8)
result is of type COMPLEX(8)
Function Cross copy sub-primary multiply-add: __fxcpnpma, __fxcsnpma
Purpose Both of these functions can be used to achieve the same result. The difference of the primary element of c, subtracted from the product of a and the primary element of b, is negated and stored as the primary element of the return value. The sum of the product of a and the secondary element of b, added to the secondary element of c, is stored as the secondary element of the return value.
Formula
primary(result) = -(a x primary(b) - primary(c))
secondary(result) = a x secondary(b) + secondary(c)
C/C++ prototype
double _Complex __fxcpnpma (double _Complex c, double
          _Complex b, double a);
double _Complex __fxcsnpma (double _Complex c, double
          _Complex b, double a);
Fortran description FXCPNPMA(C,B,A) or FXCSNPMA(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type REAL(8)
result is of type COMPLEX(8)
Function Cross copy sub-secondary multiply-add: __fxcpnsma, __fxcsnsma
Purpose Both of these functions can be used to achieve the same result. The sum of the product of a and the primary element of b, added to the primary element of c, is stored as the primary element of the return value. The difference of the secondary element of c, subtracted from the product of a and the secondary element of b, is negated and stored as the secondary element of the return value.
Formula
primary(result) = a x primary(b) + primary(c))
secondary(result) = -(a x secondary(b) - secondary(c))
C/C++ prototype
double _Complex ____fxcpnsma (double _Complex c, double
          _Complex b, double a);
double _Complex __fxcsnsma (double _Complex c, double
          _Complex b, double a);
Fortran description FXCPNSMA(C,B,A) or FXCSNSMA(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type REAL(8)
result is of type COMPLEX(8)
Function Cross mixed multiply-add: __fxcxma
Purpose The sum of the product of a and the secondary element of b, added to the primary element of c, is stored as the primary element of the return value. The sum of the product of a and the primary element of b, added to the secondary element of c, is stored as the secondary element of the return value.
Formula
primary(result) = a x secondary(b) + primary(c)
secondary(result) = a x primary(b) +secondary(c)
C/C++ prototype double _Complex __fxcxma (double _Complex c, double _Complex b, double a);
Fortran description FXCXMA(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type REAL(8)
result is of type COMPLEX(8)
Function Cross mixed negative multiply-subtract: __fxcxnms
Purpose The difference of the primary element of c, subtracted from the product of a and the secondary element of b, is negated and stored as the primary element of the return value. The difference of the secondary element of c, subtracted from the product of a and the primary element of b, is negated and stored as the primary secondary of the return value.
Formula
primary(result) = -(a × secondary(b) - primary(c))
secondary(result) = -(a × primary(b) - secondary(c))
C/C++ prototype double _Complex __fxcxnms (double _Complex c, double _Complex b, double a);
Fortran description FXCXNMS(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type REAL(8)
result is of type COMPLEX(8)
Function Cross mixed sub-primary multiply-add: __fxcxnpma
Purpose The difference of the primary element of c, subtracted from the product of a and the secondary element of b, is stored as the primary element of the return value. The sum of the product of a and the primary element of b, added to the secondary element of c, is stored as the secondary element of the return value.
Formula
primary(result) = (a × secondary(b) - primary(c))
secondary(result) = a × primary(b) + secondary(c)
C/C++ prototype double _Complex __fxcxnpma (double _Complex c, double _Complex b, double a);
Fortran description FXCXNPMA(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type REAL(8)
result is of type COMPLEX(8)
Function Cross mixed sub-secondary multiply-add: __fxcxnsma
Purpose The sum of the product of a and the secondary element of b, added to the primary element of c, is stored as the primary element of the return value. The difference of the secondary element of c, subtracted from the product of a and the primary element of b, is stored as the secondary element of the return value.
Formula
primary(result) = a x secondary(b) + primary(c))
secondary(result) = -(a x primary(b) - secondary(c))
C/C++ prototype double _Complex __fxcxnsma (double _Complex c, double _Complex b, double a);
Fortran description FXCXNSMA(C,B,A)
where C is of type COMPLEX(8)
where B is of type COMPLEX(8)
where A is of type REAL(8)
result is of type COMPLEX(8)

Select functions

Table 17 lists and explains the select functions that are available.

Table 17. Select functions
Function Parallel select: __fpsel
Purpose The value of the primary element of a is compared to zero. If its value is equal to or greater than zero, the primary element of c is stored in the primary element of the return value. Otherwise, the primary element of b is stored in the primary element of the return value. The value of the secondary element of a is compared to zero. If its value is equal to or greater than zero, the secondary element of c is stored in the secondary element of the return value. Otherwise, the secondary element of b is stored in the secondary element of the return value.
Formula
primary(result) = if primary(a)  >= 0 then primary(c); else primary(b)
secondary(result) = if secondary(a) >= 0 then primary(c); else secondary(b)
C/C++ prototype double _Complex __fpsel (double _Complex a, double _Complex b, double _Complex c);
Fortran description FPSEL(A,B,C)
where A is of type COMPLEX(8)  
where B is of type COMPLEX(8)
where C is of type COMPLEX(8)
result is of type COMPLEX(8)