Skip to content

File include/brisk/core/Simd.hpp


SimdCompatible concept

template <typename T>
concept SimdCompatible = (std::is_floating_point_v<T> ||
                          std::is_integral_v<T>) &&
                         !std::is_same_v<T, bool>

Concept to define the types compatible with SIMD operations.

The SimdCompatible concept ensures that only floating-point or integral types (excluding bool) are accepted as SIMD data types.
Template param T Type to be checked.


Simd class

template <SimdCompatible T, size_t N> Simd

A template class that represents a SIMD (Single Instruction Multiple Data) type.

The SIMD class provides various utility functions and operations for working with arrays of SIMD-compatible types. It supports element-wise arithmetic, comparisons, shuffling, and more.
Template param T The data type contained in the SIMD array (must satisfy SimdCompatible).
Template param N The number of elements in the SIMD array.

Simd<T, N> function (Simd::Simd<T, N>)

constexpr Simd() noexcept : m_data

Default constructor that initializes the SIMD array to zeros.

constexpr Simd(const Simd &) noexcept = default

Copy constructor.

template <SimdCompatible U>
explicit constexpr Simd(Simd<U, N> value) noexcept

Constructs a SIMD from another SIMD of possibly different type.
Template param U The type of the other SIMD.
Param value The other SIMD to copy values from.

template <std::convertible_to<T>... Args>
constexpr Simd(Args... values) noexcept
  requires(sizeof...(Args) == N)
    : m_data

Variadic constructor that initializes the SIMD with a list of values.
Template param Args The types of the values.
Param values The values to initialize the SIMD.

constexpr Simd(T value) noexcept
  requires(N > 1)

Broadcast constructor that initializes all elements with the same value.
Param value The value to broadcast.

size function (Simd::size)

static constexpr size_t size() noexcept

Returns the size of the SIMD array.

operator[] function (Simd::operator[])

constexpr T operator[](size_t i) const noexcept

Access operator for reading elements.
Param i Index of the element.
Returns T The element at index i.

constexpr T &operator[](size_t i) noexcept

Access operator for modifying elements.
Param i Index of the element.
Returns T& Reference to the element at index i.

read function (Simd::read)

static Simd<T, N> read(const T *data) noexcept

Static function to read data from an array into a Simd.
Param data Pointer to the data array.
Returns Simd<T, N> A Simd object populated with the array data.

write function (Simd::write)

void write(T *data) noexcept

Writes the contents of the Simd to an array.
Param data Pointer to the destination array.

shuffle function (Simd::shuffle)

template <size_t... indices>
constexpr Simd<T, sizeof...(indices)>
shuffle(size_constants<indices...>) const noexcept

Shuffles the elements of the SIMD according to the provided indices.
Template param indices The indices to shuffle the elements by.
Returns Simd<T, sizeof...(indices)> A new SIMD with the shuffled elements.

firstn function (Simd::firstn)

template <size_t Nout>
constexpr Simd<T, Nout> firstn(size_constant<Nout> =

Returns the first Nout elements of the SIMD.
Template param Nout The number of elements to return.
Returns Simd<T, Nout> A new SIMD containing the first Nout elements.

lastn function (Simd::lastn)

template <size_t Nout>
constexpr Simd<T, Nout> lastn(size_constant<Nout> =

Returns the last Nout elements of the SIMD.
Template param Nout The number of elements to return.
Returns Simd<T, Nout> A new SIMD containing the last Nout elements.

low function (Simd::low)

Simd<T, N / 2> low() const noexcept
  requires(N % 2 == 0)

Splits the SIMD in half, returning the lower half.
Returns Simd<T, N/2> A SIMD containing the lower half of elements.

high function (Simd::high)

Simd<T, N / 2> high() const noexcept
  requires(N % 2 == 0)

Splits the SIMD in half, returning the upper half.
Returns Simd<T, N/2> A SIMD containing the upper half of elements.

front function (Simd::front)

T front() const noexcept

Returns the first element in the SIMD.

T &front() noexcept

Returns a reference to the first element in the SIMD.

back function (Simd::back)

T back() const noexcept

Returns the last element in the SIMD.

T &back() noexcept

Returns a reference to the last element in the SIMD.

data function (Simd::data)

const T *data() const noexcept

Returns a pointer to the underlying data.

T *data() noexcept

Returns a mutable pointer to the underlying data.

m_data variable (Simd::m_data)

T m_data[(N)]

Underlying storage for the SIMD elements.


SimdMask typedef

template <size_t N> SimdMask = std::array<bool, N>

SimdMaskAlias for a boolean mask used with SIMD operations.
Template param N The size of the mask.


SimdMask = std::array<bool, N>

SimdMaskAlias for a boolean mask used with SIMD operations.
Template param N The size of the mask.


SimdIndices typedef

template <size_t N> SimdIndices = std::array<size_t, N>

SimdIndicesAlias for an index array used in SIMD shuffling operations.
Template param N The number of indices.


SimdIndices = std::array<size_t, N>

SimdIndicesAlias for an index array used in SIMD shuffling operations.
Template param N The number of indices.


operator+= function

template <typename T, size_t N>
constexpr Simd<T, N> &operator+=(Simd<T, N> &lhs,
                                 Simd<T, N> rhs) noexcept

Performs element-wise addition between two SIMD objects.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N>& A reference to the updated SIMD object after addition.


operator+ function

template <typename T, size_t N>
constexpr Simd<T, N> operator+(Simd<T, N> lhs,
                               Simd<T, N> rhs) noexcept

Adds two SIMD objects element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N> A new SIMD object containing the result of the addition.


operator+= function

template <typename T, size_t N>
constexpr Simd<T, N> &operator+=(Simd<T, N> &lhs,
                                 T rhs) noexcept

Adds a scalar value to each element of a SIMD object.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Param rhs The scalar value.
Returns Simd<T, N>& A reference to the updated SIMD object after addition.


operator+ function

template <typename T, size_t N>
constexpr Simd<T, N> operator+(Simd<T, N> lhs,
                               T rhs) noexcept

Adds a scalar value to each element of a SIMD object.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Param rhs The scalar value.
Returns Simd<T, N> A new SIMD object containing the result of the addition.


template <typename T, size_t N>
constexpr Simd<T, N> operator+(T lhs,
                               Simd<T, N> rhs) noexcept

Adds a SIMD object to a scalar value, element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The scalar value.
Param rhs The SIMD object.
Returns Simd<T, N> A new SIMD object containing the result of the addition.


operator-= function

template <typename T, size_t N>
constexpr Simd<T, N> &operator-=(Simd<T, N> &lhs,
                                 Simd<T, N> rhs) noexcept

Performs element-wise subtraction between two SIMD objects.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N>& A reference to the updated SIMD object after subtraction.


operator- function

template <typename T, size_t N>
constexpr Simd<T, N> operator-(Simd<T, N> lhs,
                               Simd<T, N> rhs) noexcept

Subtracts two SIMD objects element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N> A new SIMD object containing the result of the subtraction.


operator-= function

template <typename T, size_t N>
constexpr Simd<T, N> &operator-=(Simd<T, N> &lhs,
                                 T rhs) noexcept

Subtracts a scalar value from each element of a SIMD object.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Param rhs The scalar value.
Returns Simd<T, N>& A reference to the updated SIMD object after subtraction.


operator- function

template <typename T, size_t N>
constexpr Simd<T, N> operator-(Simd<T, N> lhs,
                               T rhs) noexcept

Subtracts a scalar value from each element of a SIMD object.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Param rhs The scalar value.
Returns Simd<T, N> A new SIMD object containing the result of the subtraction.


template <typename T, size_t N>
constexpr Simd<T, N> operator-(T lhs,
                               Simd<T, N> rhs) noexcept

Subtracts each element of a SIMD object from a scalar value, element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The scalar value.
Param rhs The SIMD object.
Returns Simd<T, N> A new SIMD object containing the result of the subtraction.


operator*= function

template <typename T, size_t N>
constexpr Simd<T, N> &operator*=(Simd<T, N> &lhs,
                                 Simd<T, N> rhs) noexcept

Performs element-wise multiplication between two SIMD objects.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N>& A reference to the updated SIMD object after multiplication.


operator* function

template <typename T, size_t N>
constexpr Simd<T, N> operator*(Simd<T, N> lhs,
                               Simd<T, N> rhs) noexcept

Multiplies two SIMD objects element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N> A new SIMD object containing the result of the multiplication.


operator*= function

template <typename T, size_t N>
constexpr Simd<T, N> &operator*=(Simd<T, N> &lhs,
                                 T rhs) noexcept

Multiplies each element of a SIMD object by a scalar value.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Param rhs The scalar value.
Returns Simd<T, N>& A reference to the updated SIMD object after multiplication.


operator* function

template <typename T, size_t N>
constexpr Simd<T, N> operator*(Simd<T, N> lhs,
                               T rhs) noexcept

Multiplies each element of a SIMD object by a scalar value.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Param rhs The scalar value.
Returns Simd<T, N> A new SIMD object containing the result of the multiplication.


template <typename T, size_t N>
constexpr Simd<T, N> operator*(T lhs,
                               Simd<T, N> rhs) noexcept

Multiplies a scalar value by each element of a SIMD object, element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The scalar value.
Param rhs The SIMD object.
Returns Simd<T, N> A new SIMD object containing the result of the multiplication.


operator/= function

template <typename T, size_t N>
constexpr Simd<T, N> &operator/=(Simd<T, N> &lhs,
                                 Simd<T, N> rhs) noexcept

Performs element-wise division between two SIMD objects.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N>& A reference to the updated SIMD object after division.


operator/ function

template <typename T, size_t N>
constexpr Simd<T, N> operator/(Simd<T, N> lhs,
                               Simd<T, N> rhs) noexcept

Divides two SIMD objects element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N> A new SIMD object containing the result of the division.


operator/= function

template <typename T, size_t N>
constexpr Simd<T, N> &operator/=(Simd<T, N> &lhs,
                                 T rhs) noexcept

Divides each element of a SIMD object by a scalar value.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Param rhs The scalar value.
Returns Simd<T, N>& A reference to the updated SIMD object after division.


operator/ function

template <typename T, size_t N>
constexpr Simd<T, N> operator/(Simd<T, N> lhs,
                               T rhs) noexcept

Divides each element of a SIMD object by a scalar value.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Param rhs The scalar value.
Returns Simd<T, N> A new SIMD object containing the result of the division.


template <typename T, size_t N>
constexpr Simd<T, N> operator/(T lhs,
                               Simd<T, N> rhs) noexcept

Divides a scalar value by each element of a SIMD object, element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The scalar value.
Param rhs The SIMD object.
Returns Simd<T, N> A new SIMD object containing the result of the division.


operator+ function

template <typename T, size_t N>
constexpr Simd<T, N> operator+(Simd<T, N> lhs) noexcept

Unary plus operator for SIMD objects (returns the object unchanged).
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Returns Simd<T, N> The input SIMD object, unchanged.


operator- function

template <typename T, size_t N>
constexpr Simd<T, N> operator-(Simd<T, N> lhs) noexcept

Unary negation operator for SIMD objects (negates each element).
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Returns Simd<T, N> A new SIMD object with negated elements.


operator== function

template <typename T, size_t N>
constexpr bool operator==(Simd<T, N> lhs,
                          Simd<T, N> rhs) noexcept

Equality comparison between two SIMD objects.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns true if all elements are equal, false otherwise.


operator!= function

template <typename T, size_t N>
constexpr bool operator!=(Simd<T, N> lhs,
                          Simd<T, N> rhs) noexcept

Inequality comparison between two SIMD objects.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns true if any element differs, false otherwise.


eq function

template <typename T, size_t N>
constexpr SimdMask<N> eq(Simd<T, N> lhs, Simd<T, N> rhs)

Compares two SIMD objects for equality, element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns SimdMask<N> A mask indicating which elements are equal.


ne function

template <typename T, size_t N>
constexpr SimdMask<N> ne(Simd<T, N> lhs, Simd<T, N> rhs)

Compares two SIMD objects for inequality, element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns SimdMask<N> A mask indicating which elements are not equal.


lt function

template <typename T, size_t N>
constexpr SimdMask<N> lt(Simd<T, N> lhs, Simd<T, N> rhs)

Compares two SIMD objects to determine if the left-hand side is less than the right-hand side, element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns SimdMask<N> A mask indicating which elements in the left-hand side are less than the corresponding elements in the right-hand side.


gt function

template <typename T, size_t N>
constexpr SimdMask<N> gt(Simd<T, N> lhs, Simd<T, N> rhs)

Compares two SIMD objects to determine if the left-hand side is greater than the right-hand side, element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns SimdMask<N> A mask indicating which elements in the left-hand side are greater than the corresponding elements in the right-hand side.


le function

template <typename T, size_t N>
constexpr SimdMask<N> le(Simd<T, N> lhs, Simd<T, N> rhs)

Compares two SIMD objects to determine if the left-hand side is less than or equal to the right-hand side, element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns SimdMask<N> A mask indicating which elements in the left-hand side are less than or equal to the corresponding elements in the right-hand side.


ge function

template <typename T, size_t N>
constexpr SimdMask<N> ge(Simd<T, N> lhs, Simd<T, N> rhs)

Compares two SIMD objects to determine if the left-hand side is greater than or equal to the right-hand side, element-wise.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns SimdMask<N> A mask indicating which elements in the left-hand side are greater than or equal to the corresponding elements in the right-hand side.


maskOr function

template <size_t N>
constexpr SimdMask<N> maskOr(SimdMask<N> lhs,
                             SimdMask<N> rhs)

Performs a bitwise OR between two SIMD masks.
Template param N The number of elements in the mask.
Param lhs The left-hand side SIMD mask.
Param rhs The right-hand side SIMD mask.
Returns SimdMask<N> A mask with the result of the OR operation applied element-wise.


maskAnd function

template <size_t N>
constexpr SimdMask<N> maskAnd(SimdMask<N> lhs,
                              SimdMask<N> rhs)

Performs a bitwise AND between two SIMD masks.
Template param N The number of elements in the mask.
Param lhs The left-hand side SIMD mask.
Param rhs The right-hand side SIMD mask.
Returns SimdMask<N> A mask with the result of the AND operation applied element-wise.


horizontalAll function

template <size_t N>
constexpr bool horizontalAll(SimdMask<N> value)

Determines if all elements of a SIMD mask are true.
Template param N The number of elements in the mask.
Param value The SIMD mask to check.
Returns true if all elements are true, false otherwise.


horizontalAny function

template <size_t N>
constexpr bool horizontalAny(SimdMask<N> value)

Determines if any element of a SIMD mask is true.
Template param N The number of elements in the mask.
Param value The SIMD mask to check.
Returns true if any element is true, false otherwise.


select function

template <typename T, size_t N>
constexpr Simd<T, N> select(SimdMask<N> mask,
                            Simd<T, N> trueval,
                            Simd<T, N> falseval)

Selects elements from two SIMD objects based on a mask.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param mask The SIMD mask used for selection.
Param trueval The SIMD object whose elements are selected where the mask is true.
Param falseval The SIMD object whose elements are selected where the mask is false.
Returns Simd<T, N> The resulting SIMD object with selected elements.


shuffle function

template <size_t... indices, typename T, size_t N>
constexpr Simd<T, sizeof...(indices)>
shuffle(Simd<T, N> source) noexcept

Shuffles elements in the SIMD object based on specified indices.
Template param indices The indices to shuffle the elements.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param source The SIMD object to shuffle.
Returns Simd<T, sizeof...(indices)> The shuffled SIMD object.


concat function

template <typename T, size_t... Nin>
constexpr Simd<T, (Nin + ...)>
concat(const Simd<T, Nin> &...source) noexcept

Concatenates multiple SIMD objects into a single SIMD object.
Template param T The data type contained in the SIMD arrays.
Template param Nin The sizes of the SIMD arrays to concatenate.
Param source The SIMD objects to concatenate.
Returns Simd<T, (Nin + ...)> The concatenated SIMD object.


min function

template <typename T, size_t N>
constexpr Simd<T, N> min(Simd<T, N> lhs,
                         Simd<T, N> rhs) noexcept

Returns the element-wise minimum between two SIMD objects.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N> A SIMD object containing the element-wise minimum values.


max function

template <typename T, size_t N>
constexpr Simd<T, N> max(Simd<T, N> lhs,
                         Simd<T, N> rhs) noexcept

Returns the element-wise maximum between two SIMD objects.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N> A SIMD object containing the element-wise maximum values.


clamp function

template <typename T, size_t N>
constexpr Simd<T, N> clamp(Simd<T, N> x, Simd<T, N> low,
                           Simd<T, N> high) noexcept

Clamps each element of the SIMD object between a lower and upper bound.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param x The SIMD object to clamp.
Param low The lower bound.
Param high The upper bound.
Returns Simd<T, N> A SIMD object with elements clamped between the low and high values.


blend function

template <int... mask, typename T, size_t N>
constexpr Simd<T, N> blend(Simd<T, N> val0,
                           Simd<T, N> val1) noexcept
  requires(sizeof...(mask) == N)

Blends two SIMD objects based on a mask.
Template param mask The mask for blending, where 1 means selecting from val1, 0 means selecting from val0.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param val0 The first SIMD object.
Param val1 The second SIMD object.
Returns Simd<T, N> The blended SIMD object.


constexprAbs function (Internal::constexprAbs)

template <typename T> constexpr T constexprAbs(T x)

Computes the absolute value of a number, optimized for constant evaluation.
Template param T The type of the input value.
Param x The input value.
Returns T The absolute value of the input.


constexprCopysign function (Internal::constexprCopysign)

template <typename T>
constexpr T constexprCopysign(T x, T s)

Copies the sign from one value to another, optimized for constant evaluation.
Template param T The type of the input values.
Param x The value whose magnitude is used.
Param s The value whose sign is copied.
Returns T The value of x with the sign of s.


constexprTrunc function (Internal::constexprTrunc)

template <typename T> constexpr T constexprTrunc(T x)

Truncates a floating-point value toward zero, optimized for constant evaluation.


constexprRound function (Internal::constexprRound)

template <typename T> constexpr T constexprRound(T x)

Rounds a floating-point value to the nearest integer (half away from zero), optimized for constant evaluation.


horizontalMin function

template <typename T, size_t N>
constexpr T horizontalMin(Simd<T, N> lhs) noexcept

Computes the minimum element of the SIMD object.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Returns T The minimum value across all elements in the SIMD object.


horizontalMax function

template <typename T, size_t N>
constexpr T horizontalMax(Simd<T, N> lhs) noexcept

Computes the maximum element of the SIMD object.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Returns T The maximum value across all elements in the SIMD object.


horizontalAbsMax function

template <typename T, size_t N>
constexpr T horizontalAbsMax(Simd<T, N> lhs) noexcept

Computes the maximum absolute element of the SIMD object.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Returns T The maximum absolute value across all elements in the SIMD object.


horizontalSum function

template <typename T, size_t N>
constexpr T horizontalSum(Simd<T, N> lhs) noexcept

Computes the sum of all elements in the SIMD object.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Returns T The sum of all elements in the SIMD object.


horizontalRMS function

template <typename T, size_t N>
constexpr T horizontalRMS(Simd<T, N> lhs) noexcept

Computes the root mean square (RMS) of the elements in the SIMD object.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The SIMD object.
Returns T The RMS value across all elements in the SIMD object.


dot function

template <typename T, size_t N>
constexpr T dot(Simd<T, N> lhs, Simd<T, N> rhs) noexcept

Computes the dot product of two SIMD objects.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns T The dot product of the two SIMD objects.


mix function

template <typename T, size_t N>
constexpr Simd<T, N> mix(float t, Simd<T, N> lhs,
                         Simd<T, N> rhs)

Linearly interpolates between two SIMD objects.
Template param T The data type contained in the SIMD array.
Template param N The number of elements in the SIMD array.
Param t The interpolation factor, typically between 0 and 1.
Param lhs The left-hand side SIMD object.
Param rhs The right-hand side SIMD object.
Returns Simd<T, N> The interpolated SIMD object.


pow function

template <typename T1, typename T2, size_t N,
          typename U = decltype(std::pow(
              std::declval<T1>(), std::declval<T2>()))>
constexpr Simd<U, N> pow(const Simd<T1, N> &lhs,
                         const Simd<T2, N> &rhs)

Raises each element of the SIMD object to the power of the corresponding element in another SIMD object.
Template param T1 The data type of the base SIMD array.
Template param T2 The data type of the exponent SIMD array.
Template param N The number of elements in the SIMD arrays.
Template param U The resulting type after the power operation.
Param lhs The base SIMD object.
Param rhs The exponent SIMD object.
Returns Simd<U, N> A SIMD object containing the element-wise power results.


abs function

template <typename T, size_t N>
constexpr Simd<T, N> abs(Simd<T, N> val)

Computes the element-wise absolute value of a SIMD object.
Template param T The type of the elements in the SIMD object.
Template param N The number of elements in the SIMD object.
Param val The SIMD object.
Returns Simd<T, N> A new SIMD object with absolute values of each element.


sqrt function

template <typename T, size_t N>
constexpr Simd<T, N> sqrt(Simd<T, N> val)

Computes the element-wise square root of a SIMD object.
Template param T The type of the elements in the SIMD object.
Template param N The number of elements in the SIMD object.
Param val The SIMD object.
Returns Simd<T, N> A new SIMD object with square roots of each element.


sincos function

template <typename T, size_t N>
constexpr Simd<T, N> sincos(Simd<T, N> val)
  requires(N % 2 == 0)

Computes the sine and cosine for each element of a SIMD object.
Note The number of elements (N) must be even.
Template param T The type of the elements in the SIMD object.
Template param N The number of elements in the SIMD object.
Param val The SIMD object.
Returns Simd<T, N> A new SIMD object with alternating sine and cosine values.


cossin function

template <typename T, size_t N>
constexpr Simd<T, N> cossin(Simd<T, N> val)
  requires(N % 2 == 0)

Computes the cosine and sine for each element of a SIMD object.
Note The number of elements (N) must be even.
Template param T The type of the elements in the SIMD object.
Template param N The number of elements in the SIMD object.
Param val The SIMD object.
Returns Simd<T, N> A new SIMD object with alternating cosine and sine values.


copysign function

template <typename T, size_t N>
constexpr Simd<T, N> copysign(Simd<T, N> lhs,
                              Simd<T, N> rhs)

Copies the sign from one SIMD object to another element-wise.
Template param T The type of the elements in the SIMD objects.
Template param N The number of elements in the SIMD objects.
Param lhs The SIMD object providing the magnitude.
Param rhs The SIMD object providing the sign.
Returns Simd<T, N> A new SIMD object where each element has the magnitude of lhs and the sign of rhs.


round function

template <typename T, size_t N>
constexpr Simd<T, N> round(Simd<T, N> val)

Rounds each element in the SIMD object to the nearest integer.
Template param T The type of the elements in the SIMD object.
Template param N The number of elements in the SIMD object.
Param val The SIMD object.
Returns Simd<T, N> A new SIMD object with each element rounded.


floor function

template <typename T, size_t N>
constexpr Simd<T, N> floor(Simd<T, N> val)

Computes the element-wise floor (round down) of a SIMD object.
Template param T The type of the elements in the SIMD object.
Template param N The number of elements in the SIMD object.
Param val The SIMD object.
Returns Simd<T, N> A new SIMD object with floored values.


ceil function

template <typename T, size_t N>
constexpr Simd<T, N> ceil(Simd<T, N> val)

Computes the element-wise ceiling (round up) of a SIMD object.
Template param T The type of the elements in the SIMD object.
Template param N The number of elements in the SIMD object.
Param val The SIMD object.
Returns Simd<T, N> A new SIMD object with ceiling values.


trunc function

template <typename T, size_t N>
constexpr Simd<T, N> trunc(Simd<T, N> val)

Truncates each element in the SIMD object to its integer part.
Template param T The type of the elements in the SIMD object.
Template param N The number of elements in the SIMD object.
Param val The SIMD object.
Returns Simd<T, N> A new SIMD object with truncated values.


swapAdjacent function

template <typename T, size_t N>
constexpr Simd<T, N> swapAdjacent(Simd<T, N> val)
  requires(N % 2 == 0)

Swaps adjacent elements in the SIMD object.
Note The number of elements (N) must be even.
Template param T The type of the elements in the SIMD object.
Template param N The number of elements in the SIMD object.
Param val The SIMD object.
Returns Simd<T, N> A new SIMD object with adjacent elements swapped.


repeat function

template <size_t Ncount, typename T, size_t N>
constexpr Simd<T, Ncount * N> repeat(Simd<T, N> val)

Repeats the elements of a SIMD object multiple times.
Template param Ncount The number of times to repeat the elements.
Template param T The type of the elements in the SIMD object.
Template param N The number of elements in the SIMD object.
Param val The SIMD object.
Returns Simd<T, Ncount * N> A new SIMD object with repeated elements.


rescale function

template <SimdCompatible Tout, int Mout, int Min,
          SimdCompatible Tin, size_t N>
constexpr Simd<Tout, N> rescale(Simd<Tin, N> value)
  requires(Mout != Min &&
           (std::is_floating_point<Tin>::value ||
            std::is_floating_point<Tout>::value))

Rescales the elements of a SIMD object, either between different ranges or floating-point types.
Note This overload is for rescaling with floating-point values.
Template param Tout The output type of the elements.
Template param Mout The maximum value for the output range.
Template param Min The minimum value for the input range.
Template param Tin The input type of the elements.
Template param N The number of elements in the SIMD object.
Param value The SIMD object to rescale.
Returns Simd<Tout, N> A rescaled SIMD object.


template <SimdCompatible Tout, int Mout, int Min,
          SimdCompatible Tin, size_t N>
constexpr Simd<Tout, N> rescale(Simd<Tin, N> value)
  requires(Mout != Min &&
           !(std::is_floating_point<Tin>::value ||
             std::is_floating_point<Tout>::value))

Rescales the elements of a SIMD object, either between different ranges or integral types.
Note This overload is for rescaling with integral values.
Template param Tout The output type of the elements.
Template param Mout The maximum value for the output range.
Template param Min The minimum value for the input range.
Template param Tin The input type of the elements.
Template param N The number of elements in the SIMD object.
Param value The SIMD object to rescale.
Returns Simd<Tout, N> A rescaled SIMD object.


template <SimdCompatible Tout, int Mout, int Min,
          SimdCompatible Tin, size_t N>
constexpr Simd<Tout, N> rescale(Simd<Tin, N> value)
  requires(Mout == Min)

Rescales a single value or a SIMD object when the input and output ranges are equal.
Template param Tout The output type of the value.
Template param Mout The maximum value for the output range.
Template param Min The minimum value for the input range.
Template param Tin The input type of the value.
Returns Simd<Tout, N> The rescaled value or SIMD object.


template <SimdCompatible Tout, int Mout, int Min,
          SimdCompatible Tin>
constexpr Tout rescale(Tin value)

Rescales a single value between two ranges.
Template param Tout The output type of the value.
Template param Mout The maximum value for the output range.
Template param Min The minimum value for the input range.
Template param Tin The input type of the value.
Param value The value to rescale.
Returns Tout The rescaled value.


byteswap function (Internal::byteswap)

constexpr uint16_t byteswap(uint16_t x)

Byte-swaps a 16-bit unsigned integer.

This constexpr function swaps the byte order of a 16-bit unsigned integer. It can be used at compile time when the value is known at that time, but switches to a platform-optimized version at runtime when needed.
Param x The 16-bit unsigned integer to be byte-swapped.
Returns The byte-swapped 16-bit unsigned integer.


constexpr uint32_t byteswap(uint32_t x)

Byte-swaps a 32-bit unsigned integer.

This constexpr function swaps the byte order of a 32-bit unsigned integer. It can be used at compile time if the value is known, otherwise it switches to a platform-optimized implementation at runtime.
Param x The 32-bit unsigned integer to be byte-swapped.
Returns The byte-swapped 32-bit unsigned integer.


constexpr uint64_t byteswap(uint64_t x)

Byte-swaps a 64-bit unsigned integer.

This constexpr function swaps the byte order of a 64-bit unsigned integer. It can be used at compile time if the value is known, otherwise it switches to a platform-optimized implementation at runtime.
Param x The 64-bit unsigned integer to be byte-swapped.
Returns The byte-swapped 64-bit unsigned integer.


Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/