You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--notes "Release ${{ steps.ver.outputs.value }} — see [README](https://github.com/${{ github.repository }}#readme) for API overview and [CHANGELOG commits](https://github.com/${{ github.repository }}/commits/$TAG)." \
Copy file name to clipboardExpand all lines: README.md
+4-26Lines changed: 4 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@
13
13
14
14
**qf_math** is a compact, dependency-free C99 library for **fast approximate math on IEEE-754 `float`**. It targets embedded firmware where you want predictable cost and small flash footprint: table-driven trig, logarithms, exponentials, `sqrt`, `hypot`, waveform helpers, and a floating-point ADSR envelope—without pulling in full libm semantics on platforms where that matters.
15
15
16
-
[github.com/deftio/fr_math](github.com/deftio/fr_math) is the fixed point (pure integer) cousin of this library with identical apis.
16
+
[fr_math](github.com/deftio/fr_math) is the fixed point (pure integer) cousin of this library with identical apis.
17
17
18
18
|||
19
19
|---|---|
@@ -24,7 +24,6 @@
24
24
25
25
Version macros live in [`qf_math.h`](src/qf_math.h): `QF_MATH_VERSION` / `QF_MATH_VERSION_HEX`. When you bump the version string, update the **Version** badge at the top of this README to match.
26
26
27
-
---
28
27
29
28
## Why use this?
30
29
@@ -33,13 +32,11 @@ Version macros live in [`qf_math.h`](src/qf_math.h): `QF_MATH_VERSION` / `QF_MAT
33
32
-**Explicit trade-offs**: worst-case errors are documented in headers (e.g. trig ~3e-5 class behavior vs libm doubles).
34
33
-**No heap**, minimal stack depth in normal use, integer-friendly helpers (`QF_*` macros, BAM phase, fixed-radix bridges).
For targets **without a hardware FPU** (or when you want to avoid soft-float cost), use **[fr_math](https://github.com/deftio/fr_math)**—a **battle-tested** sister library that exposes the **same API** using **pure fixed-point** math, with **16-bit** platform support when that is a requirement.
Everything that resembles an artifact—including vendored comparison libraries—stays under **`build/`** (for example `build/compare/third_party/`) so your tree stays clean.
59
56
60
-
---
61
57
62
58
## Build & test (host)
63
59
@@ -78,7 +74,6 @@ make coverage-check # CI-style gate: 100% lines covered in src/qf_math.c
78
74
make clean
79
75
```
80
76
81
-
---
82
77
83
78
## Cross-compile code sizes (Docker)
84
79
@@ -91,7 +86,6 @@ make docker-sizes-rebuild # force docker image rebuild first
@@ -114,32 +108,19 @@ Documentation tables live under **`compare/`** (`LIBRARIES.md` for platforms/rep
114
108
115
109
**Host vs MCU (relative only):****[compare/BENCHMARK_CROSSPLATFORM.md](compare/BENCHMARK_CROSSPLATFORM.md)** merges **Speed vs libm** tables from [`compare/BENCHMARK_REPORT.md`](compare/BENCHMARK_REPORT.md) (POSIX snapshot) and the MCU snapshots (`MCU_BENCHMARK_SNAPSHOT*.md` — ESP32-S3, Pico 2 ARM, Pico 2 RISC-V); regenerate with **`make benchmark-crossplatform`** after refreshing those files.
-**`lib_deps`:**`deftio/qf_math` or `https://github.com/deftio/qf_math.git`
125
-
-**Lean subset** (smaller ROM, no `log10` / `pow10` / waves / ADSR): add to the env `build_flags = -DQF_MATH_LEAN`
126
-
-**`export` exclude** in the manifest trims compare/tests/docs from the PIO-installed copy; clones via **git URL** still get the full repo (including **`examples/`**).
127
-
- Sanity check locally: `pio pkg pack .` must succeed before publishing.
- Install from ZIP of the repo or symlink the folder under `Arduino/libraries/`; include `#include <qf_math.h>` (Arduino adds library `src/` to the include path).
116
+
Use `library.json` at the repo root: add this folder as a local library or publish following [PlatformIO library format](https://docs.platformio.org/en/latest/manifests/library-json/index.html). Headers resolve from `src/` (`#include "qf_math.h"` for C, `#include "qf_math.hpp"` for C++).
133
117
134
118
### Espressif ESP-IDF
135
119
136
-
-**Component Manager:**[`idf_component.yml`](idf_component.yml) + [`CMakeLists.txt`](CMakeLists.txt). Component tarball excludes bulky trees (`examples/`, `compare/`, …); **`src/`**, root **`CMakeLists.txt`**, **`LICENSE.txt`**, and **`README.md`** remain usable.
137
-
-**Consumer projects:**`#include "qf_math.h"`; optional **`QF_MATH_LEAN`** via `target_compile_definitions` on your target or **`idf.py menuconfig`/CMake extra flags**.
138
-
-**Warnings:** component build uses `-Wall -Wextra -Wshadow -Wconversion`**without**`-Werror` so toolchain/IDF updates are less likely to break downstream apps.
120
+
`idf_component.yml` registers the component for the ESP-IDF Component Manager. `CMakeLists.txt` wraps `idf_component_register` for `src/qf_math.c` with include path `src/`.
139
121
140
-
Add as a dependency (path or git URL) per Espressif docs.
122
+
Add as a dependency (path or git URL) per Espressif docs; then `#include "qf_math.h"` from application components.
141
123
142
-
---
143
124
144
125
## API overview
145
126
@@ -153,7 +134,6 @@ Public surface is declared in `src/qf_math.h`:
153
134
154
135
Domain violations (`sqrt` of negative, `log` of non-positive) return `QF_DOMAIN_ERROR`.
155
136
156
-
---
157
137
158
138
## Documentation for automation
159
139
@@ -167,15 +147,13 @@ Domain violations (`sqrt` of negative, `log` of non-positive) return `QF_DOMAIN_
167
147
|`llms.txt`| Compact index for LLM tooling / crawling |
168
148
|`agents.md`| Conventions for coding agents working in this repo |
169
149
170
-
---
171
150
172
151
## Contributing & correctness
173
152
174
153
- Prefer extending tests in `test/qf_math_test.c` when adjusting numerical behavior.
175
154
- Keep binaries and fetched trees under `build/` only.
176
155
- Match existing comment and license style in touched files.
Copy file name to clipboardExpand all lines: pages/index.html
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -25,22 +25,22 @@ <h2>Accuracy & speed sweep vs libm</h2>
25
25
<p>This table is generated by <code>tools/qf_math_bench.c --html-table</code> (same grids as <code>make bench</code>). Numbers are from the machine that last ran <code>make docs-pages</code> or the GitHub Actions Pages deploy — <strong>not MCU timings</strong>.</p>
26
26
27
27
<!--QF_MATH_BENCH_TABLE_BEGIN-->
28
-
<pclass="qf-meta"><small>Generated UTC <strong>2026-05-08 03:36:06Z</strong> — 10000-sample grids, 100000 outer × 100-inner timing loops; error vs C <code>double</code>; libm = matching <code>*f</code> call. Compiler: <code>Apple LLVM 21.0.0 (clang-2100.0.123.102)</code>.</small></p>
28
+
<pclass="qf-meta"><small>Generated UTC <strong>2026-05-09 09:09:51Z</strong> — 10000-sample grids, 100000 outer × 100-inner timing loops; error vs C <code>double</code>; libm = matching <code>*f</code> call. Compiler: <code>Apple LLVM 21.0.0 (clang-2100.0.123.102)</code>.</small></p>
29
29
<h3>Accuracy sweep vs libm (<code>float</code>)</h3>
<tr><td><code>qf_sin()</code></td><td>radians; ref = sin in double</td><td>0.009691% amp</td><td>0.003225% amp</td><td>49.31</td><td>21.57</td><td><strong>0.44</strong>×</td></tr>
33
-
<tr><td><code>qf_cos()</code></td><td>radians; ref = cos in double</td><td>0.009733% amp</td><td>0.003226% amp</td><td>33.05</td><td>23.46</td><td><strong>0.71</strong>×</td></tr>
34
-
<tr><td><code>qf_tan()</code></td><td>excludes inputs within 0.05 rad of poles</td><td>1.71% amp</td><td>0.04845% amp</td><td>61.59</td><td>29.32</td><td><strong>0.48</strong>×</td></tr>
35
-
<tr><td><code>qf_acos()</code></td><td>domain [-1, 1]; radians out</td><td>0.007487% of pi</td><td>0.000372% of pi</td><td>76.82</td><td>22.90</td><td><strong>0.30</strong>×</td></tr>
36
-
<tr><td><code>qf_atan2()</code></td><td>swept (y,x) magnitudes; ref = atan2 double</td><td>0.02969% of pi</td><td>0.006815% of pi</td><td>57.21</td><td>26.28</td><td><strong>0.46</strong>×</td></tr>
37
-
<tr><td><code>qf_log2()</code></td><td>x in (0.001, 100]; absolute Δ vs double</td><td>4.353e-05 abs</td><td>1.615e-05 abs</td><td>16.40</td><td>23.07</td><td><strong>1.41</strong>×</td></tr>
38
-
<tr><td><code>qf_ln()</code></td><td>x in (0.001, 100]; absolute Δ vs double</td><td>3.03e-05 abs</td><td>1.119e-05 abs</td><td>22.99</td><td>22.84</td><td><strong>0.99</strong>×</td></tr>
39
-
<tr><td><code>qf_pow2()</code></td><td>relative vs double; libm ref = exp2f</td><td>0.001473% rel</td><td>0.0009778% rel</td><td>20.28</td><td>16.77</td><td><strong>0.83</strong>×</td></tr>
40
-
<tr><td><code>qf_exp()</code></td><td>relative vs double on grid</td><td>0.001512% rel</td><td>0.0009779% rel</td><td>21.95</td><td>16.68</td><td><strong>0.76</strong>×</td></tr>
41
-
<tr><td><code>qf_sqrt()</code></td><td>relative vs double</td><td>0.0004702% rel</td><td>0.0001786% rel</td><td>16.28</td><td>6.33</td><td><strong>0.39</strong>×</td></tr>
42
-
<tr><td><code>qf_hypot()</code></td><td>relative vs double hypot</td><td>0.0004676% rel</td><td>0.0001906% rel</td><td>13.22</td><td>12.96</td><td><strong>0.98</strong>×</td></tr>
43
-
<tr><td><code>qf_hypot_fast8()</code></td><td>qf piecewise-linear; timed vs hypotf reference</td><td>0.1372% rel</td><td>0.05112% rel</td><td>22.70</td><td>13.17</td><td><strong>0.58</strong>×</td></tr>
32
+
<tr><td><code>qf_sin()</code></td><td>radians; ref = sin in double</td><td>0.001885% amp</td><td>0.0007992% amp</td><td>10.64</td><td>21.39</td><td><strong>2.01</strong>×</td></tr>
33
+
<tr><td><code>qf_cos()</code></td><td>radians; ref = cos in double</td><td>0.001887% amp</td><td>0.0008006% amp</td><td>10.46</td><td>22.70</td><td><strong>2.17</strong>×</td></tr>
34
+
<tr><td><code>qf_tan()</code></td><td>excludes inputs within 0.05 rad of poles</td><td>0.4535% amp</td><td>0.02151% amp</td><td>29.42</td><td>28.64</td><td><strong>0.97</strong>×</td></tr>
35
+
<tr><td><code>qf_acos()</code></td><td>domain [-1, 1]; radians out</td><td>0.01482% of pi</td><td>0.002432% of pi</td><td>94.05</td><td>22.36</td><td><strong>0.24</strong>×</td></tr>
36
+
<tr><td><code>qf_atan2()</code></td><td>swept (y,x) magnitudes; ref = atan2 double</td><td>0.04097% of pi</td><td>0.01276% of pi</td><td>28.63</td><td>25.71</td><td><strong>0.90</strong>×</td></tr>
37
+
<tr><td><code>qf_log2()</code></td><td>x in (0.001, 100]; absolute Δ vs double</td><td>8.104e-07 abs</td><td>2.15e-07 abs</td><td>19.19</td><td>22.23</td><td><strong>1.16</strong>×</td></tr>
38
+
<tr><td><code>qf_ln()</code></td><td>x in (0.001, 100]; absolute Δ vs double</td><td>6.235e-07 abs</td><td>1.676e-07 abs</td><td>25.55</td><td>22.30</td><td><strong>0.87</strong>×</td></tr>
39
+
<tr><td><code>qf_pow2()</code></td><td>relative vs double; libm ref = exp2f</td><td>0.000322% rel</td><td>3.64e-05% rel</td><td>22.48</td><td>16.13</td><td><strong>0.72</strong>×</td></tr>
40
+
<tr><td><code>qf_exp()</code></td><td>relative vs double on grid</td><td>0.0003402% rel</td><td>4.163e-05% rel</td><td>25.65</td><td>16.28</td><td><strong>0.63</strong>×</td></tr>
41
+
<tr><td><code>qf_sqrt()</code></td><td>relative vs double</td><td>0.0004702% rel</td><td>0.0001786% rel</td><td>16.08</td><td>6.27</td><td><strong>0.39</strong>×</td></tr>
42
+
<tr><td><code>qf_hypot()</code></td><td>relative vs double hypot</td><td>0.0004676% rel</td><td>0.0001906% rel</td><td>13.35</td><td>13.02</td><td><strong>0.98</strong>×</td></tr>
43
+
<tr><td><code>qf_hypot_fast8()</code></td><td>qf piecewise-linear; timed vs hypotf reference</td><td>0.1372% rel</td><td>0.05112% rel</td><td>22.89</td><td>13.17</td><td><strong>0.58</strong>×</td></tr>
44
44
</tbody></table>
45
45
<pclass="qf-footnote"><small><strong>Error column:</strong><em>amp</em> = % of ±1 output (sin/cos/tan). <em>rel</em> = max relative error vs double × 100. <em>of pi</em> = absolute radian error as % of π (acos, atan2). <em>abs</em> = absolute Δ vs double on the grid (log2, ln). <strong>libm ÷ qf</strong> uses total loop time; > 1 means qf_math was faster on this host (microbenchmark only; profile on your MCU).</small></p>
0 commit comments