1 #ifndef __basicmaths_h__
2 #define __basicmaths_h__
8 #define _USE_MATH_DEFINES
38 #define min(a,b) ((a)<(b)?(a):(b))
41 #define max(a,b) ((a)>(b)?(a):(b))
44 #define abs(x) ((x)>0?(x):-(x))
47 #define clamp(x, lo, hi) ((x)>(hi)?(hi):((x)<(lo)?(lo):(x)))
52 #define M_PI 3.14159265358979323846
55 #define M_SQRT2 1.41421356237309504880
90 #define malloc(x) pvPortMalloc(x)
91 #define calloc(x, y) pvPortCalloc(x, y)
92 #define free(x) vPortFree(x)
93 #define realloc(x, y) pvPortRealloc(x, y);
94 void* pvPortCalloc(
size_t nmemb,
size_t size);
95 void* pvPortRealloc(
void *pv,
size_t xWantedSize);
103 #define sin(x) arm_sin_f32(x)
104 #define sinf(x) arm_sin_f32(x)
105 #define cos(x) arm_cos_f32(x)
106 #define cosf(x) arm_cos_f32(x)
107 #define sqrt(x) sqrtf(x)
109 #define rand() arm_rand32()
114 #define pow(x, y) fast_powf(x, y)
115 #define powf(x, y) fast_powf(x, y)
116 #define exp(x) fast_expf(x)
117 #define expf(x) fast_expf(x)
118 #define exp2(x) fast_exp2f(x)
119 #define exp2f(x) fast_exp2f(x)
120 #define exp10(x) fast_exp10f(x)
121 #define exp10f(x) fast_exp10f(x)
127 #define log(x) fast_logf(x)
128 #define logf(x) fast_logf(x)
129 #define log2(x) fast_log2f(x)
130 #define log2f(x) fast_log2f(x)
131 #define log10(x) fast_log10f(x)
132 #define log10f(x) fast_log10f(x)
136 #define exp10(x) powf(10, x)
137 #define exp10f(x) powf(10, x)
142 #define RAND_MAX UINT32_MAX
float fast_powf(float x, float y)
uint32_t fast_log2i(uint32_t x)
float fast_fmodf(float x, float y)
void fast_log_set_table(const float *table, int size)
float randf()
generate a random number between 0 and 1
float fast_exp2f(float x)
uint32_t arm_rand32()
Generate an unsigned 32bit pseudo-random number using xorshifter algorithm.
void arm_srand32(uint32_t s)
float fast_exp10f(float x)
float fast_log2f(float x)
void fast_pow_set_table(const uint32_t *table, int size)
float fast_atan2f(float a, float b)
float fast_log10f(float x)
float arm_sqrtf(float in)