Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Static Public Member Functions | Friends | List of all members
om::math::SIMDArray< T, width > Class Template Reference

The prototype for the SIMDArray class for wide SIMD operations. More...

#include <omSIMDArray.h>

Public Member Functions

 SIMDArray ()
 Create a scalar with it's elements equal to zero. More...
 
 SIMDArray (T value)
 Create a scalar with it's elements equal to zero. More...
 
 SIMDArray (const T *array)
 Create a scalar with elements from the specified array. More...
 
const T * toArray () const
 Return an array representation of this scalar. More...
 
T & get (Index i)
 Get the element at the specified index in the scalar. More...
 
const T & get (Index i) const
 Get the element at the specified index in the scalar. More...
 
T & operator() (Index i)
 Get the element at the specified index in the scalar. More...
 
const T & operator() (Index i) const
 Get the element at the specified index in the scalar. More...
 
T & operator[] (Index i)
 Get the element at the specified index in the scalar. More...
 
const T & operator[] (Index i) const
 Get the element at the specified index in the scalar. More...
 
void set (Index i, T newX)
 Set the element at the specified index in the scalar. More...
 
sumScalar () const
 Return the horizontal sum of all components of this SIMD scalar. More...
 
SIMDArray operator- () const
 Negate every component of this scalar and return the result. More...
 
SIMDArray operator+ () const
 'Positivate' every component of this scalar, effectively returning a copy. More...
 
SIMDArray operator+ (const SIMDArray &scalar) const
 Add a scalar to this scalar and return the resulting scalar. More...
 
SIMDArray operator+ (const T &value) const
 Add a scalar value to each component of this scalar and return the resulting scalar. More...
 
SIMDArray operator- (const SIMDArray &scalar) const
 Subtract a scalar from this scalar and return the resulting scalar. More...
 
SIMDArray operator- (const T &value) const
 Subtract a scalar value from each component of this scalar and return the resulting scalar. More...
 
SIMDArray operator* (const SIMDArray &scalar) const
 Return the result of a component-wise scalar multiplication with this scalar. More...
 
SIMDArray operator* (const T &value) const
 Multiply a scalar value by each component of this scalar and return the resulting scalar. More...
 
SIMDArray operator/ (const T &value) const
 Divide each component of this scalar by a scalar value and return the resulting scalar. More...
 
SIMDArray operator/ (const SIMDArray &scalar) const
 Divide each component of this scalar by a scalar component and return the resulting scalar. More...
 
SIMDArrayoperator+= (const SIMDArray &v2)
 
SIMDArrayoperator+= (const T &value)
 
SIMDArrayoperator-= (const SIMDArray &v2)
 
SIMDArrayoperator-= (const T &value)
 
SIMDArrayoperator*= (const SIMDArray &scalar)
 
SIMDArrayoperator*= (const T &value)
 
SIMDArrayoperator/= (const SIMDArray &scalar)
 
SIMDArrayoperator/= (const T &value)
 

Static Public Member Functions

static Size getAlignment ()
 Return the alignment required in bytes for objects of this type. More...
 
static Size getWidth ()
 Get the width of this scalar (number of components it has). More...
 

Friends

template<typename U , Size dim>
SIMDArray< U, dim > operator+ (const U &value, const SIMDArray< T, dim > &scalar)
 
template<typename U , Size dim>
SIMDArray< U, dim > operator- (const U &value, const SIMDArray< T, dim > &scalar)
 
template<typename U , Size dim>
SIMDArray< U, dim > operator* (const U &value, const SIMDArray< T, dim > &scalar)
 
template<typename U , Size dim>
SIMDArray< U, dim > operator/ (const U &value, const SIMDArray< T, dim > &scalar)
 

Detailed Description

template<typename T, Size width>
class om::math::SIMDArray< T, width >

The prototype for the SIMDArray class for wide SIMD operations.

This class emulates aribitrary-width SIMD registers using an array of SIMD values which are all processed in a vector fashion similar to normal SIMD values.

This template prototype is a scalar implementation of basic SIMD functionality. Supported operations include all basic arithmetic operations (+, -, *, /, +=, -=, *=, /=) and functions that operate on SIMDArray instances to find the per-component result for abs(), min(), max(), and sqrt() operations.

This implementation is provided as a fallback for when SIMD instructions are not available and for completeness. On any given platform, specializations for this class/functions should be implemented which use real SIMD operations.

Constructor & Destructor Documentation

template<typename T, Size width>
om::math::SIMDArray< T, width >::SIMDArray ( )
inline

Create a scalar with it's elements equal to zero.

template<typename T, Size width>
om::math::SIMDArray< T, width >::SIMDArray ( value)
inline

Create a scalar with it's elements equal to zero.

template<typename T, Size width>
om::math::SIMDArray< T, width >::SIMDArray ( const T *  array)
inline

Create a scalar with elements from the specified array.

The array must be of length greater than or equal to the width of the scalar.

Member Function Documentation

template<typename T, Size width>
const T* om::math::SIMDArray< T, width >::toArray ( ) const
inline

Return an array representation of this scalar.

template<typename T, Size width>
T& om::math::SIMDArray< T, width >::get ( Index  i)
inline

Get the element at the specified index in the scalar.

template<typename T, Size width>
const T& om::math::SIMDArray< T, width >::get ( Index  i) const
inline

Get the element at the specified index in the scalar.

template<typename T, Size width>
T& om::math::SIMDArray< T, width >::operator() ( Index  i)
inline

Get the element at the specified index in the scalar.

template<typename T, Size width>
const T& om::math::SIMDArray< T, width >::operator() ( Index  i) const
inline

Get the element at the specified index in the scalar.

template<typename T, Size width>
T& om::math::SIMDArray< T, width >::operator[] ( Index  i)
inline

Get the element at the specified index in the scalar.

template<typename T, Size width>
const T& om::math::SIMDArray< T, width >::operator[] ( Index  i) const
inline

Get the element at the specified index in the scalar.

template<typename T, Size width>
void om::math::SIMDArray< T, width >::set ( Index  i,
newX 
)
inline

Set the element at the specified index in the scalar.

template<typename T, Size width>
T om::math::SIMDArray< T, width >::sumScalar ( ) const
inline

Return the horizontal sum of all components of this SIMD scalar.

template<typename T, Size width>
SIMDArray om::math::SIMDArray< T, width >::operator- ( ) const
inline

Negate every component of this scalar and return the result.

template<typename T, Size width>
SIMDArray om::math::SIMDArray< T, width >::operator+ ( ) const
inline

'Positivate' every component of this scalar, effectively returning a copy.

template<typename T, Size width>
SIMDArray om::math::SIMDArray< T, width >::operator+ ( const SIMDArray< T, width > &  scalar) const
inline

Add a scalar to this scalar and return the resulting scalar.

template<typename T, Size width>
SIMDArray om::math::SIMDArray< T, width >::operator+ ( const T &  value) const
inline

Add a scalar value to each component of this scalar and return the resulting scalar.

template<typename T, Size width>
SIMDArray om::math::SIMDArray< T, width >::operator- ( const SIMDArray< T, width > &  scalar) const
inline

Subtract a scalar from this scalar and return the resulting scalar.

template<typename T, Size width>
SIMDArray om::math::SIMDArray< T, width >::operator- ( const T &  value) const
inline

Subtract a scalar value from each component of this scalar and return the resulting scalar.

template<typename T, Size width>
SIMDArray om::math::SIMDArray< T, width >::operator* ( const SIMDArray< T, width > &  scalar) const
inline

Return the result of a component-wise scalar multiplication with this scalar.

template<typename T, Size width>
SIMDArray om::math::SIMDArray< T, width >::operator* ( const T &  value) const
inline

Multiply a scalar value by each component of this scalar and return the resulting scalar.

template<typename T, Size width>
SIMDArray om::math::SIMDArray< T, width >::operator/ ( const T &  value) const
inline

Divide each component of this scalar by a scalar value and return the resulting scalar.

template<typename T, Size width>
SIMDArray om::math::SIMDArray< T, width >::operator/ ( const SIMDArray< T, width > &  scalar) const
inline

Divide each component of this scalar by a scalar component and return the resulting scalar.

template<typename T, Size width>
SIMDArray& om::math::SIMDArray< T, width >::operator+= ( const SIMDArray< T, width > &  v2)
inline
template<typename T, Size width>
SIMDArray& om::math::SIMDArray< T, width >::operator+= ( const T &  value)
inline
template<typename T, Size width>
SIMDArray& om::math::SIMDArray< T, width >::operator-= ( const SIMDArray< T, width > &  v2)
inline
template<typename T, Size width>
SIMDArray& om::math::SIMDArray< T, width >::operator-= ( const T &  value)
inline
template<typename T, Size width>
SIMDArray& om::math::SIMDArray< T, width >::operator*= ( const SIMDArray< T, width > &  scalar)
inline
template<typename T, Size width>
SIMDArray& om::math::SIMDArray< T, width >::operator*= ( const T &  value)
inline
template<typename T, Size width>
SIMDArray& om::math::SIMDArray< T, width >::operator/= ( const SIMDArray< T, width > &  scalar)
inline
template<typename T, Size width>
SIMDArray& om::math::SIMDArray< T, width >::operator/= ( const T &  value)
inline
template<typename T, Size width>
static Size om::math::SIMDArray< T, width >::getAlignment ( )
inlinestatic

Return the alignment required in bytes for objects of this type.

For most SIMD types this value will be 16 bytes. If there is no alignment required, 0 is returned.

template<typename T, Size width>
static Size om::math::SIMDArray< T, width >::getWidth ( )
inlinestatic

Get the width of this scalar (number of components it has).

Friends And Related Function Documentation

template<typename T, Size width>
template<typename U , Size dim>
SIMDArray<U,dim> operator+ ( const U &  value,
const SIMDArray< T, dim > &  scalar 
)
friend
template<typename T, Size width>
template<typename U , Size dim>
SIMDArray<U,dim> operator- ( const U &  value,
const SIMDArray< T, dim > &  scalar 
)
friend
template<typename T, Size width>
template<typename U , Size dim>
SIMDArray<U,dim> operator* ( const U &  value,
const SIMDArray< T, dim > &  scalar 
)
friend
template<typename T, Size width>
template<typename U , Size dim>
SIMDArray<U,dim> operator/ ( const U &  value,
const SIMDArray< T, dim > &  scalar 
)
friend

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