Vc  1.4.2
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

template<typename T , typename Abi >
Vector< T, detail::not_fixed_size_abi< Abi > > sin (const Vector< T, Abi > &x)
 
template<typename T , typename Abi >
Vector< T, detail::not_fixed_size_abi< Abi > > cos (const Vector< T, Abi > &x)
 
template<typename T , typename Abi >
Vector< T, detail::not_fixed_size_abi< Abi > > asin (const Vector< T, Abi > &x)
 
template<typename T , typename Abi >
Vector< T, detail::not_fixed_size_abi< Abi > > atan (const Vector< T, Abi > &x)
 
template<typename T , typename Abi >
Vector< T, detail::not_fixed_size_abi< Abi > > atan2 (const Vector< T, Abi > &y, const Vector< T, Abi > &x)
 
template<typename T , typename Abi >
void sincos (const Vector< T, Abi > &x, Vector< T, detail::not_fixed_size_abi< Abi >> *sin, Vector< T, Abi > *cos)
 
template<typename T , typename Abi , typename = enable_if<std::is_floating_point<T>::value && !detail::is_fixed_size_abi<Abi>::value>>
Vector< T, Abi > copysign (Vector< T, Abi > magnitude, Vector< T, Abi > sign)
 
template<typename T , typename Abi , typename = enable_if<std::is_floating_point<T>::value && !detail::is_fixed_size_abi<Abi>::value>>
Vector< T, Abi > exponent (Vector< T, Abi > x)
 
template<typename T , typename Abi >
Vector< T, detail::not_fixed_size_abi< Abi > >::MaskType isnegative (Vector< T, Abi > x)
 

Function Documentation

◆ sin()

Vector<T, detail::not_fixed_size_abi<Abi> > Vc::sin ( const Vector< T, Abi > &  x)
inline

Returns the sine of all input values in x.

Parameters
xThe values to apply the sine function on.
Returns
the sine of x.
Note
The single-precision implementation has a precision of max. 2 ulp (mean 0.17 ulp) in the range [-8192, 8192]. (testSin< float_v> with a maximal distance of 2 to the reference (mean: 0.310741))
The double-precision implementation has a precision of max. 3 ulp (mean 1040 ulp) in the range [-8192, 8192]. (testSin<double_v> with a maximal distance of 1 to the reference (mean: 0.170621))
The precision and execution latency depends on:
  • Abi (e.g. Scalar uses the <cmath> implementation
  • whether Vc_HAVE_LIBMVEC is defined
  • for the <cmath> fallback, the implementations differ (e.g. MacOS vs. Linux vs. Windows; fpmath=sse vs. fpmath=387)
Vc versions before 1.4 had different precision.

Definition at line 134 of file trigonometric.h.

Referenced by Vc::sincos().

◆ cos()

Vector<T, detail::not_fixed_size_abi<Abi> > Vc::cos ( const Vector< T, Abi > &  x)
inline

Returns the cosine of all input values in x.

Parameters
xThe values to apply the cosine function on.
Returns
the cosine of x.
Note
The single-precision implementation has a precision of max. 2 ulp (mean 0.18 ulp) in the range [-8192, 8192].
The double-precision implementation has a precision of max. 3 ulp (mean 1160 ulp) in the range [-8192, 8192].
Vc versions before 1.4 had different precision.

Definition at line 151 of file trigonometric.h.

Referenced by Vc::sincos().

◆ asin()

Vector<T, detail::not_fixed_size_abi<Abi> > Vc::asin ( const Vector< T, Abi > &  x)
inline

Returns the arcsine of all input values in x.

Parameters
xThe values to apply the arcsine function on.
Returns
the arcsine of x.
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).

Definition at line 168 of file trigonometric.h.

◆ atan()

Vector<T, detail::not_fixed_size_abi<Abi> > Vc::atan ( const Vector< T, Abi > &  x)
inline

Returns the arctangent of all input values in x.

Parameters
xThe values to apply the arctangent function on.
Returns
the arctangent of x.
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].

Definition at line 183 of file trigonometric.h.

◆ atan2()

Vector<T, detail::not_fixed_size_abi<Abi> > Vc::atan2 ( const Vector< T, Abi > &  y,
const Vector< T, Abi > &  x 
)
inline

Returns the arctangent of all input values in x and y.

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.

Definition at line 199 of file trigonometric.h.

◆ sincos()

void Vc::sincos ( const Vector< T, Abi > &  x,
Vector< T, detail::not_fixed_size_abi< Abi >> *  sin,
Vector< T, Abi > *  cos 
)
inline
Parameters
xInput value to both sine and cosine.
sinA non-null pointer to a potentially uninitialized object of type Vector. When sincos returns, *sin contains the result of sin(x).
cosA non-null pointer to a potentially uninitialized object of type Vector. When sincos returns, *cos contains the result of cos(x).
See also
sin, cos

Definition at line 217 of file trigonometric.h.

◆ copysign()

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).

◆ exponent()

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:

◆ isnegative()

Vector<T, detail::not_fixed_size_abi<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 106 of file vector.h.

Vc::abs
fixed_size_simd< T, N > abs(const SimdArray< T, N, V, M > &x)
Applies the std:: abs function component-wise and concurrently.
Definition: simdarray.h:1806
Vc::exponent
fixed_size_simd< T, N > exponent(const SimdArray< T, N, V, M > &x)
Applies the std:: exponent function component-wise and concurrently.
Definition: simdarray.h:1814