20 #ifdef TF_MANAGED_CODE 32 #if defined(DEBUG) || defined (_DEBUG) 39 #if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300) 41 #define TFSIMD_FORCE_INLINE inline 42 #define ATTRIBUTE_ALIGNED16(a) a 43 #define ATTRIBUTE_ALIGNED64(a) a 44 #define ATTRIBUTE_ALIGNED128(a) a 47 #pragma warning(disable : 4324) // disable padding warning 52 #define TFSIMD_FORCE_INLINE __forceinline 53 #define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a 54 #define ATTRIBUTE_ALIGNED64(a) __declspec(align(64)) a 55 #define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a 59 #include <ppcintrinsics.h> 60 #define TF_HAVE_NATIVE_FSEL 61 #define tfFsel(a,b,c) __fsel((a),(b),(c)) 71 #define tfAssert assert 76 #define tfFullAssert(x) 78 #define tfLikely(_c) _c 79 #define tfUnlikely(_c) _c 83 #if defined (__CELLOS_LV2__) 84 #define TFSIMD_FORCE_INLINE inline 85 #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) 86 #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64))) 87 #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) 92 #define tfAssert assert 97 #define tfFullAssert(x) 99 #define tfLikely(_c) _c 100 #define tfUnlikely(_c) _c 106 #define TFSIMD_FORCE_INLINE __inline 107 #define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16))) 108 #define ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64))) 109 #define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128))) 114 #define tfAssert assert 119 #define tfFullAssert(x) 122 #define tfLikely(_c) __builtin_expect((_c), 1) 123 #define tfUnlikely(_c) __builtin_expect((_c), 0) 130 #define TFSIMD_FORCE_INLINE inline 131 #define ATTRIBUTE_ALIGNED16(a) a 136 #define ATTRIBUTE_ALIGNED64(a) a 137 #define ATTRIBUTE_ALIGNED128(a) a 142 #if defined(DEBUG) || defined (_DEBUG) 143 #define tfAssert assert 149 #define tfFullAssert(x) 150 #define tfLikely(_c) _c 151 #define tfUnlikely(_c) _c 155 #endif //__CELLOS_LV2__ 162 #define TF_LARGE_FLOAT 1e30 166 #define TF_DECLARE_ALIGNED_ALLOCATOR() \ 167 TFSIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return tfAlignedAlloc(sizeInBytes,16); } \ 168 TFSIMD_FORCE_INLINE void operator delete(void* ptr) { tfAlignedFree(ptr); } \ 169 TFSIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \ 170 TFSIMD_FORCE_INLINE void operator delete(void*, void*) { } \ 171 TFSIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return tfAlignedAlloc(sizeInBytes,16); } \ 172 TFSIMD_FORCE_INLINE void operator delete[](void* ptr) { tfAlignedFree(ptr); } \ 173 TFSIMD_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \ 174 TFSIMD_FORCE_INLINE void operator delete[](void*, void*) { } \ 194 #define TFSIMD_2_PI tfScalar(6.283185307179586232) 195 #define TFSIMD_PI (TFSIMD_2_PI * tfScalar(0.5)) 196 #define TFSIMD_HALF_PI (TFSIMD_2_PI * tfScalar(0.25)) 197 #define TFSIMD_RADS_PER_DEG (TFSIMD_2_PI / tfScalar(360.0)) 198 #define TFSIMD_DEGS_PER_RAD (tfScalar(360.0) / TFSIMD_2_PI) 199 #define TFSIMDSQRT12 tfScalar(0.7071067811865475244008443621048490) 201 #define tfRecipSqrt(x) ((tfScalar)(tfScalar(1.0)/tfSqrt(tfScalar(x)))) 204 #define TFSIMD_EPSILON DBL_EPSILON 205 #define TFSIMD_INFINITY DBL_MAX 214 tfScalar r = (x - abs_y) / (x + abs_y);
215 angle = coeff_1 - coeff_1 * r;
217 tfScalar r = (x + abs_y) / (abs_y - x);
218 angle = coeff_2 - coeff_1 * r;
220 return (y < 0.0
f) ? -angle :
angle;
226 return (((a) <= eps) && !((a) < -eps));
229 return (!((a) <= eps));
240 #define TF_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name 245 return a >= 0 ? b : c;
248 #define tfFsels(a,b,c) (tfScalar)tfFsel(a,b,c) 254 const char *p = (
const char *) &i;
271 unsigned testNz = (unsigned)(((
int)condition | -(
int)condition) >> 31);
272 unsigned testEqz = ~testNz;
273 return ((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
277 unsigned testNz = (unsigned)(((
int)condition | -(
int)condition) >> 31);
278 unsigned testEqz = ~testNz;
279 return static_cast<int>((valueIfConditionNonZero & testNz) | (valueIfConditionZero & testEqz));
283 #ifdef TF_HAVE_NATIVE_FSEL 286 return (condition != 0) ? valueIfConditionNonZero : valueIfConditionZero;
301 return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24));
306 return static_cast<unsigned short>(((val & 0xff00) >> 8) | ((val & 0x00ff) << 8));
328 unsigned char *dst = (
unsigned char *)&a;
329 unsigned char *src = (
unsigned char *)&d;
342 unsigned char *src = (
unsigned char *)&a;
343 unsigned char *dst = (
unsigned char *)&d;
357 unsigned char *src = (
unsigned char *)&d;
374 unsigned char *dst = (
unsigned char *)&d;
402 return angleInRadians;
419 #endif //TFSIMD___SCALAR_H
tfTypedObject(int objectType)
TFSIMD_FORCE_INLINE unsigned tfSelect(unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero)
TFSIMD_FORCE_INLINE tfScalar tfNormalizeAngle(tfScalar angleInRadians)
TFSIMD_FORCE_INLINE bool tfEqual(tfScalar a, tfScalar eps)
TFSIMD_FORCE_INLINE void tfSwap(T &a, T &b)
TFSIMD_FORCE_INLINE unsigned tfSwapEndian(unsigned val)
TFSIMD_FORCE_INLINE tfScalar tfLog(tfScalar x)
TFSIMD_FORCE_INLINE double tfUnswapEndianDouble(const unsigned char *src)
double tfScalar
The tfScalar type abstracts floating point numbers, to easily switch between double and single floati...
TFSIMD_FORCE_INLINE tfScalar tfDegrees(tfScalar x)
rudimentary class to provide type info
TFSIMD_FORCE_INLINE tfScalar tfFsel(tfScalar a, tfScalar b, tfScalar c)
TFSIMD_FORCE_INLINE const tfScalar & y() const
Return the y value.
TFSIMD_FORCE_INLINE tfScalar tfAtan(tfScalar x)
TFSIMD_FORCE_INLINE void tfSwapEndianDouble(double d, unsigned char *dst)
TFSIMD_FORCE_INLINE bool tfGreaterEqual(tfScalar a, tfScalar eps)
#define TFSIMD_DEGS_PER_RAD
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
Return the ***half*** angle between two quaternions.
TFSIMD_FORCE_INLINE unsigned int tfSwapEndianFloat(float d)
tfSwapFloat uses using char pointers to swap the endianness
TFSIMD_FORCE_INLINE tfScalar tfTan(tfScalar x)
TFSIMD_FORCE_INLINE tfScalar tfCos(tfScalar x)
TFSIMD_FORCE_INLINE bool tfFuzzyZero(tfScalar x)
TFSIMD_FORCE_INLINE tfScalar tfAcos(tfScalar x)
#define TFSIMD_RADS_PER_DEG
TFSIMD_FORCE_INLINE tfScalar tfFmod(tfScalar x, tfScalar y)
#define TFSIMD_FORCE_INLINE
int getObjectType() const
TFSIMD_FORCE_INLINE const tfScalar & x() const
Return the x value.
TFSIMD_FORCE_INLINE tfScalar tfAtan2(tfScalar x, tfScalar y)
TFSIMD_FORCE_INLINE float tfUnswapEndianFloat(unsigned int a)
TFSIMD_FORCE_INLINE tfScalar tfSqrt(tfScalar x)
TFSIMD_FORCE_INLINE tfScalar tfAtan2Fast(tfScalar y, tfScalar x)
TFSIMD_FORCE_INLINE tfScalar tfAsin(tfScalar x)
TFSIMD_FORCE_INLINE tfScalar tfExp(tfScalar x)
TFSIMD_FORCE_INLINE tfScalar tfSin(tfScalar x)
TFSIMD_FORCE_INLINE bool tfMachineIsLittleEndian()
TFSIMD_FORCE_INLINE int tfIsNegative(tfScalar x)
TFSIMD_FORCE_INLINE tfScalar tfFabs(tfScalar x)
TFSIMD_FORCE_INLINE tfScalar tfRadians(tfScalar x)
TFSIMD_FORCE_INLINE tfScalar tfPow(tfScalar x, tfScalar y)