26 #define SINI_PERIOD 0x8000
27 #define SINI_MAX 0x1000
28 #define SINI_MIN -0x1000
38 static inline __attribute__((always_inline))
42 static const int32_t qN = 13,
49 x = x * x >> (2 * qN - 14);
51 y = B - (x * C >> 14);
67 static const int32_t qN = 13;
69 int32_t c = x << (30 - qN);
70 int32_t y =
_ihelp(x - (1 << qN));
72 return c >= 0 ? y :-y;
84 static const int32_t qN = 13;
89 return c >= 0 ? y :-y;
98 static inline unsigned sqrti(
unsigned x)
105 unsigned y0 = x >> 1;
106 unsigned y1 = (y0 + x / y0) >> 1;
110 y1 = (y0 + x / y0) >> 1;
124 static inline uint32_t
powi(
unsigned x,
unsigned y)
static int32_t fast_sini(int32_t x)
A sine approximation via a fourth-order cosine approx.
static uint32_t powi(unsigned x, unsigned y)
Returns the value of x to the power of y.
static unsigned sqrti(unsigned x)
Square root of an integer.
static int32_t _ihelp(int32_t x)
Internal fast_sini/fast_cosi helper function.
#define SINI_PERIOD
Period of the fast_sini() function.
static int32_t fast_cosi(int32_t x)
A a fourth-order cosine approx.