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)
76#define MAX(x, y) MAX_HR((x), (y))
77#define SIGN(x, y) ((macro_arg_1=(y)) >= ZERO ? ABS(x) : -ABS(x))
79#define ACS_DBL_TINY 1.0e-300
102#define REAL_CONST(x) x##k
106#define UREAL_CONST(x) x##uk
110#define FRACT_CONST(x) x##lr
114#define UFRACT_CONST(x) x##ulr
117#define ONE REAL_CONST(1.0000)
119#define HALF REAL_CONST(0.5000)
121#define ZERO REAL_CONST(0.0000)
123#define ACS_DBL_TINY REAL_CONST(0.000001)
128#define SQRT(x) sqrtk(x)
133#define EXP(x) expk(x)
145#define POW(x, p) powfx(x, p)
151#define ABS(x) absfx(x)
162#define SIGN(x, y) ((macro_arg_1=(y)) >= ZERO ? ABS(x) : -ABS(x))
169#define REAL_COMPARE(x, op, y) ((x) op (y))
170#define REAL_TWICE(x) ((x) * 2.00000)
171#define REAL_HALF(x) ((x) * 0.50000)
180#define REAL_COMPARE(x, op, y) (bitsk((x)) op bitsk((y)))
185#define REAL_TWICE(x) ((x) * 2.000000k)
190#define REAL_HALF(x) ((x) * 0.500000k)
195#define MIN_HR(a, b) ({\
196 __type_of__(a) _a = (a); \
197 __type_of__(b) _b = (b); \
201#define MAX_HR(a, b) ({\
202 __type_of__(a) _a = (a); \
203 __type_of__(b) _b = (b); \
208 __type_of__(a) _a = (a); \
209 _a == ZERO? ZERO: _a * _a;})
213 __type_of__(a) _a = (a); \
214 _a == ZERO? ZERO: _a * _a * _a;})
216extern uint64_t udiv64(uint64_t, uint64_t);
223 return kbits((uint32_t) udiv64(((uint64_t) bitsk(a) << 15), (uint64_t) bitsk(b)));
231 return ukbits((uint32_t) udiv64(((uint64_t) bitsuk(a) << 16), (uint64_t) bitsuk(b)));
254 0x16a09, 0x1306f, 0x1172b, 0x10b55, 0x1059b, 0x102c9, 0x10163, 0x100b1,
255 0x10058, 0x1002c, 0x10016, 0x1000b, 0x10005, 0x10002, 0x10001
263 0xb504, 0xd744, 0xeac0, 0xf525, 0xfa83, 0xfd3e, 0xfe9e, 0xff4e, 0xffa7,
264 0xffd3, 0xffe9, 0xfff4, 0xfffa, 0xfffd, 0xfffe
274 uint32_t accumulator;
280 const uint32_t *powers;
284 return kbits(0xFFFFFFFF);
286 accumulator = bitsuk(
UREAL_CONST(1)) << (bitsk(p) >> 15);
287 fract_bits = bitsk(p) & 0x7FFF;
294 accumulator = bitsuk(
UREAL_CONST(1)) >> (bitsk(val) >> 15);
295 fract_bits = bitsk(val) & 0x7FFF;
300 for (uint32_t i = 0; i < 15; i++) {
301 uint32_t bit = (fract_bits >> (14 - i)) & 0x1;
303 uint32_t f = bit * powers[i];
304 accumulator = __stdfix_smul_uk(accumulator, f);
308 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[]