23 #ifndef INCLUDED_GR_FXPT_H 24 #define INCLUDED_GR_FXPT_H 44 static const int WORDBITS = 32;
45 static const int NBITS = 10;
46 static const float s_sine_table[1 << NBITS][2];
47 static const float PI;
48 static const float TAU;
49 static const float TWO_TO_THE_31;
56 int d = (int)std::floor(x/TAU+0.5);
59 return (int32_t) ((float) x * TWO_TO_THE_31 / PI);
65 return x * (PI / TWO_TO_THE_31);
75 int index = ux >> (WORDBITS - NBITS);
76 return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1];
85 uint32_t ux = x + 0x40000000;
86 int index = ux >> (WORDBITS - NBITS);
87 return s_sine_table[index][0] * (ux >> 1) + s_sine_table[index][1];
93 static void sincos(int32_t x,
float *s,
float *c)
96 int sin_index = ux >> (WORDBITS - NBITS);
97 *s = s_sine_table[sin_index][0] * (ux >> 1) + s_sine_table[sin_index][1];
100 int cos_index = ux >> (WORDBITS - NBITS);
101 *c = s_sine_table[cos_index][0] * (ux >> 1) + s_sine_table[cos_index][1];
fixed point sine and cosine and friends.fixed pt radians -2**31 -pi 0 0 2**31-1 pi - epsilon ...
Definition: fxpt.h:42
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
static float cos(int32_t x)
Definition: fxpt.h:83
Include this header to use the message passing features.
Definition: logger.h:695
static float sin(int32_t x)
Given a fixed point angle x, return float sine (x)
Definition: fxpt.h:72
static float fixed_to_float(int32_t x)
Definition: fxpt.h:63
static void sincos(int32_t x, float *s, float *c)
Definition: fxpt.h:93
static int32_t float_to_fixed(float x)
Definition: fxpt.h:53