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

#include <simd.h>

+ Inheritance diagram for simd::vfloat3:

Public Types

enum  { elements = 3 }
 
enum  { paddedelements = 4 }
 
- Public Types inherited from simd::vfloat4
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

 vfloat3 ()
 Default constructor (contents undefined) More...
 
 vfloat3 (float a)
 Construct from a single value (store it in all slots) More...
 
 vfloat3 (float a, float b, float c)
 Construct from 3 values. More...
 
 vfloat3 (const float *f)
 Construct from a pointer to 3 values. More...
 
template<typename V , OIIO_ENABLE_IF(has_xyz< V, float >::value) >
 vfloat3 (const V &v)
 
template<typename V , OIIO_ENABLE_IF(has_subscript_N< V, float, 3 >::value &&!has_xyz< V, float >::value) >
 vfloat3 (const V &v)
 
 vfloat3 (const vfloat3 &other)
 Copy construct from another vfloat3. More...
 
 vfloat3 (const vfloat4 &other)
 
 vfloat3 (const unsigned short *vals)
 Construct from a pointer to 4 unsigned short values. More...
 
 vfloat3 (const short *vals)
 Construct from a pointer to 4 short values. More...
 
 vfloat3 (const unsigned char *vals)
 Construct from a pointer to 4 unsigned char values. More...
 
 vfloat3 (const char *vals)
 Construct from a pointer to 4 char values. More...
 
const vfloat3operator= (float a)
 Assign a single value to all components. More...
 
void load (float val)
 Helper: load a single value into all components. More...
 
void load (const float *values)
 Load from an array of 4 values. More...
 
void load (const float *values, int n)
 Load from an array of 4 values. More...
 
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
 
template<typename V , OIIO_ENABLE_IF((has_subscript_N< V, value_t, 3 >::value||has_xyzw< V, value_t >::value)&&!std::is_same< V, vfloat3 >::value) >
void store (V &vec) const
 Store into a generic subscripted or xyz 3-vector, including Imath::V3f. More...
 
const vfloat3operator+= (const vfloat3 &a)
 
vfloat3 operator- () const
 
const vfloat3operator-= (const vfloat3 &a)
 
const vfloat3operator*= (const vfloat3 &a)
 
const vfloat3operator*= (float a)
 
const vfloat3operator/= (const vfloat3 &a)
 
const vfloat3operator/= (float a)
 
float length2 () const
 Square of the length of the vector. More...
 
float length () const
 Length of the vector. More...
 
vfloat3 normalized () const
 Return a normalized version of the vector. More...
 
vfloat3 normalized_fast () const
 Return a fast, approximate normalized version of the vector. More...
 
void normalize ()
 Normalize in place. More...
 
- Public Member Functions inherited from simd::vfloat4
 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 vfloat3 Zero ()
 Return a vfloat3 with all components set to 0.0. More...
 
static const vfloat3 One ()
 Return a vfloat3 with all components set to 1.0. More...
 
static const vfloat3 Iota (float start=0.0f, float step=1.0f)
 
- Static Public Member Functions inherited from simd::vfloat4
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)
 

Friends

vfloat3 operator+ (const vfloat3 &a, const vfloat3 &b)
 
vfloat3 operator- (const vfloat3 &a, const vfloat3 &b)
 
vfloat3 operator* (const vfloat3 &a, const vfloat3 &b)
 
vfloat3 operator* (const vfloat3 &a, float b)
 
vfloat3 operator* (float a, const vfloat3 &b)
 
vfloat3 operator/ (const vfloat3 &a, const vfloat3 &b)
 
std::ostream & operator<< (std::ostream &cout, const vfloat3 &val)
 Stream output. More...
 

Additional Inherited Members

- Protected Attributes inherited from simd::vfloat4
union {
   simd_t   m_simd
 
   value_t   m_val [paddedelements]
 
}; 
 

Detailed Description

Floating point 3-vector, aligned to be internally identical to a vfloat4. The way it differs from vfloat4 is that all of he load functions only load three values, and all the stores only store 3 values. The vast majority of ops just fall back to the vfloat4 version, and so will operate on the 4th component, but we won't care about that results.

Definition at line 2251 of file simd.h.

Member Enumeration Documentation

anonymous enum
Enumerator
elements 

Definition at line 2254 of file simd.h.

anonymous enum
Enumerator
paddedelements 

Definition at line 2255 of file simd.h.

Constructor & Destructor Documentation

simd::vfloat3::vfloat3 ( )
inline

Default constructor (contents undefined)

Definition at line 2259 of file simd.h.

simd::vfloat3::vfloat3 ( float  a)
inline

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

Definition at line 2262 of file simd.h.

simd::vfloat3::vfloat3 ( float  a,
float  b,
float  c 
)
inline

Construct from 3 values.

Definition at line 2265 of file simd.h.

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

Construct from a pointer to 3 values.

Definition at line 2268 of file simd.h.

template<typename V , OIIO_ENABLE_IF(has_xyz< V, float >::value) >
simd::vfloat3::vfloat3 ( const V &  v)
inline

Construct from something that looks like a generic 3-vector class, having .x, .y, .z float elements and nothing more. This should be able to capture from an Imath::V3f or an OIIO::V3fParam.

Definition at line 2274 of file simd.h.

template<typename V , OIIO_ENABLE_IF(has_subscript_N< V, float, 3 >::value &&!has_xyz< V, float >::value) >
simd::vfloat3::vfloat3 ( const V &  v)
inline

Construct from something that looks like a generic 3-vector class, having an operator[] that returns a float and is the size of 3 floats.

Definition at line 2280 of file simd.h.

OIIO_FORCEINLINE simd::vfloat3::vfloat3 ( const vfloat3 other)

Copy construct from another vfloat3.

Definition at line 8082 of file simd.h.

OIIO_FORCEINLINE simd::vfloat3::vfloat3 ( const vfloat4 other)
explicit

Construct from a vfloat4. Note: it will not zero out the internal 4th component, but rather accept on faith that the vfloat4 you are giving it is a valid vfloat3. Be careful!

Definition at line 8090 of file simd.h.

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

Construct from a pointer to 4 unsigned short values.

Definition at line 2303 of file simd.h.

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

Construct from a pointer to 4 short values.

Definition at line 2306 of file simd.h.

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

Construct from a pointer to 4 unsigned char values.

Definition at line 2309 of file simd.h.

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

Construct from a pointer to 4 char values.

Definition at line 2312 of file simd.h.

Member Function Documentation

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

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

Definition at line 8102 of file simd.h.

OIIO_FORCEINLINE float simd::vfloat3::length ( void  ) const

Length of the vector.

Definition at line 8305 of file simd.h.

OIIO_FORCEINLINE float simd::vfloat3::length2 ( ) const

Square of the length of the vector.

Definition at line 8299 of file simd.h.

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

Helper: load a single value into all components.

Definition at line 8107 of file simd.h.

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

Load from an array of 4 values.

Definition at line 8109 of file simd.h.

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

Load from an array of 4 values.

Definition at line 8111 of file simd.h.

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

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

Definition at line 8115 of file simd.h.

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

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

Definition at line 8119 of file simd.h.

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

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

Definition at line 8123 of file simd.h.

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

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

Definition at line 8127 of file simd.h.

void simd::vfloat3::normalize ( )
inline

Normalize in place.

Definition at line 2399 of file simd.h.

OIIO_FORCEINLINE vfloat3 simd::vfloat3::normalized ( ) const

Return a normalized version of the vector.

Definition at line 8311 of file simd.h.

OIIO_FORCEINLINE vfloat3 simd::vfloat3::normalized_fast ( ) const

Return a fast, approximate normalized version of the vector.

Definition at line 8323 of file simd.h.

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

Return a vfloat3 with all components set to 1.0.

Definition at line 8100 of file simd.h.

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

Definition at line 8184 of file simd.h.

OIIO_FORCEINLINE const vfloat3 & simd::vfloat3::operator*= ( float  a)

Definition at line 8188 of file simd.h.

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

Definition at line 8156 of file simd.h.

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

Definition at line 8160 of file simd.h.

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

Definition at line 8168 of file simd.h.

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

Definition at line 8196 of file simd.h.

OIIO_FORCEINLINE const vfloat3 & simd::vfloat3::operator/= ( float  a)

Definition at line 8200 of file simd.h.

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

Assign a single value to all components.

Definition at line 2320 of file simd.h.

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

Definition at line 2256 of file simd.h.

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

Definition at line 8137 of file simd.h.

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

Definition at line 8141 of file simd.h.

template<typename V , OIIO_ENABLE_IF((has_subscript_N< V, value_t, 3 >::value||has_xyzw< V, value_t >::value)&&!std::is_same< V, vfloat3 >::value) >
void simd::vfloat3::store ( V &  vec) const
inline

Store into a generic subscripted or xyz 3-vector, including Imath::V3f.

Definition at line 2370 of file simd.h.

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

Definition at line 2253 of file simd.h.

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

Return a vfloat3 with all components set to 0.0.

Definition at line 8098 of file simd.h.

Friends And Related Function Documentation

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

Definition at line 8172 of file simd.h.

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

Definition at line 8176 of file simd.h.

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

Definition at line 8180 of file simd.h.

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

Definition at line 8152 of file simd.h.

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

Definition at line 8164 of file simd.h.

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

Definition at line 8192 of file simd.h.

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

Stream output.

Definition at line 8205 of file simd.h.


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