1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 08:15:30 +03:00

optimize math (#5287)

* optimize math

Results in considerable flash saving

* log_approx, exp_approx, pow_approx

Taken from https://github.com/jhjourdan/SIMD-math-prims/blob/master/simd_math_prims.h

* Fix pow in rangefinder

* Use approximate function in baro calculation

Maximum error is < 20cm

* fixup! Fix pow in rangefinder
This commit is contained in:
Petr Ledvina 2018-03-03 13:26:33 +01:00 committed by Michael Keller
parent b64802d931
commit c11d016bc7
7 changed files with 117 additions and 7 deletions

View file

@ -117,12 +117,18 @@ float cos_approx(float x);
float atan2_approx(float y, float x);
float acos_approx(float x);
#define tan_approx(x) (sin_approx(x) / cos_approx(x))
float exp_approx(float val);
float log_approx(float val);
float pow_approx(float a, float b);
#else
#define sin_approx(x) sinf(x)
#define cos_approx(x) cosf(x)
#define atan2_approx(y,x) atan2f(y,x)
#define acos_approx(x) acosf(x)
#define tan_approx(x) tanf(x)
#define exp_approx(x) expf(x)
#define log_approx(x) logf(x)
#define pow_approx(a, b) powf(b, a)
#endif
void arraySubInt32(int32_t *dest, int32_t *array1, int32_t *array2, int count);