HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simd::vfloat4 Class Reference

#include <simd.h>

+ Inheritance diagram for simd::vfloat4:

Public Types

enum  { elements = 4 }
 
enum  { paddedelements = 4 }
 
enum  { bits = elements*32 }
 
typedef float value_t
 Underlying equivalent scalar value type. More...
 
typedef simd_raw_t< float, 4 >
::type 
simd_t
 the native SIMD type used More...
 
typedef vfloat4 vfloat_t
 SIMD int type. More...
 
typedef vint4 vint_t
 SIMD int type. More...
 
typedef vbool4 vbool_t
 SIMD bool type. More...
 
typedef vint4 int_t
 
typedef vbool4 bool_t
 

Public Member Functions

 vfloat4 ()
 Default constructor (contents undefined) More...
 
 vfloat4 (float a)
 Construct from a single value (store it in all slots) More...
 
 vfloat4 (float a, float b, float c, float d=0.0f)
 Construct from 3 or 4 values. More...
 
 vfloat4 (const float *f)
 Construct from a pointer to 4 values. More...
 
 vfloat4 (const vfloat4 &other)
 Copy construct from another vfloat4. More...
 
 vfloat4 (const vint4 &ival)
 Construct from an vint4 (promoting all components to float) More...
 
 vfloat4 (const simd_t &m)
 Construct from the underlying SIMD type. More...
 
template<typename V , OIIO_ENABLE_IF(has_subscript_N< V, value_t, 3 >::value &&!std::is_same< V, vfloat3 >::value) >
 vfloat4 (const V &v)
 Construct from a generic subscripted 3-vector, including Imath::V3f. More...
 
template<typename V , OIIO_ENABLE_IF((has_subscript_N< V, value_t, 4 >::value||has_xyzw< V, value_t >::value))&&!std::is_same< V, vfloat4 >::value >
 vfloat4 (const V &v)
 
 operator simd_t () const
 Return the raw SIMD type. More...
 
simd_t simd () const
 
simd_tsimd ()
 
const value_tdata () const
 Return a pointer to the underlying scalar type. More...
 
value_tdata ()
 
 vfloat4 (const unsigned short *vals)
 Construct from a pointer to 4 unsigned short values. More...
 
 vfloat4 (const short *vals)
 Construct from a pointer to 4 short values. More...
 
 vfloat4 (const unsigned char *vals)
 Construct from a pointer to 4 unsigned char values. More...
 
 vfloat4 (const char *vals)
 Construct from a pointer to 4 char values. More...
 
const vfloat4operator= (float a)
 Assign a single value to all components. More...
 
const vfloat4operator= (vfloat4 other)
 Assign a vfloat4. More...
 
void clear ()
 Set all components to 0.0. More...
 
template<typename V , OIIO_ENABLE_IF((has_subscript_N< V, value_t, 4 >::value||has_xyzw< V, value_t >::value)&&!std::is_same< V, vfloat4 >::value) >
const vfloat4operator= (const V &v)
 
template<typename V , OIIO_ENABLE_IF(has_subscript_N< V, value_t, 3 >::value &&!std::is_same< V, vfloat3 >::value) >
const vfloat4operator= (const V &v)
 
float operator[] (int i) const
 Component access (get) More...
 
floatoperator[] (int i)
 Component access (set) More...
 
void setcomp (int i, float value)
 Component access (set). More...
 
value_t x () const
 
value_t y () const
 
value_t z () const
 
value_t w () const
 
void set_x (value_t val)
 
void set_y (value_t val)
 
void set_z (value_t val)
 
void set_w (value_t val)
 
void load (float val)
 Helper: load a single value into all components. More...
 
void load (float a, float b, float c, float d=0.0f)
 Helper: load 3 or 4 values. (If 3 are supplied, the 4th will be 0.) More...
 
void load (const float *values)
 Load from an array of 4 values. More...
 
void load (const float *values, int n)
 
void load (const unsigned short *values)
 Load from an array of 4 unsigned short values, convert to float. More...
 
void load (const short *values)
 Load from an array of 4 short values, convert to float. More...
 
void load (const unsigned char *values)
 Load from an array of 4 unsigned char values, convert to float. More...
 
void load (const char *values)
 Load from an array of 4 char values, convert to float. More...
 
void load_pairs (const float *lo, const float *hi)
 
void store (float *values) const
 
void store (float *values, int n) const
 Store the first n values into memory. More...
 
void load_mask (int mask, const value_t *values)
 
void load_mask (const vbool_t &mask, const value_t *values)
 
void store_mask (int mask, value_t *values) const
 
void store_mask (const vbool_t &mask, value_t *values) const
 
template<int scale = 4>
void gather (const value_t *baseptr, const vint_t &vindex)
 Load values from addresses (char*)basepatr + vindex[i]*scale. More...
 
template<int scale = 4>
void gather_mask (const vbool_t &mask, const value_t *baseptr, const vint_t &vindex)
 Gather elements defined by the mask, leave others unchanged. More...
 
template<int scale = 4>
void gather_mask (int mask, const value_t *baseptr, const vint_t &vindex)
 
template<int scale = 4>
void scatter (value_t *baseptr, const vint_t &vindex) const
 Store values at addresses (char*)basepatr + vindex[i]*scale. More...
 
template<int scale = 4>
void scatter_mask (const vbool_t &mask, value_t *baseptr, const vint_t &vindex) const
 Scatter elements defined by the mask. More...
 
template<int scale = 4>
void scatter_mask (int mask, value_t *baseptr, const vint_t &vindex) const
 
const vfloat4operator+= (const vfloat4 &a)
 
vfloat4 operator- () const
 
const vfloat4operator-= (const vfloat4 &a)
 
const vfloat4operator*= (const vfloat4 &a)
 
const vfloat4operator*= (float val)
 
const vfloat4operator/= (const vfloat4 &a)
 
const vfloat4operator/= (float val)
 
vfloat4 xyz0 () const
 Return xyz components, plus 0 for w. More...
 
vfloat4 xyz1 () const
 Return xyz components, plus 1 for w. More...
 
template<int scale>
OIIO_FORCEINLINE void gather (const value_t *baseptr, const vint_t &vindex)
 
template<int scale>
OIIO_FORCEINLINE void gather_mask (const vbool_t &mask, const value_t *baseptr, const vint_t &vindex)
 
template<int scale>
OIIO_FORCEINLINE void scatter (value_t *baseptr, const vint_t &vindex) const
 
template<int scale>
OIIO_FORCEINLINE void scatter_mask (const vbool_t &mask, value_t *baseptr, const vint_t &vindex) const
 

Static Public Member Functions

static const char * type_name ()
 
static constexpr size_t size () noexcept
 
static const vfloat4 Zero ()
 Return a vfloat4 with all components set to 0.0. More...
 
static const vfloat4 One ()
 Return a vfloat4 with all components set to 1.0. More...
 
static const vfloat4 Iota (float start=0.0f, float step=1.0f)
 

Protected Attributes

union {
   simd_t   m_simd
 
   value_t   m_val [paddedelements]
 
}; 
 

Friends

vfloat4 operator+ (const vfloat4 &a, const vfloat4 &b)
 
vfloat4 operator- (const vfloat4 &a, const vfloat4 &b)
 
vfloat4 operator* (const vfloat4 &a, const vfloat4 &b)
 
vfloat4 operator* (const vfloat4 &a, float b)
 
vfloat4 operator* (float a, const vfloat4 &b)
 
vfloat4 operator/ (const vfloat4 &a, const vfloat4 &b)
 
vbool4 operator== (const vfloat4 &a, const vfloat4 &b)
 
vbool4 operator!= (const vfloat4 &a, const vfloat4 &b)
 
vbool4 operator< (const vfloat4 &a, const vfloat4 &b)
 
vbool4 operator> (const vfloat4 &a, const vfloat4 &b)
 
vbool4 operator>= (const vfloat4 &a, const vfloat4 &b)
 
vbool4 operator<= (const vfloat4 &a, const vfloat4 &b)
 
vfloat4 AxyBxy (const vfloat4 &a, const vfloat4 &b)
 
vfloat4 AxBxAyBy (const vfloat4 &a, const vfloat4 &b)
 
std::ostream & operator<< (std::ostream &cout, const vfloat4 &val)
 Stream output. More...
 

Detailed Description

Floating point 4-vector, accelerated by SIMD instructions when available.

Definition at line 1860 of file simd.h.

Member Typedef Documentation

Definition at line 1874 of file simd.h.

Definition at line 1872 of file simd.h.

the native SIMD type used

Definition at line 1867 of file simd.h.

Underlying equivalent scalar value type.

Definition at line 1863 of file simd.h.

SIMD bool type.

Definition at line 1870 of file simd.h.

SIMD int type.

Definition at line 1868 of file simd.h.

SIMD int type.

Definition at line 1869 of file simd.h.

Member Enumeration Documentation

anonymous enum
Enumerator
elements 

Definition at line 1864 of file simd.h.

anonymous enum
Enumerator
paddedelements 

Definition at line 1865 of file simd.h.

anonymous enum
Enumerator
bits 

Definition at line 1866 of file simd.h.

Constructor & Destructor Documentation

simd::vfloat4::vfloat4 ( )
inline

Default constructor (contents undefined)

Definition at line 1878 of file simd.h.

simd::vfloat4::vfloat4 ( float  a)
inline

Construct from a single value (store it in all slots)

Definition at line 1881 of file simd.h.

simd::vfloat4::vfloat4 ( float  a,
float  b,
float  c,
float  d = 0.0f 
)
inline

Construct from 3 or 4 values.

Definition at line 1884 of file simd.h.

simd::vfloat4::vfloat4 ( const float f)
inline

Construct from a pointer to 4 values.

Definition at line 1887 of file simd.h.

simd::vfloat4::vfloat4 ( const vfloat4 other)
inline

Copy construct from another vfloat4.

Definition at line 1890 of file simd.h.

OIIO_FORCEINLINE simd::vfloat4::vfloat4 ( const vint4 ival)
explicit

Construct from an vint4 (promoting all components to float)

Definition at line 6693 of file simd.h.

simd::vfloat4::vfloat4 ( const simd_t m)
inline

Construct from the underlying SIMD type.

Definition at line 1896 of file simd.h.

template<typename V , OIIO_ENABLE_IF(has_subscript_N< V, value_t, 3 >::value &&!std::is_same< V, vfloat3 >::value) >
simd::vfloat4::vfloat4 ( const V &  v)
inlineexplicit

Construct from a generic subscripted 3-vector, including Imath::V3f.

Definition at line 1901 of file simd.h.

template<typename V , OIIO_ENABLE_IF((has_subscript_N< V, value_t, 4 >::value||has_xyzw< V, value_t >::value))&&!std::is_same< V, vfloat4 >::value >
simd::vfloat4::vfloat4 ( const V &  v)
inlineexplicit

Construct from a generic subscripted or xyzw 4-vector, including Imath::V4f.

Definition at line 1908 of file simd.h.

simd::vfloat4::vfloat4 ( const unsigned short *  vals)
inlineexplicit

Construct from a pointer to 4 unsigned short values.

Definition at line 1928 of file simd.h.

simd::vfloat4::vfloat4 ( const short *  vals)
inlineexplicit

Construct from a pointer to 4 short values.

Definition at line 1931 of file simd.h.

simd::vfloat4::vfloat4 ( const unsigned char *  vals)
inlineexplicit

Construct from a pointer to 4 unsigned char values.

Definition at line 1934 of file simd.h.

simd::vfloat4::vfloat4 ( const char *  vals)
inlineexplicit

Construct from a pointer to 4 char values.

Definition at line 1937 of file simd.h.

Member Function Documentation

OIIO_FORCEINLINE void simd::vfloat4::clear ( )

Set all components to 0.0.

Definition at line 6721 of file simd.h.

const value_t* simd::vfloat4::data ( ) const
inline

Return a pointer to the underlying scalar type.

Definition at line 1916 of file simd.h.

value_t* simd::vfloat4::data ( )
inline

Definition at line 1917 of file simd.h.

template<int scale = 4>
void simd::vfloat4::gather ( const value_t baseptr,
const vint_t vindex 
)

Load values from addresses (char*)basepatr + vindex[i]*scale.

template<int scale>
OIIO_FORCEINLINE void simd::vfloat4::gather ( const value_t baseptr,
const vint_t vindex 
)

Definition at line 7055 of file simd.h.

template<int scale = 4>
void simd::vfloat4::gather_mask ( const vbool_t mask,
const value_t baseptr,
const vint_t vindex 
)

Gather elements defined by the mask, leave others unchanged.

template<int scale = 4>
void simd::vfloat4::gather_mask ( int  mask,
const value_t baseptr,
const vint_t vindex 
)
template<int scale>
OIIO_FORCEINLINE void simd::vfloat4::gather_mask ( const vbool_t mask,
const value_t baseptr,
const vint_t vindex 
)

Definition at line 7066 of file simd.h.

OIIO_FORCEINLINE const vfloat4 simd::vfloat4::Iota ( float  start = 0.0f,
float  step = 1.0f 
)
static

Return a vfloat4 with incremented components (e.g., 0.0,1.0,2.0,3.0). Optional argument can give a non-zero starting point and non-1 step.

Definition at line 6716 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load ( float  val)

Helper: load a single value into all components.

Definition at line 6741 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load ( float  a,
float  b,
float  c,
float  d = 0.0f 
)

Helper: load 3 or 4 values. (If 3 are supplied, the 4th will be 0.)

Definition at line 6751 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load ( const float values)

Load from an array of 4 values.

Definition at line 6766 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load ( const float values,
int  n 
)

Load from a partial array of <=4 values. Unassigned values are undefined.

Definition at line 6777 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load ( const unsigned short *  values)

Load from an array of 4 unsigned short values, convert to float.

Definition at line 6830 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load ( const short *  values)

Load from an array of 4 short values, convert to float.

Definition at line 6841 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load ( const unsigned char *  values)

Load from an array of 4 unsigned char values, convert to float.

Definition at line 6850 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load ( const char *  values)

Load from an array of 4 char values, convert to float.

Definition at line 6859 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load_mask ( int  mask,
const value_t values 
)

Masked load – read from values[] where mask is 1, load zero where mask is 0.

Definition at line 7009 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load_mask ( const vbool_t mask,
const value_t values 
)

Definition at line 7020 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::load_pairs ( const float lo,
const float hi 
)

Load the first 2 elements from lo[0..1] and the second two elements from hi[0..1].

Definition at line 6911 of file simd.h.

OIIO_FORCEINLINE const vfloat4 simd::vfloat4::One ( )
static

Return a vfloat4 with all components set to 1.0.

Definition at line 6712 of file simd.h.

simd::vfloat4::operator simd_t ( ) const
inline

Return the raw SIMD type.

Definition at line 1911 of file simd.h.

OIIO_FORCEINLINE const vfloat4 & simd::vfloat4::operator*= ( const vfloat4 a)

Definition at line 7177 of file simd.h.

OIIO_FORCEINLINE const vfloat4 & simd::vfloat4::operator*= ( float  val)

Definition at line 7188 of file simd.h.

OIIO_FORCEINLINE const vfloat4 & simd::vfloat4::operator+= ( const vfloat4 a)

Definition at line 7111 of file simd.h.

OIIO_FORCEINLINE vfloat4 simd::vfloat4::operator- ( ) const

Definition at line 7122 of file simd.h.

OIIO_FORCEINLINE const vfloat4 & simd::vfloat4::operator-= ( const vfloat4 a)

Definition at line 7142 of file simd.h.

OIIO_FORCEINLINE const vfloat4 & simd::vfloat4::operator/= ( const vfloat4 a)

Definition at line 7209 of file simd.h.

OIIO_FORCEINLINE const vfloat4 & simd::vfloat4::operator/= ( float  val)

Definition at line 7220 of file simd.h.

const vfloat4& simd::vfloat4::operator= ( float  a)
inline

Assign a single value to all components.

Definition at line 1945 of file simd.h.

const vfloat4& simd::vfloat4::operator= ( vfloat4  other)
inline

Assign a vfloat4.

Definition at line 1948 of file simd.h.

template<typename V , OIIO_ENABLE_IF((has_subscript_N< V, value_t, 4 >::value||has_xyzw< V, value_t >::value)&&!std::is_same< V, vfloat4 >::value) >
const vfloat4& simd::vfloat4::operator= ( const V &  v)
inline

Assign from a generic subscripted or xyzw 4-vector, including an Imath::V4f.

Definition at line 1971 of file simd.h.

template<typename V , OIIO_ENABLE_IF(has_subscript_N< V, value_t, 3 >::value &&!std::is_same< V, vfloat3 >::value) >
const vfloat4& simd::vfloat4::operator= ( const V &  v)
inline

Assign from a generic subscripted 3-vector, including an Imath::V3f.

Definition at line 1980 of file simd.h.

OIIO_FORCEINLINE float simd::vfloat4::operator[] ( int  i) const

Component access (get)

Definition at line 6735 of file simd.h.

OIIO_FORCEINLINE float & simd::vfloat4::operator[] ( int  i)

Component access (set)

Definition at line 6730 of file simd.h.

template<int scale = 4>
void simd::vfloat4::scatter ( value_t baseptr,
const vint_t vindex 
) const

Store values at addresses (char*)basepatr + vindex[i]*scale.

template<int scale>
OIIO_FORCEINLINE void simd::vfloat4::scatter ( value_t baseptr,
const vint_t vindex 
) const

Definition at line 7077 of file simd.h.

template<int scale = 4>
void simd::vfloat4::scatter_mask ( const vbool_t mask,
value_t baseptr,
const vint_t vindex 
) const

Scatter elements defined by the mask.

template<int scale = 4>
void simd::vfloat4::scatter_mask ( int  mask,
value_t baseptr,
const vint_t vindex 
) const
template<int scale>
OIIO_FORCEINLINE void simd::vfloat4::scatter_mask ( const vbool_t mask,
value_t baseptr,
const vint_t vindex 
) const

Definition at line 7089 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::set_w ( value_t  val)

Definition at line 7426 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::set_x ( value_t  val)

Definition at line 7423 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::set_y ( value_t  val)

Definition at line 7424 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::set_z ( value_t  val)

Definition at line 7425 of file simd.h.

void simd::vfloat4::setcomp ( int  i,
float  value 
)

Component access (set).

simd_t simd::vfloat4::simd ( ) const
inline

Definition at line 1912 of file simd.h.

simd_t& simd::vfloat4::simd ( )
inline

Definition at line 1913 of file simd.h.

static constexpr size_t simd::vfloat4::size ( void  )
inlinestaticnoexcept

Definition at line 1875 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::store ( float values) const

Definition at line 6923 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::store ( float values,
int  n 
) const

Store the first n values into memory.

Definition at line 6936 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::store_mask ( int  mask,
value_t values 
) const

Masked store – write to values[] where mask is enabled, don't touch values[] where it's not.

Definition at line 7031 of file simd.h.

OIIO_FORCEINLINE void simd::vfloat4::store_mask ( const vbool_t mask,
value_t values 
) const

Definition at line 7042 of file simd.h.

static const char* simd::vfloat4::type_name ( )
inlinestatic

Definition at line 1862 of file simd.h.

OIIO_FORCEINLINE float simd::vfloat4::w ( ) const

Definition at line 7422 of file simd.h.

OIIO_FORCEINLINE float simd::vfloat4::x ( ) const

Definition at line 7419 of file simd.h.

OIIO_FORCEINLINE vfloat4 simd::vfloat4::xyz0 ( ) const

Return xyz components, plus 0 for w.

Definition at line 7308 of file simd.h.

OIIO_FORCEINLINE vfloat4 simd::vfloat4::xyz1 ( ) const

Return xyz components, plus 1 for w.

Definition at line 7312 of file simd.h.

OIIO_FORCEINLINE float simd::vfloat4::y ( ) const

Definition at line 7420 of file simd.h.

OIIO_FORCEINLINE float simd::vfloat4::z ( ) const

Definition at line 7421 of file simd.h.

OIIO_FORCEINLINE const vfloat4 simd::vfloat4::Zero ( )
static

Return a vfloat4 with all components set to 0.0.

Definition at line 6704 of file simd.h.

Friends And Related Function Documentation

vfloat4 AxBxAyBy ( const vfloat4 a,
const vfloat4 b 
)
friend

Combine the first two components of A with the first two components of B, but interleaved.

Definition at line 7300 of file simd.h.

vfloat4 AxyBxy ( const vfloat4 a,
const vfloat4 b 
)
friend

Combine the first two components of A with the first two components of B.

Definition at line 7292 of file simd.h.

vbool4 operator!= ( const vfloat4 a,
const vfloat4 b 
)
friend

Definition at line 7241 of file simd.h.

vfloat4 operator* ( const vfloat4 a,
const vfloat4 b 
)
friend

Definition at line 7167 of file simd.h.

vfloat4 operator* ( const vfloat4 a,
float  b 
)
friend

Definition at line 7153 of file simd.h.

vfloat4 operator* ( float  a,
const vfloat4 b 
)
friend

Definition at line 7163 of file simd.h.

vfloat4 operator+ ( const vfloat4 a,
const vfloat4 b 
)
friend

Definition at line 7101 of file simd.h.

vfloat4 operator- ( const vfloat4 a,
const vfloat4 b 
)
friend

Definition at line 7132 of file simd.h.

vfloat4 operator/ ( const vfloat4 a,
const vfloat4 b 
)
friend

Definition at line 7199 of file simd.h.

vbool4 operator< ( const vfloat4 a,
const vfloat4 b 
)
friend

Definition at line 7252 of file simd.h.

std::ostream& operator<< ( std::ostream &  cout,
const vfloat4 val 
)
friend

Stream output.

Definition at line 7316 of file simd.h.

vbool4 operator<= ( const vfloat4 a,
const vfloat4 b 
)
friend

Definition at line 7282 of file simd.h.

vbool4 operator== ( const vfloat4 a,
const vfloat4 b 
)
friend

Definition at line 7231 of file simd.h.

vbool4 operator> ( const vfloat4 a,
const vfloat4 b 
)
friend

Definition at line 7262 of file simd.h.

vbool4 operator>= ( const vfloat4 a,
const vfloat4 b 
)
friend

Definition at line 7272 of file simd.h.

Member Data Documentation

union { ... }
simd_t simd::vfloat4::m_simd

Definition at line 2118 of file simd.h.

value_t simd::vfloat4::m_val[paddedelements]

Definition at line 2119 of file simd.h.


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