11 #ifndef CH_MATH_UTILS_H_ 12 #define CH_MATH_UTILS_H_ 20 #define INT2FIXED(x) ((x) << FRACT_BITS) 21 #define FLOAT2FIXED(x) ((fixed_t)((x) * (1 << FRACT_BITS))) 23 #define FIXED2INT(x) ((x) >> FRACT_BITS) 24 #define FIXED2FLOAT(x) (((float)(x)) / (1 << FRACT_BITS)) 26 #define FIXEDDIV(x,y) ((fixed_t)(((uint64_t)(x) << FRACT_BITS) / (y))) 27 #define FIXEDMUL(x,y) ((fixed_t)(((x) >> (FRACT_BITS/2)) * ((y) >> (FRACT_BITS/2)))) 29 #define FIXED_PI 0x3243FU 31 #define INV_LOG2_E_Q1DOT31 0x58b90bfcU // Inverse log base 2 of e 33 typedef uint32_t fixed_t;
35 fixed_t FP_sqrt(fixed_t x);
37 fixed_t FP_log2(fixed_t x);
39 fixed_t FP_log(fixed_t x);
41 int32_t sqrt_int32( int32_t v );