Vc  1.0.0-dev
SIMD Vector Classes for C++
Math

Detailed Description

Functions that implement math functions. Take care that some of the implementations will return results with less precision than what the FPU calculates.

Functions

Vc::Vector< T > sqrt (const Vc::Vector< T > &v)
 Returns the square root of v.
 
Vc::Vector< T > rsqrt (const Vc::Vector< T > &v)
 Returns the reciprocal square root of v.
 
Vc::Vector< T > reciprocal (const Vc::Vector< T > &v)
 Returns the reciprocal of v.
 
Vc::Vector< T > abs (const Vc::Vector< T > &v)
 Returns the absolute value of v.
 
Vc::Vector< T > round (const Vc::Vector< T > &v)
 Returns the closest integer to v; 0.5 is rounded to even.
 
Vc::Vector< T > log (const Vc::Vector< T > &v)
 
Vc::Vector< T > log2 (const Vc::Vector< T > &v)
 
Vc::Vector< T > log10 (const Vc::Vector< T > &v)
 
Vc::Vector< T > exp (const Vc::Vector< T > &v)
 
Vc::Vector< T > sin (const Vc::Vector< T > &v)
 
Vc::Vector< T > cos (const Vc::Vector< T > &v)
 
Vc::Vector< T > asin (const Vc::Vector< T > &v)
 
Vc::Vector< T > atan (const Vc::Vector< T > &v)
 
Vc::Vector< T > atan2 (const Vc::Vector< T > &y, const Vc::Vector< T > &x)
 Calculates the angle given the lengths of the opposite and adjacent legs in a right triangle. More...
 
Vc::Vector< T > min (const Vc::Vector< T > &x, const Vc::Vector< T > &y)
 
Vc::Vector< T > max (const Vc::Vector< T > &x, const Vc::Vector< T > &y)
 
Vc::Vector< T > frexp (const Vc::Vector< T > &x, Vc::SimdArray< int, size()> *e)
 Convert floating-point number to fractional and integral components. More...
 
Vc::Vector< T > ldexp (Vc::Vector< T > x, Vc::SimdArray< int, size()> e)
 Multiply floating-point number by integral power of 2. More...
 
Vc::Mask< T > isfinite (const Vc::Vector< T > &x)
 
Vc::Mask< T > isnan (const Vc::Vector< T > &x)
 
Vc::Vector< T > fma (Vc::Vector< T > a, Vc::Vector< T > b, Vc::Vector< T > c)
 Multiplies a with b and then adds c, without rounding between the multiplication and the addition. More...
 

Function Documentation

Vc::Vector<T> Vc::log ( const Vc::Vector< T > &  v)
Parameters
vThe values to apply the logarithm on.
Returns
the natural logarithm of v.
Note
The single-precision implementation has an error of max. 1 ulp (mean 0.020 ulp) in the range ]0, 1000] (including denormals).
The double-precision implementation has an error of max. 1 ulp (mean 0.020 ulp) in the range ]0, 1000] (including denormals).
Vc::Vector<T> Vc::log2 ( const Vc::Vector< T > &  v)
Parameters
vThe values to apply the logarithm on.
Returns
the base-2 logarithm of v.
Note
The single-precision implementation has an error of max. 1 ulp (mean 0.016 ulp) in the range ]0, 1000] (including denormals).
The double-precision implementation has an error of max. 1 ulp (mean 0.016 ulp) in the range ]0, 1000] (including denormals).
Vc::Vector<T> Vc::log10 ( const Vc::Vector< T > &  v)
Parameters
vThe values to apply the logarithm on.
Returns
the base-10 logarithm of v.
Note
The single-precision implementation has an error of max. 2 ulp (mean 0.31 ulp) in the range ]0, 1000] (including denormals).
The double-precision implementation has an error of max. 2 ulp (mean 0.26 ulp) in the range ]0, 1000] (including denormals).
Vc::Vector<T> Vc::exp ( const Vc::Vector< T > &  v)
Parameters
vThe values to apply the exponential function on.
Returns
the exponential of v.
Vc::Vector<T> Vc::sin ( const Vc::Vector< T > &  v)
Parameters
vThe values to apply the sine function on.
Returns
the sine of v.
Note
The single-precision implementation has an error of max. 2 ulp (mean 0.17 ulp) in the range [-8192, 8192].
The double-precision implementation has an error of max. 8e6 ulp (mean 1040 ulp) in the range [-8192, 8192].
Vc versions before 0.7 had much larger errors.
Vc::Vector<T> Vc::cos ( const Vc::Vector< T > &  v)
Parameters
vThe values to apply the cosine function on.
Returns
the cosine of v.
Note
The single-precision implementation has an error of max. 2 ulp (mean 0.18 ulp) in the range [-8192, 8192].
The double-precision implementation has an error of max. 8e6 ulp (mean 1160 ulp) in the range [-8192, 8192].
Vc versions before 0.7 had much larger errors.
Vc::Vector<T> Vc::asin ( const Vc::Vector< T > &  v)
Parameters
vThe values to apply the arcsine function on.
Returns
the arcsine of v.
Note
The single-precision implementation has an error of max. 2 ulp (mean 0.3 ulp).
The double-precision implementation has an error of max. 36 ulp (mean 0.4 ulp).
Vc::Vector<T> Vc::atan ( const Vc::Vector< T > &  v)
Parameters
vThe values to apply the arctangent function on.
Returns
the arctangent of v.
Note
The single-precision implementation has an error of max. 3 ulp (mean 0.4 ulp) in the range [-8192, 8192].
The double-precision implementation has an error of max. 2 ulp (mean 0.1 ulp) in the range [-8192, 8192].
Vc::Vector<T> Vc::atan2 ( const Vc::Vector< T > &  y,
const Vc::Vector< T > &  x 
)

Calculates the angle given the lengths of the opposite and adjacent legs in a right triangle.

Parameters
yThe opposite leg.
xThe adjacent leg.
Returns
the arctangent of y / x.
Vc::Vector<T> Vc::min ( const Vc::Vector< T > &  x,
const Vc::Vector< T > &  y 
)
Parameters
x\(\mathcal{W}_\mathtt{T}\) values to compare component-wise against y.
y\(\mathcal{W}_\mathtt{T}\) values to compare component-wise against x.
Returns
the minimum of x and y.
Vc::Vector<T> Vc::max ( const Vc::Vector< T > &  x,
const Vc::Vector< T > &  y 
)
Parameters
x\(\mathcal{W}_\mathtt{T}\) values to compare component-wise against y.
y\(\mathcal{W}_\mathtt{T}\) values to compare component-wise against x.
Returns
the maximum of x and y.
Vc::Vector<T> Vc::frexp ( const Vc::Vector< T > &  x,
Vc::SimdArray< int, size()> *  e 
)

Convert floating-point number to fractional and integral components.

Parameters
xvalue to be split into normalized fraction and exponent
ethe exponent to base 2 of x
Returns
the normalized fraction. If x is non-zero, the return value is x times a power of two, and its absolute value is always in the range [0.5,1).
If x is zero, then the normalized fraction is zero and zero is stored in e.
If x is a NaN, a NaN is returned, and the value of *e is unspecified.
If x is positive infinity (negative infinity), positive infinity (nega‐ tive infinity) is returned, and the value of *e is unspecified.
Vc::Vector<T> Vc::ldexp ( Vc::Vector< T >  x,
Vc::SimdArray< int, size()>  e 
)

Multiply floating-point number by integral power of 2.

Parameters
xvalue to be multiplied by 2 ^ e
eexponent
Returns
x * 2 ^ e
Vc::Mask<T> Vc::isfinite ( const Vc::Vector< T > &  x)
Parameters
xThe \(\mathcal{W}_\mathtt{T}\) values to check for finite values.
Returns
a mask that tells whether the values in the vector are finite (i.e. not NaN or +/-inf).
Vc::Mask<T> Vc::isnan ( const Vc::Vector< T > &  x)
Parameters
xThe \(\mathcal{W}_\mathtt{T}\) values to check for NaN values.
Returns
a mask that tells whether the values in the vector are NaN.
Vc::Vector<T> Vc::fma ( Vc::Vector< T >  a,
Vc::Vector< T >  b,
Vc::Vector< T >  c 
)

Multiplies a with b and then adds c, without rounding between the multiplication and the addition.

Parameters
aFirst multiplication factor.
bSecond multiplication factor.
cSummand that will be added after multiplication.
Returns
The \(\mathcal{W}_\mathtt{T}\) values of a * b + c with higher precision due to no rounding between multiplication and addition.
Note
This operation may have explicit hardware support, in which case it is normally faster to use the FMA instead of separate multiply and add instructions.
If the target hardware does not have FMA support this function will be considerably slower than a normal a * b + c. This is due to the increased precision fusedMultiplyAdd provides.
The compiler normally detects opportunities for using the hardware FMA instructions from normal multiplication and addition/subtraction operators. Use this function only if you require the additional precision.