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
 
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...
 
float & operator[] (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 bool_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 bool_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 bool_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 bool_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, 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 1775 of file simd.h.

Member Typedef Documentation

Definition at line 1787 of file simd.h.

Definition at line 1786 of file simd.h.

the native SIMD type used

Definition at line 1782 of file simd.h.

typedef float simd::vfloat4::value_t

Underlying equivalent scalar value type.

Definition at line 1778 of file simd.h.

SIMD bool type.

Definition at line 1785 of file simd.h.

SIMD int type.

Definition at line 1783 of file simd.h.

SIMD int type.

Definition at line 1784 of file simd.h.

Member Enumeration Documentation

anonymous enum
Enumerator
elements 

Definition at line 1779 of file simd.h.

anonymous enum
Enumerator
paddedelements 

Definition at line 1780 of file simd.h.

anonymous enum
Enumerator
bits 

Definition at line 1781 of file simd.h.

Constructor & Destructor Documentation

simd::vfloat4::vfloat4 ( )
inline

Default constructor (contents undefined)

Definition at line 1790 of file simd.h.

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

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

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

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

Construct from a pointer to 4 values.

Definition at line 1799 of file simd.h.

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

Copy construct from another vfloat4.

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

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

Construct from the underlying SIMD type.

Definition at line 1808 of file simd.h.

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

Construct from a Imath::V3f.

Definition at line 1819 of file simd.h.

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

Construct from a Imath::V4f.

Definition at line 1825 of file simd.h.

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

Construct from a pointer to 4 unsigned short values.

Definition at line 1831 of file simd.h.

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

Construct from a pointer to 4 short values.

Definition at line 1834 of file simd.h.

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

Construct from a pointer to 4 unsigned char values.

Definition at line 1837 of file simd.h.

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

Construct from a pointer to 4 char values.

Definition at line 1840 of file simd.h.

Member Function Documentation

OIIO_FORCEINLINE void simd::vfloat4::clear ( )

Set all components to 0.0.

Definition at line 6343 of file simd.h.

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

Return a pointer to the underlying scalar type.

Definition at line 1815 of file simd.h.

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

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

template<int scale = 4>
void simd::vfloat4::gather_mask ( const bool_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 bool_t mask,
const value_t baseptr,
const vint_t vindex 
)

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

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

Helper: load a single value into all components.

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

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

Load from an array of 4 values.

Definition at line 6397 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 6408 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 6455 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 6466 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 6475 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 6484 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 6611 of file simd.h.

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

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

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

Return the raw SIMD type.

Definition at line 1811 of file simd.h.

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

Definition at line 6765 of file simd.h.

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

Definition at line 6776 of file simd.h.

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

Definition at line 6713 of file simd.h.

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

Definition at line 6724 of file simd.h.

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

Definition at line 6744 of file simd.h.

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

Definition at line 6795 of file simd.h.

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

Definition at line 6804 of file simd.h.

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

Assign a single value to all components.

Definition at line 1848 of file simd.h.

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

Assign a vfloat4.

Definition at line 1851 of file simd.h.

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

Assign from a Imath::V4f.

Definition at line 6351 of file simd.h.

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

Assign from a Imath::V3f.

Definition at line 6356 of file simd.h.

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

Component access (get)

Definition at line 6366 of file simd.h.

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

Component access (set)

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

template<int scale = 4>
void simd::vfloat4::scatter_mask ( const bool_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 bool_t mask,
value_t baseptr,
const vint_t vindex 
) const

Definition at line 6691 of file simd.h.

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

Definition at line 6977 of file simd.h.

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

Definition at line 6974 of file simd.h.

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

Definition at line 6975 of file simd.h.

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

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

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

Definition at line 6529 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 6542 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 6633 of file simd.h.

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

Definition at line 6644 of file simd.h.

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

Definition at line 1777 of file simd.h.

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

Cast to a Imath::V3f.

Definition at line 1822 of file simd.h.

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

Cast to a Imath::V4f.

Definition at line 1828 of file simd.h.

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

Definition at line 6973 of file simd.h.

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

Definition at line 6970 of file simd.h.

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

Return xyz components, plus 0 for w.

Definition at line 6877 of file simd.h.

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

Return xyz components, plus 1 for w.

Definition at line 6881 of file simd.h.

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

Definition at line 6971 of file simd.h.

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

Definition at line 6972 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 6326 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 6869 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 6861 of file simd.h.

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

Definition at line 6821 of file simd.h.

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

Definition at line 6755 of file simd.h.

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

Definition at line 6703 of file simd.h.

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

Definition at line 6734 of file simd.h.

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

Definition at line 6787 of file simd.h.

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

Definition at line 6829 of file simd.h.

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

Stream output.

Definition at line 6885 of file simd.h.

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

Definition at line 6853 of file simd.h.

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

Definition at line 6813 of file simd.h.

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

Definition at line 6837 of file simd.h.

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

Definition at line 6845 of file simd.h.

Member Data Documentation

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

Definition at line 2002 of file simd.h.

value_t simd::vfloat4::m_val[paddedelements]

Definition at line 2003 of file simd.h.


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