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
**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.
17
+
16
18
|||
17
19
|---|---|
18
-
|**Language**| C99 (`float` API, `qf` typedef) |
20
+
|**Language**| C99 (`float` API, `qf` typedef), plus optional C++ header wrapper|
19
21
|**Dependencies**| None at compile time for the library itself |
20
22
|**License**| BSD-2-Clause — see `LICENSE.txt`|
21
23
|**Layout**|`src/` library · `test/` unit tests · `build/` all binaries & fetched third-party sources |
@@ -42,9 +44,11 @@ For targets **without a hardware FPU** (or when you want to avoid soft-float cos
42
44
## Repository layout
43
45
44
46
```
45
-
src/ qf_math.c, qf_math.h— drop-in library
47
+
src/ qf_math.c, qf_math.h/.hpp — drop-in C library + C++ wrapper
46
48
test/ qf_math_test.c — correctness vs libm on host
|`make compare-tests`| CMake-builds libfixmath `tests_ro64` under `build/compare/third_party/libfixmath-build` and runs it. |
103
107
|`make compare-fr-tests`| Runs **fr_math**’s upstream `make test` against the shallow clone (`compare/run_fr_math_tests.sh`). |
104
-
|`make mcu-benchmark-snapshot`| Flash **LilyGO T-Display-S3**bench and rewrite **`compare/MCU_BENCHMARK_SNAPSHOT.md`** via UART (**pio**, **pyserial**). |
105
-
|`make benchmark-crossplatform`| Rewrite **`compare/BENCHMARK_CROSSPLATFORM.md`** — Host \| MCU **Speed vs libm** ratios from the two committed snapshots (no hardware). |
108
+
|`make mcu-benchmark-snapshot`| Flash MCU bench and rewrite **`compare/MCU_BENCHMARK_SNAPSHOT*.md`** via UART (**pio** / Arduino, **pyserial**). Supports LilyGO T-Display-S3, ESP32-S3, and Raspberry Pi Pico 2. |
109
+
|`make benchmark-crossplatform`| Rewrite **`compare/BENCHMARK_CROSSPLATFORM.md`** — Host \| MCU **Speed vs libm** ratios from the committed snapshots (no hardware). |
106
110
107
111
**Interpretation:** Desktop timings are *not* MCU timings. Bridged benchmarks include float↔fixed overhead that disappears when you stay natively in `fix16_t` / fixed-radix `s32`. The automated `s32` peer row is **fr_math**; other fast libraries are surveyed in [`compare/PEERS.md`](compare/PEERS.md) but are not wired into the reproducible host/ESP32-S3 harness yet. Use these numbers for intuition and regression tracking, not as a substitute for profiling on your silicon.
108
112
109
-
**On silicon:****[examples/lilygo_t_display_s3_bench](examples/lilygo_t_display_s3_bench/README.md)** (PlatformIO, **LilyGO T-Display-S3**) or **[examples/esp32s3_benchmark](examples/esp32s3_benchmark/README.md)** (ESP-IDF) runs the **same**[`benchmark_core.c`](compare/benchmark_core.c) loops so UART / USB serial captures wall-clock under Xtensa / newlib `libm`.
113
+
**On silicon:****[examples/lilygo_t_display_s3_bench](examples/lilygo_t_display_s3_bench/README.md)** (PlatformIO, **LilyGO T-Display-S3**), **[examples/esp32s3_benchmark](examples/esp32s3_benchmark/README.md)** (ESP-IDF), or **[examples/pico2_benchmark](examples/pico2_benchmark/)** (Arduino, **Raspberry Pi Pico 2** ARM / RISC-V) run the **same**[`benchmark_core.c`](compare/benchmark_core.c) loops so UART / USB serial captures wall-clock on real hardware.
110
114
111
-
**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 [`compare/MCU_BENCHMARK_SNAPSHOT.md`](compare/MCU_BENCHMARK_SNAPSHOT.md); regenerate with **`make benchmark-crossplatform`** after refreshing those files.
115
+
**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.
112
116
113
117
---
114
118
115
119
## Packaging & integration
116
120
117
121
### PlatformIO
118
122
119
-
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"`).
123
+
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++).
120
124
121
125
### Espressif ESP-IDF
122
126
@@ -132,8 +136,8 @@ Public surface is declared in `src/qf_math.h`:
Domain violations (`sqrt` of negative, `log` of non-positive) return `QF_DOMAIN_ERROR`.
@@ -144,7 +148,8 @@ Domain violations (`sqrt` of negative, `log` of non-positive) return `QF_DOMAIN_
144
148
145
149
| File | Purpose |
146
150
|------|---------|
147
-
|[`docs/`](docs/)|**GitHub Pages** site root (enable *Settings → Pages → GitHub Actions*; live at `https://deftio.github.io/qf_math/` after first deploy). |
|[`pages/`](pages/)|**GitHub Pages** site (enable *Settings → Pages → GitHub Actions*; live at `https://deftio.github.io/qf_math/` after first deploy) |
@@ -38,4 +40,4 @@ Guidance for automated coding agents editing this repository.
38
40
39
41
## Markdown policy
40
42
41
-
Root `README.md` is canonical user-facing. **`compare/*.md`** holds methodology matrices; **`compare/BENCHMARK_REPORT.md`** is the tooling-generated snapshot (`make compare-github-report`)—refresh it after materially changing numerical behavior if you want GitHub viewers to see fresh tables.
43
+
Root `README.md` is canonical user-facing. **`docs/`** holds Markdown documentation (algorithms, API, fr_math, integration). **`pages/`** holds the GitHub Pages HTML site. **`compare/*.md`** holds methodology matrices; **`compare/BENCHMARK_REPORT.md`** is the tooling-generated snapshot (`make compare-github-report`)—refresh it after materially changing numerical behavior if you want GitHub viewers to see fresh tables.
0 commit comments