A from-scratch computational maths library (following Mathematics for Machine Learning) with a C++ core and Python bindings
Project description
Vecta
A computational maths library for ML, built from scratch in C++ with Python bindings, structured chapter-by-chapter after Mathematics for Machine Learning (Deisenroth, Faisal, Ong).
Stack
- C++17 core (no external maths dependencies — everything implemented from scratch)
- pybind11 for Python bindings
- scikit-build-core + CMake for packaging
- uv for the Python venv and all package installs (no pip commands)
- Catch2 for C++ unit tests
- pytest for Python-level tests
Layout
Each chapter gets matching folders across headers, sources, bindings, the Python package, and both test suites:
include/vecta/<chapter>/ C++ headers
src/<chapter>/ C++ implementation
bindings/<chapter>_bindings.cpp pybind11 binding code for that chapter
python/vecta/<chapter>/ Python package wrapper
tests/cpp/<chapter>/ Catch2 tests
tests/python/<chapter>/ pytest tests
Chapters (folder name → book chapter):
| Folder | Book chapter | Status |
|---|---|---|
linear_algebra |
Ch 2 — Linear Algebra | Vector implemented |
analytic_geometry |
Ch 3 — Analytic Geometry | stub |
matrix_decompositions |
Ch 4 — Matrix Decompositions | stub |
vector_calculus |
Ch 5 — Vector Calculus | stub |
probability |
Ch 6 — Probability and Distributions | stub |
optimization |
Ch 7 — Continuous Optimization | stub |
linear_regression |
Ch 9 — Linear Regression | stub |
dimensionality_reduction |
Ch 10 — Dimensionality Reduction (PCA) | stub |
density_estimation |
Ch 11 — Density Estimation (GMM) | stub |
classification |
Ch 12 — Classification (SVM) | stub |
"stub" means: it compiles, links, imports from Python, and has a smoke test —
so the whole pipeline stays green as you go. Replace placeholder() with real
content in the header/source/bindings/tests for a chapter as you study it.
examples/ is free scratch space for worked examples from the book.
Adding real content to a stub chapter
- Write the real implementation in
include/vecta/<chapter>/<chapter>.hpp(and.cppif needed). - Expose it to Python in
bindings/<chapter>_bindings.cpp. - Delete the
placeholder()smoke tests intests/cpp/<chapter>/andtests/python/<chapter>/, replacing them with real tests. - CMake picks up new
.cppfiles automatically on the next build (globbing withCONFIGURE_DEPENDS) — no need to editCMakeLists.txt.
Dev workflow (uv-based, no pip)
Activate the venv created by setup_vecta.sh:
source .venv/bin/activate
Rebuild + reinstall the Python module after changing C++ code:
uv pip install -e . --no-build-isolation
Run Python tests:
pytest
Run C++ tests (separate dev build, not part of the Python wheel).
A plain cmake invocation doesn't automatically know where pybind11's CMake
config lives the way pip/uv pip install does, so point it there explicitly:
PYBIND11_CMAKE_DIR=$(python -c "import pybind11; print(pybind11.get_cmake_dir())")
cmake -S . -B build-tests -DVECTA_BUILD_TESTS=ON -DCMAKE_PREFIX_PATH="$PYBIND11_CMAKE_DIR"
cmake --build build-tests
ctest --test-dir build-tests --output-on-failure
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file vecta_math-0.0.1.tar.gz.
File metadata
- Download URL: vecta_math-0.0.1.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f572e824eac7711a55c117db289e76849e5a14fbb5b22538a9086e0f4d89a43
|
|
| MD5 |
71602b2faa260bb01a3e245042d61351
|
|
| BLAKE2b-256 |
58fa645d5626898533bda04f66337ad5e9cdf1fe19180cbd5cdad14bc64877c1
|