avx::Double256

class Double256

Class providing vectorized version of double. Can hold 4 individual double values. Provides arithmetic operators.

  • Provides comparison operators == != (optimization on the way).

Public Types

using storedType = double

Type that is stored inside vector.

Public Functions

inline Double256() noexcept
inline Double256(const double val) noexcept
inline Double256(const __m256d init) noexcept
inline Double256(const Double256 &init) noexcept
inline Double256(const std::array<double, 4> &init) noexcept
inline  Double256 (const double *addr) N_THROW_REL
inline Double256(std::initializer_list<double> init)
inline void load (const double *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<double, 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 (double *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 double).

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 (double *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 double).

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 const __m256d get() const noexcept
inline void set(__m256d val) noexcept
inline bool operator==(const Double256 &bV)
inline bool operator==(const double b)
inline bool operator!=(const Double256 &bV)
inline bool operator!=(const double b)
inline Double256 operator+(const Double256 &other) const noexcept
inline Double256 operator+(const double val) const noexcept
inline Double256 &operator+=(const Double256 &other) noexcept
inline Double256 &operator+=(const double val) noexcept
inline Double256 operator-(const Double256 &other) const noexcept
inline Double256 operator-(const double val) const noexcept
inline Double256 &operator-=(const Double256 &other) noexcept
inline Double256 &operator-=(const double val) noexcept
inline Double256 operator*(const Double256 &other) const noexcept
inline Double256 operator*(const double val) const noexcept
inline Double256 &operator*=(const Double256 &other) noexcept
inline Double256 &operator*=(const double val) noexcept
inline Double256 operator/(const Double256 &other) const noexcept
inline Double256 operator/(const double val) const noexcept
inline Double256 &operator/=(const Double256 &other) noexcept
inline Double256 &operator/=(const double val) noexcept
inline double operator[](const unsigned int index) const

Indexing operator. Does not support value assignment through this method (e.g. aV[0] = 1 won’t work).

Parameters:

index – Position of desired element between 0 and 3.

Throws:

std::out_of_range – If index is not within the correct range and build type is debug will be thrown. Otherwise bitwise AND will prevent index to be out of range.

Returns:

Value of underlying element.

inline std::string str() const noexcept

Returns string representation of vector. Printing will result in Double256(<vector_values>) eg. Double256(1.000000, 2.000000, 3.000000, 4.000000)

Returns:

String representation of underlying vector.

Public Static Attributes

static int size = 4

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