Chirp SonicLib  2.1.0
Macros | Typedefs | Functions
ch_math_utils.h File Reference

Functions for performing fixed point arithmetic. https://github.com/dmoulding/log2fix https://github.com/chmike/fpsqrt. More...

#include <stdio.h>
#include <math.h>
#include <stdint.h>

Go to the source code of this file.

Macros

#define FRACT_BITS   16
 
#define INT2FIXED(x)   ((x) << FRACT_BITS)
 
#define FLOAT2FIXED(x)   ((fixed_t)((x) * (1 << FRACT_BITS)))
 
#define FIXED2INT(x)   ((x) >> FRACT_BITS)
 
#define FIXED2FLOAT(x)   (((float)(x)) / (1 << FRACT_BITS))
 
#define FIXEDDIV(x, y)   ((fixed_t)(((uint64_t)(x) << FRACT_BITS) / (y)))
 
#define FIXEDMUL(x, y)   ((fixed_t)(((x) >> (FRACT_BITS/2)) * ((y) >> (FRACT_BITS/2))))
 
#define FIXED_PI   0x3243FU
 
#define INV_LOG2_E_Q1DOT31   0x58b90bfcU
 

Typedefs

typedef uint32_t fixed_t
 

Functions

fixed_t FP_sqrt (fixed_t x)
 
fixed_t FP_log2 (fixed_t x)
 
fixed_t FP_log (fixed_t x)
 
int32_t sqrt_int32 (int32_t v)
 

Detailed Description

Functions for performing fixed point arithmetic. https://github.com/dmoulding/log2fix https://github.com/chmike/fpsqrt.

Date
July 20, 2017
Author
nparikh