Closed jserv closed 1 month ago
libfixmath implements Q16.16 format fixed point operations in C.
When FIXMATH_FAST_SIN
is enabled, its fast implementation for sin operates at 159% the speed of its most accurate version, with a slightly lower accuracy of approximately 2.3%. See fix16_trig.c
In addition, libfixmath64 is a derived version of libfixmath, converted into Q31.32 (Q31) format for larger integer range.
In the file
src/trig.c
, there is a lookup table for the sine function pre-calculated with fixed-point arithmetic. According to thesize
command provided by binutils, the lookup table and its related functions (sin, cos, tan) contribute more than 2 KiB to the code size on Aarch64.Instead of relying on table lookups, we can perform calculations on the fly and ensure a reasonably fast response time by utilizing a smaller table or a combination of bit operations. Additionally, instead of invoking twin_sin and twin_cos functions, we can use the sincos function to retrieve sine and cosine values simultaneously, reducing the number of function calls.
Reference: 2024 Report