T-SIMD v31.1.0
A C++ template SIMD library
Loading...
Searching...
No Matches
simd::Mask< T, SIMD_WIDTH > Class Template Reference

SIMD mask class consisting of as many bits as the corresponding Vec has elements. More...

Detailed Description

template<typename T, size_t SIMD_WIDTH>
class simd::Mask< T, SIMD_WIDTH >

SIMD mask class consisting of as many bits as the corresponding Vec has elements.

Template Parameters
Ttype of the elements of the corresponding Vec
SIMD_WIDTHnumber of bytes in the corresponding Vec

Public Member Functions

 Mask (const uint64_t x)
 Constructs a Mask from an integer.
 
 Mask (const Vec< T, SIMD_WIDTH > &x)
 Constructs a Mask from a Vec.
 
 operator uint64_t () const
 Converts the Mask to an integer.
 
 operator Vec< T, SIMD_WIDTH > () const
 Converts the Mask to a Vec.
 
bool operator== (const Mask< T, SIMD_WIDTH > &other) const
 Compares the Mask with another Mask.
 
bool operator[] (const size_t i) const
 Returns the Mask bit at the given index.
 

Constructor & Destructor Documentation

◆ Mask() [1/2]

template<typename T , size_t SIMD_WIDTH>
simd::Mask< T, SIMD_WIDTH >::Mask ( const Vec< T, SIMD_WIDTH > & x)
inlineexplicit

Constructs a Mask from a Vec.

The Mask bits are set to 1 if the corresponding Vec element has its most significant bit set, otherwise the Mask bit is set to 0.

◆ Mask() [2/2]

template<typename T , size_t SIMD_WIDTH>
simd::Mask< T, SIMD_WIDTH >::Mask ( const uint64_t x)
inlineexplicit

Constructs a Mask from an integer.

The lowest bits of the integer are used to set the Mask bits.

Member Function Documentation

◆ operator uint64_t()

template<typename T , size_t SIMD_WIDTH>
simd::Mask< T, SIMD_WIDTH >::operator uint64_t ( ) const
inlineexplicit

Converts the Mask to an integer.

The lowest bits of the integer are set to the Mask bits.

Returns
converted integer from the Mask

◆ operator Vec< T, SIMD_WIDTH >()

template<typename T , size_t SIMD_WIDTH>
simd::Mask< T, SIMD_WIDTH >::operator Vec< T, SIMD_WIDTH > ( ) const
inlineexplicit

Converts the Mask to a Vec.

The bits of the Vec elements are set to all 1s if the corresponding Mask bit is set, otherwise the Vec element bits are set to 0.

Returns
converted Vec from the Mask

◆ operator==()

template<typename T , size_t SIMD_WIDTH>
bool simd::Mask< T, SIMD_WIDTH >::operator== ( const Mask< T, SIMD_WIDTH > & other) const
inline

Compares the Mask with another Mask.

Parameters
otherMask to compare with
Returns
whether the Mask is equal to the other Mask

◆ operator[]()

template<typename T , size_t SIMD_WIDTH>
bool simd::Mask< T, SIMD_WIDTH >::operator[] ( const size_t i) const
inline

Returns the Mask bit at the given index.

Parameters
iindex of the Mask bit
Returns
whether the Mask bit at the given index is set