T-SIMD v31.1.0
A C++ template SIMD library
Loading...
Searching...
No Matches
Arithmetic

Description

Arithmetic functions on Vec's, such as addition, multiplication, etc.

See also
Masked Arithmetic

Functions

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::absDiff (const Vec< T, SIMD_WIDTH > &v1, const Vec< T, SIMD_WIDTH > &v2)
 Computes the absolute difference of the elements of two Vec's.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::add (const Vec< T, SIMD_WIDTH > &a, const Vec< T, SIMD_WIDTH > &b)
 Adds the elements of two Vec's.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::adds (const Vec< T, SIMD_WIDTH > &a, const Vec< T, SIMD_WIDTH > &b)
 Adds the elements of two Vec's using saturated arithmetic.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::avg (const Vec< T, SIMD_WIDTH > &a, const Vec< T, SIMD_WIDTH > &b)
 Computes the average of the elements of two Vec's, rounded up.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::avgrd (const Vec< T, SIMD_WIDTH > &a, const Vec< T, SIMD_WIDTH > &b)
 Computes the average of the elements of two Vecs, rounding down.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::avgru (const Vec< T, SIMD_WIDTH > &a, const Vec< T, SIMD_WIDTH > &b)
 Computes the average of the elements of two Vec's, rounded up.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::div (const Vec< T, SIMD_WIDTH > &a, const Vec< T, SIMD_WIDTH > &b)
 Divides the elements of two Vec's.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::div2r0 (const Vec< T, SIMD_WIDTH > &a)
 Divides all elements of a Vec by 2 and rounds the result to 0.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::div2rd (const Vec< T, SIMD_WIDTH > &a)
 Divides all elements of a Vec by 2 and rounds down the result.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::mul (const Vec< T, SIMD_WIDTH > &a, const Vec< T, SIMD_WIDTH > &b)
 Multiplies the elements of two Vec's.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::sign (const Vec< T, SIMD_WIDTH > &a, const Vec< T, SIMD_WIDTH > &b)
 Negates the elements of a Vec of floating-point numbers where the corresponding element of a second Vec of floating-point numbers is negative.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::sub (const Vec< T, SIMD_WIDTH > &a, const Vec< T, SIMD_WIDTH > &b)
 Subtracts the elements of two Vec's.
 
template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::subs (const Vec< T, SIMD_WIDTH > &a, const Vec< T, SIMD_WIDTH > &b)
 Subtracts the elements of two Vec's using saturated arithmetic.
 

Function Documentation

◆ absDiff()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::absDiff ( const Vec< T, SIMD_WIDTH > & v1,
const Vec< T, SIMD_WIDTH > & v2 )
inlinestatic

Computes the absolute difference of the elements of two Vec's.

Parameters
v1first Vec
v2second Vec
Returns
Vec containing the absolute difference of the elements of the two input Vec's

◆ add()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::add ( const Vec< T, SIMD_WIDTH > & a,
const Vec< T, SIMD_WIDTH > & b )
inlinestatic

Adds the elements of two Vec's.

Parameters
afirst Vec
bsecond Vec
Returns
Vec containing the sums of the elements of the two input Vec's

◆ adds()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::adds ( const Vec< T, SIMD_WIDTH > & a,
const Vec< T, SIMD_WIDTH > & b )
inlinestatic

Adds the elements of two Vec's using saturated arithmetic.

Note
Does not use saturated arithmetic with floating point types.
Parameters
afirst Vec
bsecond Vec
Returns
Vec containing the saturated sums of the elements of the two input Vec's

◆ avg()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::avg ( const Vec< T, SIMD_WIDTH > & a,
const Vec< T, SIMD_WIDTH > & b )
inlinestatic

Computes the average of the elements of two Vec's, rounded up.

Parameters
afirst Vec
bsecond Vec
Returns
Vec containing the rounded up average of the elements of the two input Vec's

◆ avgrd()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::avgrd ( const Vec< T, SIMD_WIDTH > & a,
const Vec< T, SIMD_WIDTH > & b )
inlinestatic

Computes the average of the elements of two Vecs, rounding down.

Parameters
afirst Vec
bsecond Vec
Returns
Vec containing the rounded down average of the elements of the two input Vec's

◆ avgru()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::avgru ( const Vec< T, SIMD_WIDTH > & a,
const Vec< T, SIMD_WIDTH > & b )
inlinestatic

Computes the average of the elements of two Vec's, rounded up.

Equivalent to avg(const Vec<T, SIMD_WIDTH> &, const Vec<T, SIMD_WIDTH> &).

Parameters
afirst Vec
bsecond Vec
Returns
Vec containing the rounded up average of the elements of the two input Vec's

◆ div()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::div ( const Vec< T, SIMD_WIDTH > & a,
const Vec< T, SIMD_WIDTH > & b )
inlinestatic

Divides the elements of two Vec's.

Note
This function is only available for floating point types.
Parameters
afirst Vec
bsecond Vec
Returns
Vec containing the quotients of the elements of the two input Vec's

◆ div2r0()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::div2r0 ( const Vec< T, SIMD_WIDTH > & a)
inlinestatic

Divides all elements of a Vec by 2 and rounds the result to 0.

Only rounds the result to 0 for integer types. For floating point types the result is not rounded.

Parameters
ainput Vec
Returns
result of the division
See also
div2rd()

◆ div2rd()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::div2rd ( const Vec< T, SIMD_WIDTH > & a)
inlinestatic

Divides all elements of a Vec by 2 and rounds down the result.

Only rounds down the result for integer types. For floating point types the result is not rounded.

Parameters
ainput Vec
Returns
result of the division
See also
div2r0()

◆ mul()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::mul ( const Vec< T, SIMD_WIDTH > & a,
const Vec< T, SIMD_WIDTH > & b )
inlinestatic

Multiplies the elements of two Vec's.

Note
This function is only available for floating point types.
Parameters
afirst Vec
bsecond Vec
Returns
Vec containing the products of the elements of the two input Vec's

◆ sign()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::sign ( const Vec< T, SIMD_WIDTH > & a,
const Vec< T, SIMD_WIDTH > & b )
inlinestatic

Negates the elements of a Vec of floating-point numbers where the corresponding element of a second Vec of floating-point numbers is negative.

Note
Contrary to IEEE 754, this function considers -0.0 to be negative.
Parameters
aVec of floating-point numbers to be negated
bVec of floating-point numbers that determines which elements of a are negated
Returns
resulting Vec of floating-point numbers

◆ sub()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::sub ( const Vec< T, SIMD_WIDTH > & a,
const Vec< T, SIMD_WIDTH > & b )
inlinestatic

Subtracts the elements of two Vec's.

Parameters
afirst Vec
bsecond Vec
Returns
Vec containing the differences of the elements of the two input Vec's

◆ subs()

template<typename T , size_t SIMD_WIDTH>
static Vec< T, SIMD_WIDTH > simd::subs ( const Vec< T, SIMD_WIDTH > & a,
const Vec< T, SIMD_WIDTH > & b )
inlinestatic

Subtracts the elements of two Vec's using saturated arithmetic.

Note
Does not use saturated arithmetic with floating point types.
Parameters
afirst Vec
bsecond Vec
Returns
Vec containing the saturated differences of the elements of the two input Vec's