JPL Spatial
Sound spatialization and propagation library
Loading...
Searching...
No Matches
JPL::simd Struct Reference

Minimal 4-wide 32-bit float vector implementation for SIMD. More...

#include <JPLSpatial/Math/SIMD.h>

Public Types

using Type = std::array< float, 4 >
 

Public Member Functions

 simd () noexcept=default
 
 simd (const simd &) noexcept=default
 
simdoperator= (const simd &) noexcept=default
 
JPL_INLINE simd (Type value) noexcept
 
JPL_INLINE simd (float value) noexcept
 
JPL_INLINE simd (float v0, float v1, float v2, float v3) noexcept
 
JPL_INLINE simd (const float *mem)
 
JPL_INLINE void load (const float *mem)
 Load values from memory into simd, 'mem' should point to memory with at least size() number of floats.
 
JPL_INLINE void store (float *mem) const
 Store values from simd to provided memory location.
 
JPL_INLINE float operator[] (uint32 index) const noexcept
 Get float component by index.
 
template<uint32 LaneIndex>
requires (LaneIndex < 4)
JPL_INLINE float get_lane () const noexcept
 Get float component by index known at compile-time.
 
JPL_INLINE simd operator* (const simd &other) const noexcept
 Multiply two float vectors (component wise)
 
JPL_INLINE simd operator* (float value) const noexcept
 Multiply vector with float.
 
JPL_INLINE simd operator/ (float value) const noexcept
 Divide vector by float.
 
JPL_INLINE simdoperator*= (float value) noexcept
 Multiply vector with float.
 
JPL_INLINE simdoperator*= (const simd &other) noexcept
 Multiply vector with vector.
 
JPL_INLINE simdoperator/= (float value) noexcept
 Divide vector by float.
 
JPL_INLINE simdoperator/= (const simd &other) noexcept
 Divide vector by vector.
 
JPL_INLINE simd operator+ (const simd &other) const noexcept
 Add two float vectors (component wise)
 
JPL_INLINE simdoperator+= (const simd &other) noexcept
 Add two float vectors (component wise)
 
JPL_INLINE simd operator- () const noexcept
 Negate.
 
JPL_INLINE simd operator- (const simd &other) const noexcept
 Subtract two float vectors (component wise)
 
JPL_INLINE simdoperator-= (const simd &other) noexcept
 Subtract two float vectors (component wise)
 
JPL_INLINE simd operator/ (const simd &other) const noexcept
 Divide (component wise)
 
JPL_INLINE void operator|= (const simd &other) noexcept
 Component-wise logical OR.
 
JPL_INLINE void operator^= (const simd &other) noexcept
 Component-wise logical XOR.
 
JPL_INLINE void operator&= (const simd &other) noexcept
 Component-wise logical AND.
 
template<uint32 LaneIndex>
requires (LaneIndex < 4)
JPL_INLINE simd splat () const
 Replicate component at LaneIndex to all components.
 
JPL_INLINE float reduce () const noexcept
 Returns sum of all components.
 
JPL_INLINE float reduce_max () const noexcept
 Returns max component.
 
JPL_INLINE float reduce_min () const noexcept
 Returns min component.
 
JPL_INLINE float reduce_mean () const noexcept
 Returns mean of the components.
 
JPL_INLINE operator Type () const noexcept
 
JPL_INLINE simd_mask to_mask () const noexcept
 Convert each component from a float to an int.
 
JPL_INLINE simd_mask as_mask () const noexcept
 Reinterpret simd as a simd_mask (doesn't change the bits)
 

Static Public Member Functions

template<int Scale>
static JPL_INLINE simd gather (const float *base, const simd_mask &offsets)
 Gather 4 floats from memory at base + offsets[i] * Scale.
 
static JPL_INLINE simd zero () noexcept
 Vector with all zeros.
 
static JPL_INLINE simd nan () noexcept
 Vector with all NaN's.
 
static JPL_INLINE simd inf () noexcept
 
static JPL_INLINE simd c_0 () noexcept
 Frequently used constants.
 
static JPL_INLINE simd c_1 () noexcept
 
static JPL_INLINE simd c_0p5 () noexcept
 
static JPL_INLINE simd c_pi () noexcept
 
static constexpr std::size_t size () noexcept
 Get number of element of the vector.
 
static JPL_INLINE simd select (const simd_mask &mask, const simd &a, const simd &b) noexcept
 Component-wise select, returns 'a' if mask is true, 'b' otherwise.
 
static JPL_INLINE simd reciprocal (const simd &vec) noexcept
 Reciprocal vector (1 / value) for each of the components.
 

Public Attributes

Type mNative
 

Friends

JPL_INLINE simd operator* (float value, const simd &other) noexcept
 Multiply vector with float.
 
std::ostream & operator<< (std::ostream &inStream, const simd &vec)
 

Detailed Description

Minimal 4-wide 32-bit float vector implementation for SIMD.

Member Typedef Documentation

◆ Type

using JPL::simd::Type = std::array<float, 4>

Constructor & Destructor Documentation

◆ simd() [1/6]

JPL::simd::simd ( )
defaultnoexcept

◆ simd() [2/6]

JPL::simd::simd ( const simd )
defaultnoexcept

◆ simd() [3/6]

JPL_INLINE JPL::simd::simd ( Type  value)
inlinenoexcept

◆ simd() [4/6]

JPL_INLINE JPL::simd::simd ( float  value)
noexcept

◆ simd() [5/6]

JPL_INLINE JPL::simd::simd ( float  v0,
float  v1,
float  v2,
float  v3 
)
noexcept

◆ simd() [6/6]

JPL_INLINE JPL::simd::simd ( const float mem)

Member Function Documentation

◆ as_mask()

JPL_INLINE simd_mask JPL::simd::as_mask ( ) const
noexcept

Reinterpret simd as a simd_mask (doesn't change the bits)

◆ c_0()

JPL_INLINE simd JPL::simd::c_0 ( )
staticnoexcept

Frequently used constants.

◆ c_0p5()

JPL_INLINE simd JPL::simd::c_0p5 ( )
staticnoexcept

◆ c_1()

JPL_INLINE simd JPL::simd::c_1 ( )
staticnoexcept

◆ c_pi()

JPL_INLINE simd JPL::simd::c_pi ( )
staticnoexcept

◆ gather()

template<int Scale>
JPL_INLINE simd JPL::simd::gather ( const float base,
const simd_mask offsets 
)
static

Gather 4 floats from memory at base + offsets[i] * Scale.

◆ get_lane()

template<uint32 LaneIndex>
requires (LaneIndex < 4)
JPL_INLINE float JPL::simd::get_lane ( ) const
noexcept

Get float component by index known at compile-time.

◆ inf()

JPL_INLINE simd JPL::simd::inf ( )
staticnoexcept

◆ load()

JPL_INLINE void JPL::simd::load ( const float mem)

Load values from memory into simd, 'mem' should point to memory with at least size() number of floats.

◆ nan()

JPL_INLINE simd JPL::simd::nan ( )
staticnoexcept

Vector with all NaN's.

◆ operator Type()

JPL_INLINE JPL::simd::operator Type ( ) const
inlinenoexcept

◆ operator&=()

JPL_INLINE void JPL::simd::operator&= ( const simd other)
noexcept

Component-wise logical AND.

◆ operator*() [1/2]

JPL_INLINE simd JPL::simd::operator* ( const simd other) const
noexcept

Multiply two float vectors (component wise)

◆ operator*() [2/2]

JPL_INLINE simd JPL::simd::operator* ( float  value) const
noexcept

Multiply vector with float.

◆ operator*=() [1/2]

JPL_INLINE simd & JPL::simd::operator*= ( const simd other)
noexcept

Multiply vector with vector.

◆ operator*=() [2/2]

JPL_INLINE simd & JPL::simd::operator*= ( float  value)
noexcept

Multiply vector with float.

◆ operator+()

JPL_INLINE simd JPL::simd::operator+ ( const simd other) const
noexcept

Add two float vectors (component wise)

◆ operator+=()

JPL_INLINE simd & JPL::simd::operator+= ( const simd other)
noexcept

Add two float vectors (component wise)

◆ operator-() [1/2]

JPL_INLINE simd JPL::simd::operator- ( ) const
noexcept

Negate.

◆ operator-() [2/2]

JPL_INLINE simd JPL::simd::operator- ( const simd other) const
noexcept

Subtract two float vectors (component wise)

◆ operator-=()

JPL_INLINE simd & JPL::simd::operator-= ( const simd other)
noexcept

Subtract two float vectors (component wise)

◆ operator/() [1/2]

JPL_INLINE simd JPL::simd::operator/ ( const simd other) const
noexcept

Divide (component wise)

◆ operator/() [2/2]

JPL_INLINE simd JPL::simd::operator/ ( float  value) const
noexcept

Divide vector by float.

◆ operator/=() [1/2]

JPL_INLINE simd & JPL::simd::operator/= ( const simd other)
noexcept

Divide vector by vector.

◆ operator/=() [2/2]

JPL_INLINE simd & JPL::simd::operator/= ( float  value)
noexcept

Divide vector by float.

◆ operator=()

simd & JPL::simd::operator= ( const simd )
defaultnoexcept

◆ operator[]()

JPL_INLINE float JPL::simd::operator[] ( uint32  index) const
noexcept

Get float component by index.

◆ operator^=()

JPL_INLINE void JPL::simd::operator^= ( const simd other)
noexcept

Component-wise logical XOR.

◆ operator|=()

JPL_INLINE void JPL::simd::operator|= ( const simd other)
noexcept

Component-wise logical OR.

◆ reciprocal()

JPL_INLINE simd JPL::simd::reciprocal ( const simd vec)
staticnoexcept

Reciprocal vector (1 / value) for each of the components.

◆ reduce()

JPL_INLINE float JPL::simd::reduce ( ) const
noexcept

Returns sum of all components.

◆ reduce_max()

JPL_INLINE float JPL::simd::reduce_max ( ) const
noexcept

Returns max component.

◆ reduce_mean()

JPL_INLINE float JPL::simd::reduce_mean ( ) const
inlinenoexcept

Returns mean of the components.

◆ reduce_min()

JPL_INLINE float JPL::simd::reduce_min ( ) const
noexcept

Returns min component.

◆ select()

JPL_INLINE simd JPL::simd::select ( const simd_mask mask,
const simd a,
const simd b 
)
staticnoexcept

Component-wise select, returns 'a' if mask is true, 'b' otherwise.

◆ size()

static constexpr std::size_t JPL::simd::size ( )
inlinestaticconstexprnoexcept

Get number of element of the vector.

◆ splat()

template<uint32 LaneIndex>
requires (LaneIndex < 4)
JPL_INLINE simd JPL::simd::splat ( ) const

Replicate component at LaneIndex to all components.

◆ store()

JPL_INLINE void JPL::simd::store ( float mem) const

Store values from simd to provided memory location.

◆ to_mask()

JPL_INLINE simd_mask JPL::simd::to_mask ( ) const
noexcept

Convert each component from a float to an int.

◆ zero()

JPL_INLINE simd JPL::simd::zero ( )
staticnoexcept

Vector with all zeros.

Friends And Related Symbol Documentation

◆ operator*

JPL_INLINE simd operator* ( float  value,
const simd other 
)
friend

Multiply vector with float.

◆ operator<<

std::ostream & operator<< ( std::ostream &  inStream,
const simd vec 
)
friend

Member Data Documentation

◆ mNative

Type JPL::simd::mNative

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