Classes | Macros | Typedefs | Functions
Scalar.h File Reference
#include <math.h>
#include <stdlib.h>
#include <cstdlib>
#include <cfloat>
#include <float.h>
#include <assert.h>
Include dependency graph for Scalar.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tfTypedObject
 rudimentary class to provide type info More...
 

Macros

#define ATTRIBUTE_ALIGNED128(a)   a
 
#define ATTRIBUTE_ALIGNED16(a)   a
 
#define ATTRIBUTE_ALIGNED64(a)   a
 
#define TF_DECLARE_ALIGNED_ALLOCATOR()
 
#define TF_DECLARE_HANDLE(name)   typedef struct name##__ { int unused; } *name
 
#define TF_LARGE_FLOAT   1e30
 
#define tfAssert(x)
 
#define tfFsels(a, b, c)   (tfScalar)tfFsel(a,b,c)
 
#define tfFullAssert(x)
 
#define tfLikely(_c)   _c
 
#define tfRecipSqrt(x)   ((tfScalar)(tfScalar(1.0)/tfSqrt(tfScalar(x)))) /* reciprocal square root */
 
#define TFSIMD_2_PI   tfScalar(6.283185307179586232)
 
#define TFSIMD_DEGS_PER_RAD   (tfScalar(360.0) / TFSIMD_2_PI)
 
#define TFSIMD_EPSILON   DBL_EPSILON
 
#define TFSIMD_FORCE_INLINE   inline
 
#define TFSIMD_HALF_PI   (TFSIMD_2_PI * tfScalar(0.25))
 
#define TFSIMD_INFINITY   DBL_MAX
 
#define TFSIMD_PI   (TFSIMD_2_PI * tfScalar(0.5))
 
#define TFSIMD_RADS_PER_DEG   (TFSIMD_2_PI / tfScalar(360.0))
 
#define TFSIMDSQRT12   tfScalar(0.7071067811865475244008443621048490)
 
#define tfUnlikely(_c)   _c
 

Typedefs

typedef double tfScalar
 The tfScalar type abstracts floating point numbers, to easily switch between double and single floating point precision. More...
 

Functions

TFSIMD_FORCE_INLINE tfScalar tfAcos (tfScalar x)
 
TFSIMD_FORCE_INLINE tfScalar tfAsin (tfScalar x)
 
TFSIMD_FORCE_INLINE tfScalar tfAtan (tfScalar x)
 
TFSIMD_FORCE_INLINE tfScalar tfAtan2 (tfScalar x, tfScalar y)
 
TFSIMD_FORCE_INLINE tfScalar tfAtan2Fast (tfScalar y, tfScalar x)
 
TFSIMD_FORCE_INLINE tfScalar tfCos (tfScalar x)
 
TFSIMD_FORCE_INLINE tfScalar tfDegrees (tfScalar x)
 
TFSIMD_FORCE_INLINE bool tfEqual (tfScalar a, tfScalar eps)
 
TFSIMD_FORCE_INLINE tfScalar tfExp (tfScalar x)
 
TFSIMD_FORCE_INLINE tfScalar tfFabs (tfScalar x)
 
TFSIMD_FORCE_INLINE tfScalar tfFmod (tfScalar x, tfScalar y)
 
TFSIMD_FORCE_INLINE tfScalar tfFsel (tfScalar a, tfScalar b, tfScalar c)
 
TFSIMD_FORCE_INLINE bool tfFuzzyZero (tfScalar x)
 
TFSIMD_FORCE_INLINE bool tfGreaterEqual (tfScalar a, tfScalar eps)
 
TFSIMD_FORCE_INLINE int tfIsNegative (tfScalar x)
 
TFSIMD_FORCE_INLINE tfScalar tfLog (tfScalar x)
 
TFSIMD_FORCE_INLINE bool tfMachineIsLittleEndian ()
 
TFSIMD_FORCE_INLINE tfScalar tfNormalizeAngle (tfScalar angleInRadians)
 
TFSIMD_FORCE_INLINE tfScalar tfPow (tfScalar x, tfScalar y)
 
TFSIMD_FORCE_INLINE tfScalar tfRadians (tfScalar x)
 
TFSIMD_FORCE_INLINE unsigned tfSelect (unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero)
 
TFSIMD_FORCE_INLINE int tfSelect (unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero)
 
TFSIMD_FORCE_INLINE float tfSelect (unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero)
 
TFSIMD_FORCE_INLINE tfScalar tfSin (tfScalar x)
 
TFSIMD_FORCE_INLINE tfScalar tfSqrt (tfScalar x)
 
template<typename T >
TFSIMD_FORCE_INLINE void tfSwap (T &a, T &b)
 
TFSIMD_FORCE_INLINE unsigned tfSwapEndian (unsigned val)
 
TFSIMD_FORCE_INLINE unsigned short tfSwapEndian (unsigned short val)
 
TFSIMD_FORCE_INLINE unsigned tfSwapEndian (int val)
 
TFSIMD_FORCE_INLINE unsigned short tfSwapEndian (short val)
 
TFSIMD_FORCE_INLINE void tfSwapEndianDouble (double d, unsigned char *dst)
 
TFSIMD_FORCE_INLINE unsigned int tfSwapEndianFloat (float d)
 tfSwapFloat uses using char pointers to swap the endianness More...
 
TFSIMD_FORCE_INLINE tfScalar tfTan (tfScalar x)
 
TFSIMD_FORCE_INLINE double tfUnswapEndianDouble (const unsigned char *src)
 
TFSIMD_FORCE_INLINE float tfUnswapEndianFloat (unsigned int a)
 

Macro Definition Documentation

◆ ATTRIBUTE_ALIGNED128

#define ATTRIBUTE_ALIGNED128 (   a)    a

Definition at line 137 of file Scalar.h.

◆ ATTRIBUTE_ALIGNED16

#define ATTRIBUTE_ALIGNED16 (   a)    a
Todo:
: check out alignment methods for other platforms/compilers define ATTRIBUTE_ALIGNED16(a) a attribute ((aligned (16))) define ATTRIBUTE_ALIGNED64(a) a attribute ((aligned (64))) define ATTRIBUTE_ALIGNED128(a) a attribute ((aligned (128)))

Definition at line 135 of file Scalar.h.

◆ ATTRIBUTE_ALIGNED64

#define ATTRIBUTE_ALIGNED64 (   a)    a

Definition at line 136 of file Scalar.h.

◆ TF_DECLARE_ALIGNED_ALLOCATOR

#define TF_DECLARE_ALIGNED_ALLOCATOR ( )
Value:
TFSIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return tfAlignedAlloc(sizeInBytes,16); } \
TFSIMD_FORCE_INLINE void operator delete(void* ptr) { tfAlignedFree(ptr); } \
TFSIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \
TFSIMD_FORCE_INLINE void operator delete(void*, void*) { } \
TFSIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return tfAlignedAlloc(sizeInBytes,16); } \
TFSIMD_FORCE_INLINE void operator delete[](void* ptr) { tfAlignedFree(ptr); } \
TFSIMD_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \
TFSIMD_FORCE_INLINE void operator delete[](void*, void*) { } \
#define TFSIMD_FORCE_INLINE
Definition: Scalar.h:130

Definition at line 166 of file Scalar.h.

◆ TF_DECLARE_HANDLE

#define TF_DECLARE_HANDLE (   name)    typedef struct name##__ { int unused; } *name

Definition at line 240 of file Scalar.h.

◆ TF_LARGE_FLOAT

#define TF_LARGE_FLOAT   1e30

Definition at line 162 of file Scalar.h.

◆ tfAssert

#define tfAssert (   x)

Definition at line 145 of file Scalar.h.

◆ tfFsels

#define tfFsels (   a,
  b,
 
)    (tfScalar)tfFsel(a,b,c)

Definition at line 248 of file Scalar.h.

◆ tfFullAssert

#define tfFullAssert (   x)

Definition at line 149 of file Scalar.h.

◆ tfLikely

#define tfLikely (   _c)    _c

Definition at line 150 of file Scalar.h.

◆ tfRecipSqrt

#define tfRecipSqrt (   x)    ((tfScalar)(tfScalar(1.0)/tfSqrt(tfScalar(x)))) /* reciprocal square root */

Definition at line 201 of file Scalar.h.

◆ TFSIMD_2_PI

#define TFSIMD_2_PI   tfScalar(6.283185307179586232)

Definition at line 194 of file Scalar.h.

◆ TFSIMD_DEGS_PER_RAD

#define TFSIMD_DEGS_PER_RAD   (tfScalar(360.0) / TFSIMD_2_PI)

Definition at line 198 of file Scalar.h.

◆ TFSIMD_EPSILON

#define TFSIMD_EPSILON   DBL_EPSILON

Definition at line 204 of file Scalar.h.

◆ TFSIMD_FORCE_INLINE

#define TFSIMD_FORCE_INLINE   inline

Definition at line 130 of file Scalar.h.

◆ TFSIMD_HALF_PI

#define TFSIMD_HALF_PI   (TFSIMD_2_PI * tfScalar(0.25))

Definition at line 196 of file Scalar.h.

◆ TFSIMD_INFINITY

#define TFSIMD_INFINITY   DBL_MAX

Definition at line 205 of file Scalar.h.

◆ TFSIMD_PI

#define TFSIMD_PI   (TFSIMD_2_PI * tfScalar(0.5))

Definition at line 195 of file Scalar.h.

◆ TFSIMD_RADS_PER_DEG

#define TFSIMD_RADS_PER_DEG   (TFSIMD_2_PI / tfScalar(360.0))

Definition at line 197 of file Scalar.h.

◆ TFSIMDSQRT12

#define TFSIMDSQRT12   tfScalar(0.7071067811865475244008443621048490)

Definition at line 199 of file Scalar.h.

◆ tfUnlikely

#define tfUnlikely (   _c)    _c

Definition at line 151 of file Scalar.h.

Typedef Documentation

◆ tfScalar

typedef double tfScalar

The tfScalar type abstracts floating point numbers, to easily switch between double and single floating point precision.

Definition at line 160 of file Scalar.h.

Function Documentation

◆ tfAcos()

Definition at line 184 of file Scalar.h.

◆ tfAsin()

Definition at line 185 of file Scalar.h.

◆ tfAtan()

Definition at line 186 of file Scalar.h.

◆ tfAtan2()

Definition at line 187 of file Scalar.h.

◆ tfAtan2Fast()

TFSIMD_FORCE_INLINE tfScalar tfAtan2Fast ( tfScalar  y,
tfScalar  x 
)

Definition at line 207 of file Scalar.h.

◆ tfCos()

Definition at line 181 of file Scalar.h.

◆ tfDegrees()

Definition at line 238 of file Scalar.h.

◆ tfEqual()

TFSIMD_FORCE_INLINE bool tfEqual ( tfScalar  a,
tfScalar  eps 
)

Definition at line 225 of file Scalar.h.

◆ tfExp()

Definition at line 188 of file Scalar.h.

◆ tfFabs()

Definition at line 180 of file Scalar.h.

◆ tfFmod()

Definition at line 191 of file Scalar.h.

◆ tfFsel()

Definition at line 243 of file Scalar.h.

◆ tfFuzzyZero()

TFSIMD_FORCE_INLINE bool tfFuzzyZero ( tfScalar  x)

Definition at line 223 of file Scalar.h.

◆ tfGreaterEqual()

TFSIMD_FORCE_INLINE bool tfGreaterEqual ( tfScalar  a,
tfScalar  eps 
)

Definition at line 228 of file Scalar.h.

◆ tfIsNegative()

TFSIMD_FORCE_INLINE int tfIsNegative ( tfScalar  x)

Definition at line 233 of file Scalar.h.

◆ tfLog()

Definition at line 189 of file Scalar.h.

◆ tfMachineIsLittleEndian()

TFSIMD_FORCE_INLINE bool tfMachineIsLittleEndian ( )

Definition at line 251 of file Scalar.h.

◆ tfNormalizeAngle()

TFSIMD_FORCE_INLINE tfScalar tfNormalizeAngle ( tfScalar  angleInRadians)

Definition at line 389 of file Scalar.h.

◆ tfPow()

Definition at line 190 of file Scalar.h.

◆ tfRadians()

Definition at line 237 of file Scalar.h.

◆ tfSelect() [1/3]

TFSIMD_FORCE_INLINE unsigned tfSelect ( unsigned  condition,
unsigned  valueIfConditionNonZero,
unsigned  valueIfConditionZero 
)

tfSelect avoids branches, which makes performance much better for consoles like Playstation 3 and XBox 360 Thanks Phil Knight. See also http://www.cellperformance.com/articles/2006/04/more_techniques_for_eliminatin_1.html

Definition at line 265 of file Scalar.h.

◆ tfSelect() [2/3]

TFSIMD_FORCE_INLINE int tfSelect ( unsigned  condition,
int  valueIfConditionNonZero,
int  valueIfConditionZero 
)

Definition at line 275 of file Scalar.h.

◆ tfSelect() [3/3]

TFSIMD_FORCE_INLINE float tfSelect ( unsigned  condition,
float  valueIfConditionNonZero,
float  valueIfConditionZero 
)

Definition at line 281 of file Scalar.h.

◆ tfSin()

Definition at line 182 of file Scalar.h.

◆ tfSqrt()

Definition at line 179 of file Scalar.h.

◆ tfSwap()

template<typename T >
TFSIMD_FORCE_INLINE void tfSwap ( T &  a,
T &  b 
)

Definition at line 290 of file Scalar.h.

◆ tfSwapEndian() [1/4]

TFSIMD_FORCE_INLINE unsigned tfSwapEndian ( unsigned  val)

Definition at line 299 of file Scalar.h.

◆ tfSwapEndian() [2/4]

TFSIMD_FORCE_INLINE unsigned short tfSwapEndian ( unsigned short  val)

Definition at line 304 of file Scalar.h.

◆ tfSwapEndian() [3/4]

TFSIMD_FORCE_INLINE unsigned tfSwapEndian ( int  val)

Definition at line 309 of file Scalar.h.

◆ tfSwapEndian() [4/4]

TFSIMD_FORCE_INLINE unsigned short tfSwapEndian ( short  val)

Definition at line 314 of file Scalar.h.

◆ tfSwapEndianDouble()

TFSIMD_FORCE_INLINE void tfSwapEndianDouble ( double  d,
unsigned char *  dst 
)

Definition at line 355 of file Scalar.h.

◆ tfSwapEndianFloat()

TFSIMD_FORCE_INLINE unsigned int tfSwapEndianFloat ( float  d)

tfSwapFloat uses using char pointers to swap the endianness

tfSwapFloat/tfSwapDouble will NOT return a float, because the machine might 'correct' invalid floating point values Not all values of sign/exponent/mantissa are valid floating point numbers according to IEEE 754. When a floating point unit is faced with an invalid value, it may actually change the value, or worse, throw an exception. In most systems, running user mode code, you wouldn't get an exception, but instead the hardware/os/runtime will 'fix' the number for you. so instead of returning a float/double, we return integer/long long integer

Definition at line 325 of file Scalar.h.

◆ tfTan()

Definition at line 183 of file Scalar.h.

◆ tfUnswapEndianDouble()

TFSIMD_FORCE_INLINE double tfUnswapEndianDouble ( const unsigned char *  src)

Definition at line 371 of file Scalar.h.

◆ tfUnswapEndianFloat()

TFSIMD_FORCE_INLINE float tfUnswapEndianFloat ( unsigned int  a)

Definition at line 339 of file Scalar.h.



tf
Author(s): Tully Foote, Eitan Marder-Eppstein, Wim Meeussen
autogenerated on Mon Feb 28 2022 22:26:19