Skip to main content

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

  1. Write the real implementation in include/vecta/<chapter>/<chapter>.hpp (and .cpp if needed).
  2. Expose it to Python in bindings/<chapter>_bindings.cpp.
  3. Delete the placeholder() smoke tests in tests/cpp/<chapter>/ and tests/python/<chapter>/, replacing them with real tests.
  4. CMake picks up new .cpp files automatically on the next build (globbing with CONFIGURE_DEPENDS) — no need to edit CMakeLists.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vecta_math-0.0.1.tar.gz (10.0 kB view details)

Uploaded Source

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

Hashes for vecta_math-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0f572e824eac7711a55c117db289e76849e5a14fbb5b22538a9086e0f4d89a43
MD5 71602b2faa260bb01a3e245042d61351
BLAKE2b-256 58fa645d5626898533bda04f66337ad5e9cdf1fe19180cbd5cdad14bc64877c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page