Skip to content

Conversation

kusma
Copy link
Contributor

@kusma kusma commented Apr 9, 2020

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 ;)

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.
@kusma
Copy link
Contributor Author

kusma commented Apr 9, 2020

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

@kusma kusma closed this Apr 9, 2020
@kusma
Copy link
Contributor Author

kusma commented Apr 9, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant