logicomacorp / WaveSabre

Official WaveSabre repository
MIT License
246 stars 34 forks source link

WIP: WaveSabreCore: simplify cos-table computation #35

Closed kusma closed 4 years ago

kusma commented 4 years ago

We don't need to use run-time trig functions here, because the step between each entry is the same. So instead, let's calculate the coefficients of a 2D rotation matrix using constant expressions, which should give the same result, barring any accumulation errors.

Since we're using double precision floats and the LUT is of limited size, the max error accumulated are a negligible 2.22045e-14, compared to the CRT cos() function.

Note: I've marked this as WIP, so don't merge this just yet. This is kinda written "blindly" without verifying if the resulting code is smaller or not. I suspect it is, but this needs to be verified. My excuse is that I was on a Linux machine when I wrote this ;)

kusma commented 4 years ago

Sadly, seems like this leads to slightly larger code instead of smaller. I'm a bit surprised by that, but yeah.

kusma commented 4 years ago

In case you wondered, the size of the code-segment is actually the same before compression, but we lose 24 bytes after compression.