moved fastPow() to lmms_math.h

This commit is contained in:
Hannu Haahti
2014-04-05 03:32:54 +03:00
parent b0cdcc639e
commit 6c33b4af80
4 changed files with 16 additions and 37 deletions

View File

@@ -26,6 +26,7 @@
#ifndef _LMMS_MATH_H
#define _LMMS_MATH_H
#include <stdint.h>
#ifdef __INTEL_COMPILER
@@ -106,5 +107,18 @@ static inline int fast_rand()
// source: http://martin.ankerl.com/2007/10/04/optimized-pow-approximation-for-java-and-c-c/
static inline double fastPow( double a, double b )
{
union
{
double d;
int32_t x[2];
} u = { a };
u.x[1] = static_cast<int32_t>( b * ( u.x[1] - 1072632447 ) + 1072632447 );
u.x[0] = 0;
return u.d;
}
#endif