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
Copy file name to clipboardExpand all lines: README.md
+78-7Lines changed: 78 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,9 @@ We created `numpycpp` to keep NumPy's familiar usage patterns while letting C++
13
13
14
14
## Overview
15
15
16
-
`numpycpp` is a **header-only C++ library** implementing numpy's core API (`numpy.*`, `numpy.linalg.*`, `numpy.einsum`) with pixel-level precision alignment. Raw pointer + size interface. Zero external dependencies — pure C++17 standard library.
16
+
`numpycpp` is a **header-only C++ library** implementing numpy's core API (`numpy.*`, `numpy.linalg.*`, `numpy.einsum`) with **bit-level precision alignment**. Raw pointer + size interface. Zero external dependencies — pure C++17 standard library.
17
+
18
+
All APIs are tested against Python numpy under strict bit-level comparison: every IEEE 754 float bit must match exactly. Where bit-exact parity is unattainable due to differing math library implementations (1‑ULP), it is documented explicitly.
17
19
18
20
## Quick Start
19
21
@@ -75,14 +77,81 @@ Add `-Ipath/to/numpycpp` to your compiler flags and include the headers directly
75
77
76
78
### Testing
77
79
78
-
The test suite verifies pixel-level precision alignment between every C++ function and Python numpy.
80
+
The test suite verifies **bit-level precision alignment** between every C++ function and Python numpy.
81
+
No tolerance, no `atol`/`rtol` — raw IEEE 754 bits must match exactly.
79
82
80
83
```bash
81
84
cd tests
82
-
make # compile test module
83
-
make test# run all 336 tests
85
+
make # compile C++ test module
86
+
make test# run all tests (default: 337 tests, float64 + float32)
84
87
```
85
88
89
+
**API category filter** — limit tests to specific API groups via env var:
90
+
91
+
```bash
92
+
# Run only creation + reduction APIs (zeros_like, sum, mean, etc.)
93
+
NUMPYCPP_TEST_APIS=creation,reduction make test
94
+
95
+
# Run only elementary math (sqrt, exp, sin, pow, etc.)
> **Why 1‑ULP?** The C++ standard library (`std::exp`, `std::log`, etc.) and numpy's underlying libm may use different polynomial approximations or rounding strategies, leading to a single-bit difference in the last place. This is inherent to the math library, not a bug in `numpycpp`.
154
+
86
155
## Project Structure
87
156
88
157
```
@@ -95,10 +164,12 @@ numpycpp/
95
164
│ ├── core_py.h
96
165
│ ├── linalg_py.h
97
166
│ └── einsum_py.h
98
-
├── tests/ # precision tests + test module
167
+
├── tests/ # bit-level precision tests + test module
99
168
│ ├── module.cpp # pybind11 module for testing
100
-
│ ├── Makefile
101
-
│ └── test_*.py
169
+
│ ├── test_all.py # single entry — all APIs, float64+float32
0 commit comments