avx::Short256¶
-
class Short256¶
Class providing vectorized version of
short
. Can hold 16 individualshort
values. Provides arithmetic and bitwise operators. Provides comparison operators == !=.Public Types
-
using storedType = short¶
Type that is stored inside vector.
Public Functions
-
inline Short256() noexcept¶
Default constructor. Sets zero to whole vector.
-
inline Short256(const Short256 &init) noexcept¶
Initializes vector with value from other vector.
- Parameters:
init – Object which value will be copied.
-
inline Short256(const __m256i &init) noexcept¶
Initializes vector but using
__m256i
type.- Parameters:
init – Raw value to be set.
-
inline Short256(const std::array<short, 16> &init) noexcept¶
Initialize vector with values read from an array.
- Parameters:
init – Array from which values will be copied.
- inline explicit Short256 (const short *addr) N_THROW_REL
Initialize vector with values using pointer.
- Parameters:
addr – A valid address containing at least 16
short
numbers.- Throws:
If – in debug mode and
addr
isnullptr
throwsstd::invalid_argument
. Otherwise no exception will be thrown.
-
inline explicit Short256(const short b) noexcept¶
Initializes all vector fields with single value.
- Parameters:
b – A literal value to be set.
-
inline Short256(std::initializer_list<short> init)¶
- inline void load (const short *pSrc) N_THROW_REL
Loads data from memory into vector (memory should be of size of at least 32 bytes). Memory doesn’t need to be aligned to any specific boundary. If
sP
isnullptr
this method has no effect.- Parameters:
pSrc – Pointer to memory from which to load data.
- Throws:
std::invalid_argument – If in Debug mode and
pSrc
isnullptr
. In Release builds this method never throws (fornullptr
method will have no effect).
-
inline void save(std::array<short, 16> &dest) const noexcept¶
Saves data to destination in memory.
- Parameters:
dest – Reference to the list to which vector will be saved. Array doesn’t need to be aligned to any specific boundary.
- inline void save (short *pDest) const N_THROW_REL
Saves data to destination in memory. The memory doesn’t have to be aligned to any specific boundary.
See https://en.cppreference.com/w/cpp/memory/c/aligned_alloc for more details.
- Parameters:
pDest – A valid pointer to a memory of at least 32 bytes (16x
short
).- Throws:
std::invalid_argument – If in Debug mode and
pDest
isnullptr
. In Release builds this method never throws (fornullptr
method will have no effect).
- inline void saveAligned (short *pDest) const N_THROW_REL
Saves data to destination in memory. The memory must be aligned at 32-byte boundary.
See https://en.cppreference.com/w/cpp/memory/c/aligned_alloc for more details.
- Parameters:
pDest – A valid pointer to a memory of at least 32 bytes (16x
short
).- Throws:
std::invalid_argument – If in Debug mode and
pDest
isnullptr
. In Release builds this method never throws (fornullptr
method will have no effect).
-
inline __m256i get() const noexcept¶
Get the internal vector value.
- Returns:
The value of
__m256i
vector.
-
inline void set(const __m256i value) noexcept¶
Set the internal vector value.
- Parameters:
value – New value to be set.
-
inline short operator[](const unsigned int &index) const¶
Indexing operator.
- Parameters:
index – Position of desired element between 0 and 15.
- Throws:
std::out_of_range – If index is not within the correct range.
- Returns:
Value of underlying element.
-
inline bool operator==(const Short256 &bV) const noexcept¶
Compares with second vector for equality.
- Parameters:
bV – Object to compare.
- Returns:
true
if all elements are equal orfalse
if not.
-
inline bool operator==(const short b) const noexcept¶
Compares with value for equality.
- Parameters:
b – Value to compare.
- Returns:
true
if all elements are equal to passed valuefalse
if not.
-
inline bool operator!=(const Short256 &bV) const noexcept¶
Compares with second vector for inequality.
- Parameters:
bV – Object to compare.
- Returns:
true
if any alement is not equal to corresponding element inbV
otherwisefalse
.
-
inline bool operator!=(const short b) const noexcept¶
Compares with value for inequality.
- Parameters:
b – Value
- Returns:
true
if any alement is not equal to corresponding element inbV
otherwisefalse
.
-
inline Short256 operator/(const Short256 &bV) const noexcept¶
Performs an integer division.
NOTE: Value is first casted to
int
and then tofloat
and inverse to return integer result which has not been yet tested for performance.- Parameters:
bV – Divisors vector.
- Returns:
Result of integer division with truncation.
-
inline Short256 operator/(const short &b) const noexcept¶
Performs an integer division.
NOTE: Value is first casted to
int
and then tofloat
and inverse to return integer result which has not been yet tested for performance.- Parameters:
bV – Divisor value.
- Returns:
Result of integer division with truncation.
-
inline Short256 operator%(const Short256 &bV) const noexcept¶
Performs a modulo operation.
NOTE: Analogously as in
/
and/=
operators values are casted before performing a division.- Parameters:
bV – Divisors vector.
- Returns:
Modulo result.
-
inline Short256 operator%(const short &b) noexcept¶
Performs a modulo operation.
NOTE: Analogously as in
/
and/=
operators values are casted before performing a division.- Parameters:
bV – Divisor.
- Returns:
Modulo result.
-
inline Short256 operator<<(const Short256 &bV) const noexcept¶
Performs left bitwise shift of corresponding values.
- Parameters:
bV – Second vector that specifies number of bits to shift (for each 16-bit value).
- Returns:
New value of
v
shifted by number of bits specfied inbV
.
-
inline std::string str() const noexcept¶
Public Static Attributes
-
static const int size = 16¶
Number of individual values stored by object. This value can be used to iterate over elements.
-
using storedType = short¶