HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
hi::v1::array_generic< T, N > Struct Template Reference

#include <hikocpu/array_generic.hpp>

Public Types

using value_type = T
using array_type = std::array<T, N>
using intrinsic_type = array_intrinsic<T, N>
using mask_type
using signed_mask_type = std::make_signed_t<mask_type>

Public Member Functions

 hi_warning_push ()
 hi_warning_ignore_msvc (26494)
 hi_warning_pop ()

Static Public Member Functions

hi_force_inline static constexpr mask_type to_mask (value_type a) noexcept
hi_force_inline static constexpr signed_mask_type to_signed_mask (value_type a) noexcept
template<std::unsigned_integral M>
hi_force_inline static constexpr value_type to_value (M a) noexcept
template<std::signed_integral M>
hi_force_inline static constexpr value_type to_value (M a) noexcept
static hi_force_inline array_type undefined () noexcept
template<std::same_as< value_type >... Args>
requires (sizeof...(Args) == N)
hi_force_inline static constexpr array_type set (Args... args) noexcept
hi_force_inline static constexpr array_type set (value_type arg) noexcept
hi_force_inline static constexpr array_type set_zero () noexcept
hi_force_inline static constexpr array_type set_all_ones () noexcept
hi_force_inline static constexpr array_type set_one () noexcept
hi_force_inline static constexpr array_type broadcast (value_type a) noexcept
hi_force_inline static constexpr array_type broadcast (array_type a) noexcept
template<size_t I>
hi_force_inline static constexpr value_type get (array_type a) noexcept
hi_force_inline static constexpr array_type set_mask (size_t mask) noexcept
 Set each element to all ones or all zero based on the bits of the mask.
hi_force_inline static constexpr size_t get_mask (array_type a) noexcept
 Get an integer mask where each bit in the mask corresponds with the top-bit of each element.
template<array_generic_convertible_to< value_type > O>
hi_force_inline static constexpr array_type convert (std::array< O, N > a) noexcept
hi_force_inline static constexpr array_type neg (array_type a) noexcept
template<std::size_t Mask>
hi_force_inline static constexpr array_type neg_mask (array_type a) noexcept
hi_force_inline static constexpr array_type inv (array_type a) noexcept
hi_force_inline static constexpr array_type rcp (array_type a) noexcept
static hi_force_inline array_type sqrt (array_type a) noexcept
static hi_force_inline array_type rsqrt (array_type a) noexcept
hi_force_inline static constexpr array_type abs (array_type a) noexcept
hi_force_inline static constexpr array_type round (array_type a) noexcept
hi_force_inline static constexpr array_type floor (array_type a) noexcept
hi_force_inline static constexpr array_type ceil (array_type a) noexcept
hi_force_inline static constexpr array_type add (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type sub (array_type a, array_type b) noexcept
template<std::size_t Mask>
hi_force_inline static constexpr array_type addsub_mask (array_type a, array_type b) noexcept
 Add or subtract based on the mask.
hi_force_inline static constexpr array_type mul (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type div (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type mod (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type eq (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type ne (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type lt (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type gt (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type le (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type ge (array_type a, array_type b) noexcept
hi_force_inline static constexpr bool test (array_type a, array_type b) noexcept
 Test the two operands.
hi_force_inline static constexpr bool all_equal (array_type a, array_type b) noexcept
 Compare the two operands.
hi_force_inline static constexpr array_type max (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type min (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type clamp (array_type v, array_type lo, array_type hi) noexcept
hi_force_inline static constexpr array_type _or (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type _and (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type _xor (array_type a, array_type b) noexcept
hi_force_inline static constexpr array_type andnot (array_type a, array_type b) noexcept
 andnot of two operands
hi_force_inline static constexpr array_type sll (array_type a, unsigned int b) noexcept
hi_force_inline static constexpr array_type srl (array_type a, unsigned int b) noexcept
hi_force_inline static constexpr array_type sra (array_type a, unsigned int b) noexcept
hi_force_inline static constexpr array_type hadd (array_type a, array_type b) noexcept
 Add the elements of both operands pairwise and return the packed result.
hi_force_inline static constexpr array_type hsub (array_type a, array_type b) noexcept
template<size_t I, int First, int... Rest>
hi_force_inline static constexpr void _shuffle (array_type &r, array_type a) noexcept
template<size_t I, int First, int... Rest>
static constexpr bool _have_to_shuffle () noexcept
template<int... Indices>
hi_force_inline static constexpr array_type shuffle (array_type a) noexcept
template<size_t Mask>
hi_force_inline static constexpr array_type blend (array_type a, array_type b) noexcept
template<std::derived_from< array_type >... Columns>
requires (sizeof...(Columns) == N)
static constexpr std::array< array_type, N > transpose (Columns... columns) noexcept
template<size_t I, int Value, int First, int... Rest>
static constexpr void _make_swizzle_blend_mask (std::size_t &r) noexcept
template<int Value, int... Indices>
static constexpr std::size_t _make_swizzle_blend_mask () noexcept
template<int... Indices>
hi_force_inline static constexpr array_type swizzle (array_type a) noexcept
 Swizzle elements.
hi_force_inline static constexpr array_type sum (array_type a) noexcept
template<size_t Mask>
hi_force_inline static constexpr array_type dot (array_type a, array_type b) noexcept
template<size_t Mask>
hi_force_inline static constexpr array_type hypot (array_type a) noexcept
template<size_t Mask>
hi_force_inline static constexpr array_type rhypot (array_type a) noexcept
template<size_t Mask>
hi_force_inline static constexpr array_type normalize (array_type a) noexcept

Static Public Attributes

static constexpr value_type _zero_mask = to_value(mask_type{0})
static constexpr value_type _ones_mask = to_value(~mask_type{0})

Detailed Description

template<typename T, std::size_t N>
struct hi::v1::array_generic< T, N >

Intrinsic operations on arrays.

Member Typedef Documentation

◆ mask_type

template<typename T, std::size_t N>
using hi::v1::array_generic< T, N >::mask_type
Initial value:
std::conditional_t<sizeof(T) * CHAR_BIT == 8, uint8_t,
std::conditional_t<sizeof(T) * CHAR_BIT == 16, uint16_t,
std::conditional_t<sizeof(T) * CHAR_BIT == 32, uint32_t,
std::conditional_t<sizeof(T) * CHAR_BIT == 64, uint64_t, void>>>>

Member Function Documentation

◆ addsub_mask()

template<typename T, std::size_t N>
template<std::size_t Mask>
hi_force_inline static constexpr array_type hi::v1::array_generic< T, N >::addsub_mask ( array_type a,
array_type b )
inlinestaticnodiscardconstexprnoexcept

Add or subtract based on the mask.

If the mask bit is '1' then add, if the bit is '0' then substract.

◆ all_equal()

template<typename T, std::size_t N>
hi_force_inline static constexpr bool hi::v1::array_generic< T, N >::all_equal ( array_type a,
array_type b )
inlinestaticnodiscardconstexprnoexcept

Compare the two operands.

This will compare both operands bit-wise and if equal return true.

◆ andnot()

template<typename T, std::size_t N>
hi_force_inline static constexpr array_type hi::v1::array_generic< T, N >::andnot ( array_type a,
array_type b )
inlinestaticnodiscardconstexprnoexcept

andnot of two operands

The following calculation is done on the bits of the two operands: result = ~a & b

◆ get_mask()

template<typename T, std::size_t N>
hi_force_inline static constexpr size_t hi::v1::array_generic< T, N >::get_mask ( array_type a)
inlinestaticnodiscardconstexprnoexcept

Get an integer mask where each bit in the mask corresponds with the top-bit of each element.

◆ hadd()

template<typename T, std::size_t N>
hi_force_inline static constexpr array_type hi::v1::array_generic< T, N >::hadd ( array_type a,
array_type b )
inlinestaticnodiscardconstexprnoexcept

Add the elements of both operands pairwise and return the packed result.

◆ set_mask()

template<typename T, std::size_t N>
hi_force_inline static constexpr array_type hi::v1::array_generic< T, N >::set_mask ( size_t mask)
inlinestaticnodiscardconstexprnoexcept

Set each element to all ones or all zero based on the bits of the mask.

◆ swizzle()

template<typename T, std::size_t N>
template<int... Indices>
hi_force_inline static constexpr array_type hi::v1::array_generic< T, N >::swizzle ( array_type a)
inlinestaticnodiscardconstexprnoexcept

Swizzle elements.

This function shuffles the elements or inserts the constants 0 or 1 depending on the value of the Indices.

The Indices can have the following values:

  • -2: The value 1.
  • -1: The value 0.
  • other: The index of an element of a.

◆ test()

template<typename T, std::size_t N>
hi_force_inline static constexpr bool hi::v1::array_generic< T, N >::test ( array_type a,
array_type b )
inlinestaticnodiscardconstexprnoexcept

Test the two operands.

This will AND the two operands together and if all the bits are zero the test returns true.


The documentation for this struct was generated from the following file: