avx::UInt256

class UInt256

Class providing vectorized version of unsigned int. It can hold 8 individual values. Supports arithmetic and bitwise operators. Provides comparison operators == !=. Class providing vectorized version of unsigned int. It can hold 8 individual values. Supports arithmetic and bitwise operators. Provides comparison operators == !=.

Public Types

using storedType = unsigned int

Type that is stored inside vector.

Public Functions

inline UInt256()

Default constructor. Initializes vector with zeros using _mm256_setzero_si256().

inline UInt256(const unsigned int *pSrc)

Initializes vector by loading data from memory (via _mm256_lddq_si256).

Parameters:

pSrc – Valid memory addres of minimal size of 256-bits (32 bytes).

inline UInt256(const unsigned int init) noexcept

Fills vector with passed value using _mm256_set1_epi32().

Parameters:

init – Value to be set.

inline UInt256(__m256i init) noexcept

Just sets vector value using passed __m256i.

Parameters:

init – Vector value to be set.

inline UInt256(UInt256 &init) noexcept

Set value using reference.

Parameters:

init – Reference to object which value will be copied.

inline UInt256(const UInt256 &init) noexcept

Set value using const reference.

Parameters:

init – Const reference to object which value will be copied.

inline UInt256(std::array<unsigned int, 8> init) noexcept

Sets vector values using array of unsigned integers.

When accessing vector fields using [] order of values will be inversed.

Parameters:

init – Array of unsigned integers which values will be assigned to vector fields.

inline UInt256(std::array<unsigned short, 8> init) noexcept

Sets vector values using array of unsigned shorts. When accessing vector fields using [] order of values will be inversed.

Parameters:

init – Array of unsigned shorts which values will be assigned to vector fields.

inline UInt256(std::array<unsigned char, 8> init) noexcept

Sets vector values using array of unsigned chars. When accessing vector fields using [] order of values will be inversed.

Parameters:

init – Array of unsigned chars which values will be assigned to vector fields.

inline UInt256(std::initializer_list<unsigned int> init) noexcept

Sets vector values using array of unsigned integers. If list is longer than 8 other values will be ignored. If the list contains fewer than 8 elements other vector fields will be set to 0. When accessing vector fields using [] order of values will be inversed.

Parameters:

init – Initlizer list containing unsigned integers which values will be assigned to vector fields.

inline __m256i get() const noexcept

Get underlying __m256i vector.

Returns:

Copy of internal __m256i vector.

inline void set(__m256i val) noexcept

Set underlying __m256i vector value.

Parameters:

val – Vector which value will be copied.

inline void load (const unsigned int *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 is nullptr 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 is nullptr. In Release builds this method never throws (for nullptr method will have no effect).

inline void save(std::array<unsigned int, 8> &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 (unsigned int *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 (8x unsigned int).

Throws:

std::invalid_argument – If in Debug mode and pDest is nullptr. In Release builds this method never throws (for nullptr method will have no effect).

inline void saveAligned (unsigned int *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 (8x unsigned int).

Throws:

std::invalid_argument – If in Debug mode and pDest is nullptr. In Release builds this method never throws (for nullptr method will have no effect).

inline bool operator==(const UInt256 &bV) const
inline bool operator==(const int b) const
inline bool operator!=(const UInt256 &bV) const
inline bool operator!=(const int b) const
inline unsigned int operator[](const unsigned int index) const
inline UInt256 operator+(const UInt256 &b) const noexcept
inline UInt256 operator+(const unsigned int b) const noexcept
inline UInt256 &operator+=(const UInt256 &b) noexcept
inline UInt256 &operator+=(const unsigned int b) noexcept
inline UInt256 operator-(const UInt256 &b) const noexcept
inline UInt256 operator-(const unsigned int b) const noexcept
inline UInt256 &operator-=(const UInt256 &b) noexcept
inline UInt256 &operator-=(const unsigned int b) noexcept
inline UInt256 operator*(const UInt256 &b) const noexcept
inline UInt256 operator*(const unsigned int b) const noexcept
inline UInt256 &operator*=(const UInt256 &b) noexcept
inline UInt256 &operator*=(const unsigned int b) noexcept
inline UInt256 operator/(const UInt256 &b) const noexcept
inline UInt256 operator/(const unsigned int b) const noexcept
inline UInt256 &operator/=(const UInt256 &b) noexcept
inline UInt256 &operator/=(const unsigned int b) noexcept
inline UInt256 operator%(const UInt256 &b) const noexcept
inline UInt256 operator%(const unsigned int b) const noexcept
inline UInt256 &operator%=(const UInt256 &b) noexcept
inline UInt256 &operator%=(const unsigned int b) noexcept
inline UInt256 operator^(const UInt256 &b) const noexcept
inline UInt256 operator^(const unsigned int b) const noexcept
inline UInt256 &operator^=(const UInt256 &b) noexcept
inline UInt256 &operator^=(const unsigned int b) noexcept
inline UInt256 operator|(const UInt256 &b) const noexcept
inline UInt256 operator|(const unsigned int b) const noexcept
inline UInt256 &operator|=(const UInt256 &b) noexcept
inline UInt256 &operator|=(const unsigned int b) noexcept
inline UInt256 operator&(const UInt256 &b) const noexcept
inline UInt256 operator&(const unsigned int b) const noexcept
inline UInt256 &operator&=(const UInt256 &b) noexcept
inline UInt256 &operator&=(const unsigned int b) noexcept
inline UInt256 operator<<(const UInt256 &b) const noexcept
inline UInt256 operator<<(const unsigned int b) const noexcept
inline UInt256 &operator<<=(const UInt256 &b) noexcept
inline UInt256 &operator<<=(const unsigned int b) noexcept
inline UInt256 operator>>(const UInt256 &b) const noexcept
inline UInt256 operator>>(const unsigned int b) const noexcept
inline UInt256 &operator>>=(const UInt256 &b) noexcept
inline UInt256 &operator>>=(const unsigned int b) noexcept
inline UInt256 operator~() const noexcept
inline std::string str() const noexcept

Return string representation of vector.

Returns:

String representation of vector.

Public Static Attributes

static int size = 8

Number of individual values stored by object. This value can be used to iterate over elements.