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...
 
 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 Imath::V3f &v)
 Construct from a Imath::V3f. More...
 
const Imath::V3f & V3f () const
 Cast to a Imath::V3f. More...
 
 vfloat4 (const Imath::V4f &v)
 Construct from a Imath::V4f. More...
 
const Imath::V4f & V4f () const
 Cast to a Imath::V4f. More...
 
 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...
 
const vfloat4operator= (const Imath::V4f &v)
 Assign from a Imath::V4f. More...
 
const vfloat4operator= (const Imath::V3f &v)
 Assign from a Imath::V3f. More...
 
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 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 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 1789 of file simd.h.

Member Typedef Documentation

Definition at line 1803 of file simd.h.

Definition at line 1801 of file simd.h.

the native SIMD type used

Definition at line 1796 of file simd.h.

Underlying equivalent scalar value type.

Definition at line 1792 of file simd.h.

SIMD bool type.

Definition at line 1799 of file simd.h.

SIMD int type.

Definition at line 1797 of file simd.h.

SIMD int type.

Definition at line 1798 of file simd.h.

Member Enumeration Documentation

anonymous enum
Enumerator
elements 

Definition at line 1793 of file simd.h.

anonymous enum
Enumerator
paddedelements 

Definition at line 1794 of file simd.h.

anonymous enum
Enumerator
bits 

Definition at line 1795 of file simd.h.

Constructor & Destructor Documentation

simd::vfloat4::vfloat4 ( )
inline

Default constructor (contents undefined)

Definition at line 1806 of file simd.h.

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

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

Definition at line 1809 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 1812 of file simd.h.

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

Construct from a pointer to 4 values.

Definition at line 1815 of file simd.h.

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

Copy construct from another vfloat4.

Definition at line 1818 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 6526 of file simd.h.

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

Construct from the underlying SIMD type.

Definition at line 1824 of file simd.h.

simd::vfloat4::vfloat4 ( const Imath::V3f v)
inlineexplicit

Construct from a Imath::V3f.

Definition at line 1836 of file simd.h.

simd::vfloat4::vfloat4 ( const Imath::V4f v)
inlineexplicit

Construct from a Imath::V4f.

Definition at line 1842 of file simd.h.

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

Construct from a pointer to 4 unsigned short values.

Definition at line 1848 of file simd.h.

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

Construct from a pointer to 4 short values.

Definition at line 1851 of file simd.h.

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

Construct from a pointer to 4 unsigned char values.

Definition at line 1854 of file simd.h.

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

Construct from a pointer to 4 char values.

Definition at line 1857 of file simd.h.

Member Function Documentation

OIIO_FORCEINLINE void simd::vfloat4::clear ( )

Set all components to 0.0.

Definition at line 6554 of file simd.h.

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

Return a pointer to the underlying scalar type.

Definition at line 1832 of file simd.h.

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

Definition at line 1833 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 6868 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 6879 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 6549 of file simd.h.

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

Helper: load a single value into all components.

Definition at line 6583 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 6593 of file simd.h.

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

Load from an array of 4 values.

Definition at line 6608 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 6619 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 6666 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 6677 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 6686 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 6695 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 6822 of file simd.h.

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

Definition at line 6833 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 6545 of file simd.h.

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

Return the raw SIMD type.

Definition at line 1827 of file simd.h.

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

Definition at line 6990 of file simd.h.

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

Definition at line 7001 of file simd.h.

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

Definition at line 6924 of file simd.h.

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

Definition at line 6935 of file simd.h.

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

Definition at line 6955 of file simd.h.

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

Definition at line 7022 of file simd.h.

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

Definition at line 7033 of file simd.h.

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

Assign a single value to all components.

Definition at line 1865 of file simd.h.

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

Assign a vfloat4.

Definition at line 1868 of file simd.h.

OIIO_FORCEINLINE const vfloat4 & simd::vfloat4::operator= ( const Imath::V4f v)

Assign from a Imath::V4f.

Definition at line 6562 of file simd.h.

OIIO_FORCEINLINE const vfloat4 & simd::vfloat4::operator= ( const Imath::V3f v)

Assign from a Imath::V3f.

Definition at line 6567 of file simd.h.

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

Component access (get)

Definition at line 6577 of file simd.h.

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

Component access (set)

Definition at line 6572 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 6890 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 6902 of file simd.h.

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

Definition at line 7221 of file simd.h.

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

Definition at line 7218 of file simd.h.

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

Definition at line 7219 of file simd.h.

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

Definition at line 7220 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 1828 of file simd.h.

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

Definition at line 1829 of file simd.h.

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

Definition at line 6740 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 6753 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 6844 of file simd.h.

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

Definition at line 6855 of file simd.h.

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

Definition at line 1791 of file simd.h.

const Imath::V3f& simd::vfloat4::V3f ( ) const
inline

Cast to a Imath::V3f.

Definition at line 1839 of file simd.h.

const Imath::V4f& simd::vfloat4::V4f ( ) const
inline

Cast to a Imath::V4f.

Definition at line 1845 of file simd.h.

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

Definition at line 7217 of file simd.h.

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

Definition at line 7214 of file simd.h.

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

Return xyz components, plus 0 for w.

Definition at line 7121 of file simd.h.

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

Return xyz components, plus 1 for w.

Definition at line 7125 of file simd.h.

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

Definition at line 7215 of file simd.h.

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

Definition at line 7216 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 6537 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 7113 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 7105 of file simd.h.

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

Definition at line 7054 of file simd.h.

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

Definition at line 6980 of file simd.h.

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

Definition at line 6966 of file simd.h.

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

Definition at line 6976 of file simd.h.

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

Definition at line 6914 of file simd.h.

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

Definition at line 6945 of file simd.h.

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

Definition at line 7012 of file simd.h.

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

Definition at line 7065 of file simd.h.

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

Stream output.

Definition at line 7129 of file simd.h.

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

Definition at line 7095 of file simd.h.

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

Definition at line 7044 of file simd.h.

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

Definition at line 7075 of file simd.h.

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

Definition at line 7085 of file simd.h.

Member Data Documentation

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

Definition at line 2021 of file simd.h.

value_t simd::vfloat4::m_val[paddedelements]

Definition at line 2022 of file simd.h.


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