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

float_v sqrt (const float_v &v)
 Returns the square root of v.
float_v rsqrt (const float_v &v)
 Returns the reciprocal square root of v.
float_v reciprocal (const float_v &v)
 Returns the reciprocal of v.
float_v abs (const float_v &v)
 Returns the absolute value of v.
float_v round (const float_v &v)
 Returns the closest integer to v; 0.5 is rounded to even.
float_v log (const float_v &v)
 Returns the natural logarithm of v.
float_v log2 (const float_v &v)
 Returns the base-2 logarithm of v.
float_v log10 (const float_v &v)
 Returns the base-10 logarithm of v.
float_v exp (const float_v &v)
 Returns the exponential of v.
float_v sin (const float_v &v)
 Returns the sine of v.
float_v cos (const float_v &v)
 Returns the cosine of v.
void sincos (const float_v &v, float_v *sin, float_v *cos)
 Calculates the sine and cosine of v.
float_v asin (const float_v &v)
 Returns the arcsine of v.
float_v atan (const float_v &v)
 Returns the arctangent of v.
float_v atan2 (const float_v &x, const float_v &y)
 Returns the arctangent of x / y.
float_v min (const float_v &x, const float_v &y)
 Returns the minimum of x and y.
float_v max (const float_v &x, const float_v &y)
 Returns the maximum of x and y.
float_v frexp (const float_v &x, int_v *e)
 Convert floating-point number to fractional and integral components.
float_v ldexp (float_v x, int_v e)
 Multiply floating-point number by integral power of 2.
float_m isfinite (const float_v &x)
 Returns a mask that tells whether the values in the vector are finite (i.e. not NaN or +/-inf).
float_m isnan (const float_v &x)
 Returns a mask that tells whether the values in the vector are NaN.
double_v sqrt (const double_v &v)
 Returns the square root of v.
double_v rsqrt (const double_v &v)
 Returns the reciprocal square root of v.
double_v reciprocal (const double_v &v)
 Returns the reciprocal of v.
double_v abs (const double_v &v)
 Returns the absolute value of v.
double_v round (const double_v &v)
 Returns the closest integer to v; 0.5 is rounded to even.
double_v log (const double_v &v)
 Returns the natural logarithm of v.
double_v log2 (const double_v &v)
 Returns the base-2 logarithm of v.
double_v log10 (const double_v &v)
 Returns the base-10 logarithm of v.
double_v exp (const double_v &v)
 Returns the exponential of v.
double_v sin (const double_v &v)
 Returns the sine of v.
double_v cos (const double_v &v)
 Returns the cosine of v.
void sincos (const double_v &v, double_v *sin, double_v *cos)
 Calculates the sine and cosine of v.
double_v asin (const double_v &v)
 Returns the arcsine of v.
double_v atan (const double_v &v)
 Returns the arctangent of v.
double_v atan2 (const double_v &x, const double_v &y)
 Returns the arctangent of x / y.
double_v min (const double_v &x, const double_v &y)
 Returns the minimum of x and y.
double_v max (const double_v &x, const double_v &y)
 Returns the maximum of x and y.
double_v frexp (const double_v &x, int_v *e)
 Convert floating-point number to fractional and integral components.
double_v ldexp (double_v x, int_v e)
 Multiply floating-point number by integral power of 2.
double_m isfinite (const double_v &x)
 Returns a mask that tells whether the values in the vector are finite (i.e. not NaN or +/-inf).
double_m isnan (const double_v &x)
 Returns a mask that tells whether the values in the vector are NaN.
sfloat_v sqrt (const sfloat_v &v)
 Returns the square root of v.
sfloat_v rsqrt (const sfloat_v &v)
 Returns the reciprocal square root of v.
sfloat_v reciprocal (const sfloat_v &v)
 Returns the reciprocal of v.
sfloat_v abs (const sfloat_v &v)
 Returns the absolute value of v.
sfloat_v round (const sfloat_v &v)
 Returns the closest integer to v; 0.5 is rounded to even.
sfloat_v log (const sfloat_v &v)
 Returns the natural logarithm of v.
sfloat_v log2 (const sfloat_v &v)
 Returns the base-2 logarithm of v.
sfloat_v log10 (const sfloat_v &v)
 Returns the base-10 logarithm of v.
sfloat_v exp (const sfloat_v &v)
 Returns the exponential of v.
sfloat_v sin (const sfloat_v &v)
 Returns the sine of v.
sfloat_v cos (const sfloat_v &v)
 Returns the cosine of v.
void sincos (const sfloat_v &v, sfloat_v *sin, sfloat_v *cos)
 Calculates the sine and cosine of v.
sfloat_v asin (const sfloat_v &v)
 Returns the arcsine of v.
sfloat_v atan (const sfloat_v &v)
 Returns the arctangent of v.
sfloat_v atan2 (const sfloat_v &x, const sfloat_v &y)
 Returns the arctangent of x / y.
sfloat_v min (const sfloat_v &x, const sfloat_v &y)
 Returns the minimum of x and y.
sfloat_v max (const sfloat_v &x, const sfloat_v &y)
 Returns the maximum of x and y.
sfloat_v frexp (const sfloat_v &x, short_v *e)
 Convert floating-point number to fractional and integral components.
sfloat_v ldexp (sfloat_v x, short_v e)
 Multiply floating-point number by integral power of 2.
sfloat_m isfinite (const sfloat_v &x)
 Returns a mask that tells whether the values in the vector are finite (i.e. not NaN or +/-inf).
sfloat_m isnan (const sfloat_v &x)
 Returns a mask that tells whether the values in the vector are NaN.

Function Documentation

float_v Vc::log ( const float_v &  v)

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).
float_v Vc::log2 ( const float_v &  v)

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).
float_v Vc::log10 ( const float_v &  v)

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).
float_v Vc::sin ( const float_v &  v)

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.
float_v Vc::cos ( const float_v &  v)

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.
void Vc::sincos ( const float_v &  v,
float_v *  sin,
float_v *  cos 
)

Calculates the sine and cosine of v.

The values are returned in the sin and cos parameters.

Parameters
[in]vinput value to sin and cos
[out]sinNeeds to be a non-null pointer which will be set to the sine of v.
[out]cosNeeds to be a non-null pointer which will be set to 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.
float_v Vc::asin ( const float_v &  v)

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).
float_v Vc::atan ( const float_v &  v)

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].
float_v Vc::frexp ( const float_v &  x,
int_v *  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.
float_v Vc::ldexp ( float_v  x,
int_v  e 
)

Multiply floating-point number by integral power of 2.

Parameters
xvalue to be multiplied by 2 ^ e
eexponent
Returns
x * 2 ^ e
double_v Vc::log ( const double_v &  v)

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).
double_v Vc::log2 ( const double_v &  v)

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).
double_v Vc::log10 ( const double_v &  v)

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).
double_v Vc::sin ( const double_v &  v)

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.
double_v Vc::cos ( const double_v &  v)

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.
void Vc::sincos ( const double_v &  v,
double_v *  sin,
double_v *  cos 
)

Calculates the sine and cosine of v.

The values are returned in the sin and cos parameters.

Parameters
[in]vinput value to sin and cos
[out]sinNeeds to be a non-null pointer which will be set to the sine of v.
[out]cosNeeds to be a non-null pointer which will be set to 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.
double_v Vc::asin ( const double_v &  v)

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).
double_v Vc::atan ( const double_v &  v)

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].
double_v frexp ( const double_v &  x,
int_v *  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.
Note
Often int_v::Size == double_v::Size * 2, then only every second value in *e is defined.
double_v ldexp ( double_v  x,
int_v  e 
)

Multiply floating-point number by integral power of 2.

Parameters
xvalue to be multiplied by 2 ^ e
eexponent
Returns
x * 2 ^ e
Note
Often int_v::Size == double_v::Size * 2, then only every second value in *e is defined.
sfloat_v Vc::log ( const sfloat_v &  v)

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).
sfloat_v Vc::log2 ( const sfloat_v &  v)

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).
sfloat_v Vc::log10 ( const sfloat_v &  v)

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).
sfloat_v Vc::sin ( const sfloat_v &  v)

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.
sfloat_v Vc::cos ( const sfloat_v &  v)

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.
void Vc::sincos ( const sfloat_v &  v,
sfloat_v *  sin,
sfloat_v *  cos 
)

Calculates the sine and cosine of v.

The values are returned in the sin and cos parameters.

Parameters
[in]vinput value to sin and cos
[out]sinNeeds to be a non-null pointer which will be set to the sine of v.
[out]cosNeeds to be a non-null pointer which will be set to 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.
sfloat_v Vc::asin ( const sfloat_v &  v)

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).
sfloat_v Vc::atan ( const sfloat_v &  v)

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].
sfloat_v Vc::frexp ( const sfloat_v &  x,
short_v *  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.
sfloat_v Vc::ldexp ( sfloat_v  x,
short_v  e 
)

Multiply floating-point number by integral power of 2.

Parameters
xvalue to be multiplied by 2 ^ e
eexponent
Returns
x * 2 ^ e