Vc  1.3.2-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...
 
template<typename T , typename Abi , typename = enable_if<std::is_floating_point<T>::value>>
Vector< T, Abi > copysign (Vector< T, Abi > magnitude, Vector< T, Abi > sign)
 Copies the sign(s) of sign to the value(s) in magnitude and returns the resulting vector. More...
 
template<typename T , typename Abi , typename = enable_if<std::is_floating_point<T>::value>>
Vector< T, Abi > exponent (Vector< T, Abi > x)
 Extracts the exponent of each floating-point vector component. More...
 
template<typename T , typename Abi >
Vector< T, Abi >::MaskType isnegative (Vector< T, Abi > x)
 Returns for each vector component whether it stores a negative value. 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.
Vector<T, Abi> Vc::copysign ( Vector< T, Abi >  magnitude,
Vector< T, Abi >  sign 
)
inline

Copies the sign(s) of sign to the value(s) in magnitude and returns the resulting vector.

Parameters
magnitudeThis vector's magnitude will be used in the return vector.
signThis vector's sign bit will be used in the return vector.
Returns
a value where the sign of the value equals the sign of sign. I.e. sign(copysign(v, r)) == sign(r).

Referenced by Vector< T, Abi >::Vector().

Vector<T, Abi> Vc::exponent ( Vector< T, Abi >  x)
inline

Extracts the exponent of each floating-point vector component.

Parameters
xThe vector of values to check for the sign.
Returns
the exponent to base 2.

This function provides efficient access to the exponent of the floating point number. The returned value is a fast approximation to the logarithm of base 2. The absolute error of that approximation is between [0, 1[.

Examples:

 value | exponent | log2
=======|==========|=======
   1.0 |        0 | 0
   2.0 |        1 | 1
   3.0 |        1 | 1.585
   3.9 |        1 | 1.963
   4.0 |        2 | 2
   4.1 |        2 | 2.036
Warning
This function assumes a positive value (non-zero). If the value is negative the sign bit will modify the returned value. An input value of zero will return the bias of the floating-point representation. If you compile with Vc runtime checks, the function will assert values greater than or equal to zero.

You may use abs to apply this function to negative values:

Referenced by Vector< T, Abi >::Vector().

Vector<T, Abi>::MaskType Vc::isnegative ( Vector< T, Abi >  x)
inline

Returns for each vector component whether it stores a negative value.

Parameters
xThe vector of values to check for the sign.
Returns
a mask which is true only in those components that are negative in x.

Definition at line 102 of file vector.h.