Template Struct wide_vector

Inheritance Relationships

Base Type

  • private wt::detail::simd_data_t< f_t, Width, N >

Struct Documentation

template<std::size_t Width, std::size_t N, Quantity Q>
struct wide_vector : private wt::detail::simd_data_t<f_t, Width, N>

Wide (4 or 8 element) floating point vectors, each vector of N elements (up to 4). Used SIMD type and instruction set depends on wt::f_t, designed to support 32-bit and 64-bit precision. The resulting data type is of Width x N element count. Supports quantities.

Template Parameters:
  • Width – width (count of simd elements) of the vector, must be 4 or 8

  • N – number of vector elements (N==1 is treated as a scalar), must be 1<=N<=4

  • Q – quantity of the vector (simd::unitless indicates unitless, simd::bool_mask indicates boolean masks)

Public Types

using Fp = f_t
using S = std::conditional_t<is_unitless, Fp, Q>

Type of a single element of the wide vector &#8212; scalar of quantity Q.

using T = std::conditional_t<is_scalar, S, std::conditional_t<is_unitless, vec<N, Fp>, qvec<N, Q>>>

Type of a horizontal slice of the wide vector &#8212; N element vector of quantity Q.

using simd_native_t = detail::simd_data_t<f_t, Width, N>::simd_native_t

Public Functions

wide_vector() noexcept = default
inline wide_vector(const wide_vector &o) noexcept = default
inline explicit wide_vector(const simd_native_t &v) noexcept

Construct a scalar wide vector from a native SIMD wide scalar. Typically should not be used.

inline explicit wide_vector(const simd_native_t &x, const simd_native_t &y) noexcept

Construct a wide vector from native SIMD wide scalars. Typically should not be used.

inline explicit wide_vector(const simd_native_t &x, const simd_native_t &y, const simd_native_t &z) noexcept

Construct a wide vector from native SIMD wide scalars. Typically should not be used.

inline explicit wide_vector(const simd_native_t &x, const simd_native_t &y, const simd_native_t &z, const simd_native_t &w) noexcept

Construct a wide vector from native SIMD wide scalars. Typically should not be used.

inline auto &simd_native(std::size_t n) noexcept

Access the underlying SIMD element for vector index n. Typically, should not be used.

inline const auto &simd_native(std::size_t n) const noexcept

Access the underlying SIMD element for vector index n. Typically, should not be used.

template<typename T2>
inline explicit wide_vector(const T2 &scalar) noexcept

Construct a scalar wide vector from a single scalar scalar, copying scalar into all wide elements.

template<typename T2>
inline explicit wide_vector(const T2 &vec) noexcept

Construct a wide vector from a single vector vec, copying vec into all wide elements.

inline explicit wide_vector(const wide_vector<Width, N, simd::unitless> &v) noexcept

Explicit construction of a bool mask from a unitless wide vector.

inline explicit wide_vector(wide_vector<4, N, Q> lower, wide_vector<4, N, Q> upper) noexcept

Construct an 8-wide vector from 2 4-wide vectors.

inline explicit wide_vector(wide_vector<4, N, Q> lower, wide_vector<4, N, Q> upper) noexcept

Construct an 8-wide vector from 2 4-wide vectors.

inline explicit wide_vector(wide_vector<Width, 1, Q> x, wide_vector<Width, 1, Q> y) noexcept

Construct a wide vector from scalar wide vectors.

inline explicit wide_vector(wide_vector<Width, 1, Q> x, wide_vector<Width, 1, Q> y, wide_vector<Width, 1, Q> z) noexcept

Construct a wide vector from scalar wide vectors.

inline explicit wide_vector(wide_vector<Width, 1, Q> x, wide_vector<Width, 1, Q> y, wide_vector<Width, 1, Q> z, wide_vector<Width, 1, Q> w) noexcept

Construct a wide vector from scalar wide vectors.

inline explicit wide_vector(const T &w0, const T &w1, const T &w2, const T &w3) noexcept

Construct a scalar wide vector by explicitly setting each wide element.

inline explicit wide_vector(const T &w0, const T &w1, const T &w2, const T &w3, const T &w4, const T &w5, const T &w6, const T &w7) noexcept

Construct a scalar wide vector by explicitly setting each wide element.

inline explicit wide_vector(const T &w0, const T &w1, const T &w2, const T &w3) noexcept

Construct a wide vector by explicitly setting each wide element.

inline explicit wide_vector(const T &w0, const T &w1, const T &w2, const T &w3, const T &w4, const T &w5, const T &w6, const T &w7) noexcept

Construct a wide vector by explicitly setting each wide element.

inline explicit wide_vector(const S *data, simd::unaligned_data_t) noexcept

Loads wide data from arbitrarily-aligned address.

inline explicit wide_vector(const S *x, const S *y, simd::unaligned_data_t) noexcept

Loads wide data from arbitrarily-aligned address.

inline explicit wide_vector(const S *x, const S *y, const S *z, simd::unaligned_data_t) noexcept

Loads wide data from arbitrarily-aligned address.

inline explicit wide_vector(const S *x, const S *y, const S *z, const S *w, simd::unaligned_data_t) noexcept

Loads wide data from arbitrarily-aligned address.

inline explicit wide_vector(const S *data, simd::aligned_data_t) noexcept

Loads wide data from address, assumes address is aligned to sizeof(Fp)*Width boundary.

inline explicit wide_vector(const S *x, const S *y, simd::aligned_data_t) noexcept

Loads wide data from address, assumes address is aligned to sizeof(Fp)*Width boundary.

inline explicit wide_vector(const S *x, const S *y, const S *z, simd::aligned_data_t) noexcept

Loads wide data from address, assumes address is aligned to sizeof(Fp)*Width boundary.

inline explicit wide_vector(const S *x, const S *y, const S *z, const S *w, simd::aligned_data_t) noexcept

Loads wide data from address, assumes address is aligned to sizeof(Fp)*Width boundary.

inline explicit wide_vector(const wide_vector<4, N, Q> &o) noexcept
inline explicit wide_vector(const wide_vector<4, N, Q> &o) noexcept
inline wide_vector &operator=(const wide_vector &o) noexcept = default
inline auto operator[](std::size_t n) const noexcept

Extracts a horizontal slice as a scalar wide vector from element at position n (between 0 and N-1) in the vector.

inline auto x() const noexcept

Extracts the n==0 scalar wide vector, equivalent to operator[0].

inline auto y() const noexcept

Extracts the n==1 scalar wide vector, equivalent to operator[1].

inline auto z() const noexcept

Extracts the n==2 scalar wide vector, equivalent to operator[2].

inline auto w() const noexcept

Extracts the n==3 scalar wide vector, equivalent to operator[3].

inline auto extract_lower_half() const noexcept

Casts an 8-wide vector into a 4-wide vector by extracting the 4 lower wide elements.

inline auto extract_upper_half() const noexcept

Casts an 8-wide vector into a 4-wide vector by extracting the 4 upper wide elements.

template<std::size_t idx>
inline auto reads() const noexcept

Returns a vertical slice of the wide vector at position w between 0 and Width-1.

Template Parameters:

idx – the compile-time known wide index

template<std::size_t idx>
inline auto reads() const noexcept

Returns a vertical slice of the wide vector at position w between 0 and Width-1.

Template Parameters:

idx – the compile-time known wide index

template<std::size_t idx>
inline auto reads() const noexcept

Returns a vertical slice of the wide vector at position w between 0 and Width-1.

Template Parameters:

idx – the compile-time known wide index

inline auto read(std::size_t w) const noexcept

Returns a vertical slice of the wide vector at position w between 0 and Width-1. Dynamic index, slower than reads.

inline auto read(std::size_t w) const noexcept

Returns a vertical slice of the wide vector at position w between 0 and Width-1. Dynamic index, slower than reads.

inline auto read(std::size_t w) const noexcept

Returns a vertical slice of the wide vector at position w between 0 and Width-1. Dynamic index, slower than reads.

inline wide_vector &operator+=(const wide_vector &o) noexcept
inline wide_vector &operator-=(const wide_vector &o) noexcept
inline wide_vector &operator*=(const wide_vector &o) noexcept
inline wide_vector &operator/=(const wide_vector &o) noexcept
inline wide_vector &operator*=(const Fp &t) noexcept
inline wide_vector &operator/=(const Fp &t) noexcept
inline wide_vector &operator&=(const wide_vector &o) noexcept

Logical AND.

inline wide_vector &operator|=(const wide_vector &o) noexcept

Logical OR.

inline wide_vector<Width, N, simd::bool_mask> operator==(const wide_vector &o) const noexcept

Logical (bool masks) equality comparison.

inline wide_vector<Width, N, simd::bool_mask> operator!=(const wide_vector &o) const noexcept

Logical (bool masks) inequality comparison.

inline wide_vector<Width, N, simd::bool_mask> operator==(const wide_vector &o) const noexcept

Floating point equality comparison.

inline wide_vector<Width, N, simd::bool_mask> operator!=(const wide_vector &o) const noexcept

Floating point inequality comparison.

inline wide_vector<Width, N, simd::bool_mask> operator<(const wide_vector &o) const noexcept
inline wide_vector<Width, N, simd::bool_mask> operator>(const wide_vector &o) const noexcept
inline wide_vector<Width, N, simd::bool_mask> operator<=(const wide_vector &o) const noexcept
inline wide_vector<Width, N, simd::bool_mask> operator>=(const wide_vector &o) const noexcept
inline wide_vector<Width, N, simd::bool_mask> operator==(zero_t) const noexcept
inline wide_vector<Width, N, simd::bool_mask> operator!=(zero_t) const noexcept
inline wide_vector<Width, N, simd::bool_mask> operator<(zero_t) const noexcept
inline wide_vector<Width, N, simd::bool_mask> operator>(zero_t) const noexcept
inline wide_vector<Width, N, simd::bool_mask> operator<=(zero_t) const noexcept
inline wide_vector<Width, N, simd::bool_mask> operator>=(zero_t) const noexcept
inline auto to_bitmask() const noexcept

Converts a unitless wide vector to a vector of std::bitset. This is useful for reading the results of comparisons operators.

inline auto to_bitmask() const noexcept

Converts a unitless wide vector to a vector of std::bitset. This is useful for reading the results of comparison operators.

template<std::convertible_to<Q> Q2>
inline operator wide_vector<Width, N, Q2>() const noexcept

Quantity cast. This may be a lossy cast.

template<std::convertible_to<Q> Q2, std::size_t N2>
inline explicit operator wide_vector<Width, N2, Q2>() const noexcept

Cast a scalar wide vector to a wide vector. Also does a quantity cast which may be a lossy cast.

Public Static Functions

template<typename T2>
static inline wide_vector from_scalar(T2 scalar) noexcept

Constructs from a single scalar, i.e. sets all Width*N elements to scalar.

template<typename S2>
static inline wide_vector from_vector(S2 scalar) noexcept

Constructs from a single vector, i.e. sets all Width*N elements to scalar.

static inline wide_vector zero() noexcept
static inline wide_vector zero() noexcept
static inline wide_vector one() noexcept
static inline wide_vector inf() noexcept
static inline wide_vector inf() noexcept
static inline wide_vector mask_true() noexcept

Creates a unitless wide vector with all its elements initialized to a mask interpreted as TRUE.

static inline wide_vector mask_false() noexcept

Creates a unitless wide vector with all its elements initialized to 0, also interpreted as FALSE.

Public Static Attributes

static constexpr auto is_bool_mask = std::is_same_v<Q, simd::bool_mask>
static constexpr auto width = Width
static constexpr bool is_scalar = N == 1
static constexpr auto unit = Q::unit
static constexpr bool is_unitless = unit == u::one