56#define REAL_CONST(x) x
57#define UREAL_CONST(x) x
58#define FRACT_CONST(x) x
59#define UFRACT_CONST(x) x
61static REAL macro_arg_1, macro_arg_2, macro_arg_3, macro_arg_4;
63#define ONE 1.00000000000000000
64#define HALF 0.50000000000000000
65#define ZERO 0.00000000000000000
67#define POW(x, p) pow((x), (p))
69#define SQRT(x) sqrt(x)
70#define SQRTU(x) sqrt(x)
78#define MAX(x, y) MAX_HR((x), (y))
79#define SIGN(x, y) ((macro_arg_1=(y)) >= ZERO ? ABS(x) : -ABS(x))
81#define ACS_DBL_TINY 1.0e-300
104#define REAL_CONST(x) x##k
108#define UREAL_CONST(x) x##uk
112#define FRACT_CONST(x) x##lr
116#define UFRACT_CONST(x) x##ulr
119#define ONE REAL_CONST(1.0000)
121#define HALF REAL_CONST(0.5000)
123#define ZERO REAL_CONST(0.0000)
125#define ACS_DBL_TINY REAL_CONST(0.000001)
130#define SQRT(x) sqrtk(x)
135#define SQRTU(x) sqrtuk(x)
140#define EXP(x) expk(x)
145#define EXPU(x) expuk(x)
157#define POW(x, p) powfx(x, p)
163#define ABS(x) absfx(x)
174#define SIGN(x, y) ((macro_arg_1=(y)) >= ZERO ? ABS(x) : -ABS(x))
181#define REAL_COMPARE(x, op, y) ((x) op (y))
182#define REAL_TWICE(x) ((x) * 2.00000)
183#define REAL_HALF(x) ((x) * 0.50000)
192#define REAL_COMPARE(x, op, y) (bitsk((x)) op bitsk((y)))
197#define REAL_TWICE(x) ((x) * 2.000000k)
202#define REAL_HALF(x) ((x) * 0.500000k)
207#define MIN_HR(a, b) ({\
208 __type_of__(a) _a = (a); \
209 __type_of__(b) _b = (b); \
213#define MAX_HR(a, b) ({\
214 __type_of__(a) _a = (a); \
215 __type_of__(b) _b = (b); \
220 __type_of__(a) _a = (a); \
221 _a == ZERO? ZERO: _a * _a;})
225 __type_of__(a) _a = (a); \
226 _a == ZERO? ZERO: _a * _a * _a;})
228extern uint64_t udiv64(uint64_t, uint64_t);
235 return kbits((uint32_t) udiv64(((uint64_t) bitsk(a) << 15), (uint64_t) bitsk(b)));
243 return ukbits((uint32_t) udiv64(((uint64_t) bitsuk(a) << 16), (uint64_t) bitsuk(b)));
266 0x16a09, 0x1306f, 0x1172b, 0x10b55, 0x1059b, 0x102c9, 0x10163, 0x100b1,
267 0x10058, 0x1002c, 0x10016, 0x1000b, 0x10005, 0x10002, 0x10001
275 0xb504, 0xd744, 0xeac0, 0xf525, 0xfa83, 0xfd3e, 0xfe9e, 0xff4e, 0xffa7,
276 0xffd3, 0xffe9, 0xfff4, 0xfffa, 0xfffd, 0xfffe
286 uint32_t accumulator;
292 const uint32_t *powers;
296 return kbits(0xFFFFFFFF);
298 accumulator = bitsuk(
UREAL_CONST(1)) << (bitsk(p) >> 15);
299 fract_bits = bitsk(p) & 0x7FFF;
306 accumulator = bitsuk(
UREAL_CONST(1)) >> (bitsk(val) >> 15);
307 fract_bits = bitsk(val) & 0x7FFF;
312 for (uint32_t i = 0; i < 15; i++) {
313 uint32_t bit = (fract_bits >> (14 - i)) & 0x1;
315 uint32_t f = bit * powers[i];
316 accumulator = __stdfix_smul_uk(accumulator, f);
320 return ukbits(accumulator);
static UREAL pow_of_2(REAL p)
Calculates 2^p where p is a real number (rather than just an integer). This is still quicker than gen...
#define REAL_CONST(x)
Define a constant of type REAL.
long fract FRACT
Type used for "fractional" numbers.
unsigned accum UREAL
Type used for "unsigned real" numbers.
unsigned int Card
A Cardinal type.
accum REAL
Type used for "real" numbers.
unsigned long fract UFRACT
Type used for "unsigned fractional" numbers.
static int32_t udivk(int32_t a, REAL b)
Divides an integer by an accum.
static REAL kdivk(REAL a, REAL b)
Divides an accum by another accum.
#define UREAL_CONST(x)
Define a constant of type UREAL.
static UREAL ukdivuk(UREAL a, UREAL b)
Divides an unsigned accum by another unsigned accum.
static REAL kdivui(REAL a, uint32_t b)
Divides an accum by an unsigned integer.
static const uint32_t fract_powers_2[]
static const uint32_t fract_powers_half[]