<commit_before>cordic_polar.py
===============

Generates polar to rectangular conversion functions using a CORDIC algorithm.

https://en.wikipedia.org/wiki/CORDIC

Fixed-point trigonometric functions for microcontrollers and microprocessors.

Usage
-----

`cordic_polar.py [-h] [--pdfname PDFNAME] passes datatype`

positional arguments:

* passes             number of CORDIC passes

* datatype           datatype (one of int8_t, int16_t, int32_t)

optional arguments:

  `-h`, `--help`       show this help message and exit

  `--pdfname PDFNAME`  Filename for error report

The code is printed to the output.

Scaling and Units
-----------------
The units are scaled to the datatype used.

The angle measure is binary radians in the size of the datatype. This fits one rotation in one wrap of the datatype.

The magnitude measure (and x- and y- measures) are arbitrary, but it is recommended to use no more than half of the range of the datatype to prevent internal overflows.

Dependencies
------------

Requires Python 2.  If making an error plot, requires matplotlib.

To do error testing, this script compiles its output and runs the code as a subprocess.  This requires a working C compiler on the host, installed as 'cc'.

There may be portability bugs related to the temp directory. It works on Ubuntu, if that helps any.

Notes
-----

The C implementation requires arithmetic right-shift of signed integers. This is compiler-defined behavior, but GCC does what we want: "Signed ‘>>’ acts on negative numbers by sign extension." from https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html

If you're using a compiler that does something else, define the macro ARS for arithmetic right-shift.

FAQ
===

How accurate is it?
-------------------

See the accuracy test results in comments at the top of the
generated function, or get the pdf accuracy test.

How performant is it?
---------------------
<commit_msg>Clearer text about limits hopefully.<commit_after>cordic_polar.py
===============

Generates polar to rectangular conversion functions using a CORDIC algorithm.

https://en.wikipedia.org/wiki/CORDIC

Fixed-point trigonometric functions for microcontrollers and microprocessors.

Usage
-----

`cordic_polar.py [-h] [--pdfname PDFNAME] passes datatype`

positional arguments:

* `passes`             number of CORDIC passes

* `datatype`           datatype (one of int8_t, int16_t, int32_t)

optional arguments:

  `-h`, `--help`       show this help message and exit

  `--pdfname PDFNAME`  Filename for error report

The code is printed to the output.

Scaling and Units
-----------------
The units are scaled to the datatype used.

The angle measure is binary radians in the size of the datatype. This fits one rotation in one wrap of the datatype.

The magnitude measure is arbitrary, but use no more than the range of the datatype / 2 to prevent internal overflows. For example, with int16_t the limit is 32768 / 2 or 16384. The x- and y- can be any value that maintains a magnitude less than this. For int16\_t safety, it's easier to keep x and y in the square bounded by +/- 16384/sqrt(2) in both dimensions.

Dependencies
------------

Requires Python 2.  If making an error plot, requires matplotlib.

To do error testing, this script compiles its output and runs the code as a subprocess.  This requires a working C compiler on the host, installed as 'cc'.

There may be portability bugs related to the temp directory. It works on Ubuntu, if that helps any.

Notes
-----

The C implementation requires arithmetic right-shift of signed integers. This is compiler-defined behavior, but GCC does what we want: "Signed ‘>>’ acts on negative numbers by sign extension." from https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html

If you're using a compiler that does something else, define the macro ARS for arithmetic right-shift.

FAQ
===

How accurate is it?
-------------------

See the accuracy test results in comments at the top of the
generated function, or get the pdf accuracy test.

How performant is it?
---------------------

{'fraction_non_alphanumeric': 0.09899534427836315, 'fraction_numerical': 0.008331291350159274, 'mean_word_length': 3.2213029989658737, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6212247', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1064, 'n_words': 555}