#include <math.h>
#include <stdlib.h>
#include <cstdlib>
#include <cfloat>
#include <float.h>
#include <assert.h>
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... | |
#define ATTRIBUTE_ALIGNED16 | ( | a | ) | a |
#define TF_DECLARE_ALIGNED_ALLOCATOR | ( | ) |
#define TF_DECLARE_HANDLE | ( | name | ) | typedef struct name##__ { int unused; } *name |
#define TFSIMD_DEGS_PER_RAD (tfScalar(360.0) / TFSIMD_2_PI) |
#define TFSIMD_HALF_PI (TFSIMD_2_PI * tfScalar(0.25)) |
#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) |
typedef double tfScalar |
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 | ||
) |
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
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 | ) |
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
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
TFSIMD_FORCE_INLINE tfScalar tfTan | ( | tfScalar | x | ) |
TFSIMD_FORCE_INLINE double tfUnswapEndianDouble | ( | const unsigned char * | src | ) |
TFSIMD_FORCE_INLINE float tfUnswapEndianFloat | ( | unsigned int | a | ) |