This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Bertini 2 (b2) is a C++17 numerical algebraic geometry library with Python bindings. It implements homotopy continuation for solving polynomial systems, including path tracking, endgames (power series, Cauchy), and start systems (total degree, multihomogeneous). The Python package is published to PyPI as bertini.
# Configure (from repo root)
cmake -DENABLE_UNIT_TESTING=ON -G Ninja -B build -S .
# Build
cmake --build build --target all --config Release
# Run all C++ tests
ctest --test-dir build/corepython3 -m build --wheelThe build system uses scikit-build-core (configured in pyproject.toml). The wheel build invokes CMake internally.
brew install gmp mpfr libmpc eigen@3 eigenpy boost boost-python3Use environment.yml (Ubuntu) or environment-win.yml (Windows) with conda/mamba/micromamba.
Tests are defined in core/CMakeLists.txt. Each test suite is a separate executable:
# All tests
ctest --test-dir build/core
# Individual test executables (after build)
./build/core/test_classes
./build/core/test_blackbox
./build/core/test_classic
./build/core/test_endgames
./build/core/test_generating
./build/core/test_nag_algorithms
./build/core/test_nag_datatypes
./build/core/test_tracking_basics
./build/core/test_settingspytest python/test/The project has three layers, built in order:
-
core/-- C++ shared library (libbertini2). Header-only-heavy design undercore/include/bertini2/. Key subsystems:function_tree/-- Expression tree (nodes, operators, symbols) for representing polynomial systemssystem/-- Polynomial system construction, start systems (start/total_degree.hpp,start/mhom.hpp), patches, slicestrackers/-- Path tracking (fixed-precision and adaptive-precision trackers, predictors, Newton correctors)endgames/-- Power series and Cauchy endgames for singular endpoint handlingnag_algorithms/-- Higher-level algorithms (zero-dim solve, numerical irreducible decomposition)io/parsing/-- Boost.Spirit Qi parsers for classic Bertini input formatblackbox/-- CLI executable entry point (bertini2_exe)
-
python_bindings/-- Boost.Python + eigenpy bindings producing_pybertininative module. Each*_export.cppwraps the corresponding C++ subsystem. Depends oneigenpyfor NumPy/Eigen interop. -
python/bertini/-- Pure Python package that wraps_pybertiniinto a user-friendly API. Submodules mirror the C++ structure:function_tree,system,tracking,endgame,parse,nag_algorithm,multiprec, etc.
- GMP/MPFR/MPC -- Arbitrary-precision arithmetic (found via custom CMake modules in
cmake/) - Eigen 3.3 -- Linear algebra (pinned to v3.3)
- Boost (serialization, filesystem, log, graph, regex, timer, chrono, thread, unit_test_framework, python) -- Boost >= 1.82 required;
boost_systemis conditionally linked for Boost < 1.89 - eigenpy -- Eigen/NumPy bridge for Python bindings
- jrl-cmakemodules -- CMake helper macros (auto-fetched via FetchContent if not found)
- The root
CMakeLists.txtusesjrl-cmakemodules(fetched automatically). It currently only addscore/as a subdirectory;python_bindings/andpython/subdirectory calls are commented out (the wheel build via scikit-build-core handles them). pyproject.tomlconfigures scikit-build-core: wheel packages frompython/bertini/, build dir isbld/.- Cross-platform: Linux uses manylinux Docker +
auditwheel; macOS uses Homebrew; Windows uses conda + clang-cl (MSVC has template compilation issues). -Werroris disabled globally.-pedanticis stripped from flags.
.github/workflows/build-and-publish-to-pypi.yml-- Builds wheels on Ubuntu/macOS/Windows, publishes to TestPyPI ondeveloppush, PyPI on version tags (v*.*.*).- Pushes to
developtrigger TestPyPI publish; tagged releases go to PyPI with Sigstore signing and GitHub Releases.
- C++ standard: C++17. Headers use
.hppextension. - License: GPL v3 with additional terms (see
licenses/,core/ADDITIONAL_GPL_TERMS). - Version is tracked in
python/bertini/_version.pyandpyproject.toml.