avx::Long256

class Long256

Class providing vectorized version of long long aka int64_t. Can hold 4 individual long long values. Provides arithmetic and bitwise operators. Provides comparison operators == !=.

Public Types

using storedType = long long

Type that is stored inside vector.

Public Functions

inline Long256() noexcept

Default constructor. Initializes vector with zeros.

inline Long256(const long long *init)

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

Parameters:

init – Valid memory address of minimal size of 256-bits (32 bytes).

inline Long256(const long long &init) noexcept

Initializes vector with const value. Each cell will be set with value of init.

Parameters:

init – Value to be set.

inline Long256(__m256i init) noexcept

Initializes vector from __m256i value.

Parameters:

init – Value of type __m256i to initialize the vector.

inline Long256(Long256 &init) noexcept

Copy constructor. Initializes vector from another Long256 vector.

Parameters:

init – Another Long256 vector to copy from.

inline Long256(const Long256 &init)

Copy constructor (const). Initializes vector from another Long256 vector.

Parameters:

init – Another Long256 vector to copy from.

inline Long256(const std::array<long long, 4> &init) noexcept

Initializes vector from std::array of 4 long long values.

Parameters:

init – Array of 4 long long values to initialize the vector.

inline Long256(const std::array<int, 4> &init) noexcept

Initializes vector from std::array of 4 int values. Each int value is promoted to long long.

Parameters:

init – Array of 4 int values to initialize the vector.

inline Long256(const std::array<short, 4> &init) noexcept

Initializes vector from std::array of 4 short values. Each short value is promoted to long long.

Parameters:

init – Array of 4 short values to initialize the vector.

inline Long256(const std::array<char, 4> &init) noexcept

Initializes vector from std::array of 4 char values. Each char value is promoted to long long.

Parameters:

init – Array of 4 char values to initialize the vector.

inline Long256(std::initializer_list<long long> init) noexcept

Initializes vector from initializer_list of long long values. If the list contains fewer than 4 elements, remaining elements are set to zero. If the list contains more than 4 elements, only the first 4 are used.

Parameters:

init – Initializer list of long long values.

inline __m256i get() const noexcept

Returns the internal __m256i value stored by the object.

Returns:

The __m256i value.

inline void set(__m256i val) noexcept

Sets the internal __m256i value stored by the object.

Parameters:

val – New value of type __m256i.

inline void load (const long long *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<long long, 4> &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 (long long *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 (4x long long).

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 (long long *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 (4x long long).

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 long long operator[](unsigned int index) const
inline bool operator==(const Long256 &bV) const noexcept

Compares with second vector for equality.

Parameters:

bV – Object to compare.

Returns:

true if all elements are equal or false if not.

inline bool operator==(const long long b) const noexcept

Compares with value for equality.

Parameters:

b – Value to compare.

Returns:

true if all elements are equal to passed value false if not.

inline bool operator!=(const Long256 &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 in bV otherwise false.

inline bool operator!=(const long long b) const noexcept

Compares with value for inequality.

Parameters:

b – Value

Returns:

true if any alement is not equal to corresponding element in bV otherwise false.

inline Long256 operator+(const Long256 &bV) const noexcept
inline Long256 operator+(const long long &b) const noexcept
inline Long256 &operator+=(const Long256 &bV) noexcept
inline Long256 &operator+=(const long long &b) noexcept
inline Long256 operator-(const Long256 &bV) const noexcept
inline Long256 operator-(const long long &b) const noexcept
inline Long256 &operator-=(const Long256 &bV) noexcept
inline Long256 &operator-=(const long long &b) noexcept
inline Long256 operator*(const Long256 &bV) const noexcept
inline Long256 operator*(const long long &b) const noexcept
inline Long256 &operator*=(const Long256 &bV) noexcept
inline Long256 &operator*=(const long long &b) noexcept
inline Long256 operator/(const Long256 &bV) const noexcept
inline Long256 operator/(const long long &b) const noexcept
inline Long256 &operator/=(const Long256 &bV) noexcept
inline Long256 &operator/=(const long long &b) noexcept
inline Long256 operator%(const Long256 &bV) const noexcept
inline Long256 operator%(const long long &b) const noexcept
inline Long256 &operator%=(const Long256 &bV) noexcept
inline Long256 &operator%=(const long long &b) noexcept
inline Long256 operator|(const Long256 &bV) const noexcept
inline Long256 operator|(const long long &b) const noexcept
inline Long256 &operator|=(const Long256 &bV) noexcept
inline Long256 &operator|=(const long long &b) noexcept
inline Long256 operator^(const Long256 &bV) const noexcept
inline Long256 operator^(const long long &b) const noexcept
inline Long256 &operator^=(const Long256 &bV) noexcept
inline Long256 &operator^=(const long long &b) noexcept
inline Long256 operator&(const Long256 &bV) const noexcept
inline Long256 operator&(const long long &b) const noexcept
inline Long256 &operator&=(const Long256 &bV) noexcept
inline Long256 &operator&=(const long long &b) noexcept
inline Long256 operator~() const noexcept
inline Long256 operator<<(const Long256 &bV) const noexcept
inline Long256 operator<<(const unsigned int &b) const noexcept
inline Long256 &operator<<=(const Long256 &bV) noexcept
inline Long256 &operator<<=(const unsigned int &b) noexcept
inline Long256 operator>>(const Long256 &bV) const noexcept
inline Long256 operator>>(const unsigned int &b) const noexcept
inline Long256 &operator>>=(const Long256 &bV) noexcept
inline Long256 &operator>>=(const unsigned int &b) noexcept
inline std::string str() const noexcept

Public Static Attributes

static int size = 4

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