Skip to main content

Rank-one Cholesky update/downdate, implicit factor-vector products, and rank-one Cholesky solves.

Project description

cholrot

DOI

cholrot is a small experimental NumPy package for rank-one Cholesky updates/downdates, implicit modified-factor products, and rank-one modified Cholesky solves.

The package is intentionally narrower than MATLAB-style cholupdate: besides returning the modified Cholesky factor, it exposes operations that avoid forming intermediate matrices when you only need a product or a solve.

Why this exists

Suppose R is a Cholesky factor of a positive definite matrix A:

  • upper convention: A = R.T @ R, or
  • lower convention: A = L @ L.T.

After a rank-one modification

A_new = A + alpha * z z.T,       alpha in {+1, -1}

it is often wasteful to build A_new, recompute its Cholesky factor, and then multiply or solve. cholrot provides:

  • update(...): materialize the modified Cholesky factor D.
  • downdate(...): convenience wrapper for alpha=-1.
  • matvec(...): compute D @ v directly, without materializing D.
  • cholsolve(...): solve (A + alpha*z*z.T) x = b without materializing A_new or D.
  • logdet_rank1(...): compute the modified log determinant.

The public API is Python, but the package is designed around compiled kernels. When the pybind11 extension is available, update(...), matvec(...), and cholsolve(...) dispatch to C++ implementations; otherwise they fall back to the reference NumPy/Python implementation. cholsolve(...) uses triangular solves and the rank-one inverse identity, so it avoids forming both the modified matrix and the modified factor.

Binary wheels

Release wheels are built with GitHub Actions and cibuildwheel for:

  • CPython 3.12, 3.13, and 3.14;
  • Linux manylinux2014 x86_64;
  • macOS Intel and Apple Silicon;
  • Windows 64-bit.

For most users this means a normal install should use a prebuilt wheel:

python -m pip install cholrot

The source distribution remains available for platforms not covered by the release matrix, provided a C++17 compiler and pybind11-compatible build environment are present.

Compile from a local checkout

The pybind11 extension is compiled automatically when you install from the repository. You need a C++17 compiler: g++/clang++ on Linux, Xcode Command Line Tools on macOS, or Microsoft C++ Build Tools on Windows.

python -m pip install --upgrade pip
python -m pip install -e .[test]
pytest
python -c "import cholrot; print(cholrot.backend())"

A successful compiled install prints:

cpp

To compare against the reference NumPy/Python backend:

CHOLROT_PURE_PYTHON=1 pytest

Build release artifacts with:

python -m pip install build twine
python -m build
python -m twine check dist/*

C++ / pybind11 backend

The C++ backend lives in src/cholrot/_core_ext.cpp and is built with pybind11. It currently mirrors the tested Python algorithms for:

  • materialized rank-one update/downdate via update(...);
  • direct modified-factor products via matvec(...);
  • rank-one modified solves via cholsolve(...);
  • upper and lower Cholesky conventions;
  • method="hy", method="hc", and method="algorithm_a".

You can check the active backend at runtime:

import cholrot
print(cholrot.backend())  # "cpp" or "python"

For debugging or correctness comparisons, force the reference backend with:

CHOLROT_PURE_PYTHON=1 pytest

Minimal example

import numpy as np
from cholrot import downdate, matvec, cholsolve, identity_matvec

rng = np.random.default_rng(0)
n = 6
A = rng.normal(size=(n, n))
A = A.T @ A + n * np.eye(n)
R = np.linalg.cholesky(A).T          # upper Cholesky factor: A = R.T @ R
z = 0.1 * rng.normal(size=n)
v = rng.normal(size=n)

D = downdate(R, z, method="hy")      # D.T @ D = R.T @ R - z z.T
w = matvec(R, z, v, method="hy")     # same as D @ v, but D is not formed
x = cholsolve(R, z, v, alpha=-1)     # solve (A - z z.T) x = v

np.testing.assert_allclose(w, D @ v)
np.testing.assert_allclose(
    x,
    np.linalg.solve(A - np.outer(z, z), v),
)

API conventions

By default, cholrot uses the upper Cholesky convention:

A = R.T @ R

Set lower=True for the lower convention:

A = L @ L.T

Supported methods:

  • method="hy": hyperbolic-rotation form.
  • method="hc": Chambers-style hyperbolic-cosine variant.
  • method="algorithm_a": Algorithm A variant.

Non-regression tests

The test suite has two layers:

  1. property-style correctness tests comparing update, downdate, matvec, cholsolve, and logdet_rank1 against NumPy references;
  2. golden-value regression tests in tests/test_regression.py to catch silent changes in sign conventions, lower/upper orientation, or recurrence details.

Recommended release checks:

pytest
CHOLROT_PURE_PYTHON=1 pytest

The GitHub Actions workflow runs both the compiled/default backend and the pure Python backend on Linux, macOS, and Windows.

Benchmarks

Run local dense rank-one benchmarks with:

python benchmarks/bench_rank1.py --sizes 100 200 400 800 1600 --repeat 5
python benchmarks/bench_rank1.py --csv benchmarks/results/local.csv

This benchmark compares three routes for computing w = D @ v:

  1. recompute Cholesky with NumPy, then multiply;
  2. materialize the modified factor with cholrot.downdate, then multiply;
  3. compute D @ v directly with cholrot.matvec.

For the identity-structured case,

D D.T = I + alpha * z z.T,

run:

python benchmarks/bench_identity.py --sizes 100 200 400 800 1600 3200 6400 --repeat 5

Benchmark tables should report the CPU, OS, Python version, NumPy version, thread settings, cholrot.backend(), matrix size, and the three timings above. The current C++ backend is single-threaded; NumPy may use a multithreaded BLAS or LAPACK backend. For this reason, both single-threaded BLAS and default local thread settings are useful benchmark modes.

The intended benchmark conclusion is not "cholrot always beats MKL". The claim is narrower: for rank-one modified workflows, cholrot can avoid full recomputation and can compute products or solves without materializing the modified factor.

Documentation

The repo includes a Sphinx documentation skeleton in docs/, suitable for Read the Docs. Build it locally with:

python -m pip install -e .[docs]
sphinx-build -b html docs docs/_build/html

Keep the package README short and practical. Put the algorithm derivations, math, API reference, and benchmark methodology in the Sphinx docs.

Development status

This is an alpha-stage scientific package. The first public release focuses on rank-one Cholesky update/downdate routines, direct modified-factor products, and rank-one modified solves through a tested C++/pybind11 backend with a Python fallback.

The package implements known numerical linear algebra algorithms. The public contribution is the packaging, API design, correctness tests, benchmarks, and the focus on product/solve routines that avoid unnecessary materialization.

License

cholrot is licensed under the Apache License, Version 2.0. See LICENSE and NOTICE.

The software is provided on an "AS IS" basis, without warranties or conditions of any kind. Users are responsible for validating numerical behavior in their own applications.

Contributions are accepted under the same Apache-2.0 license; see CONTRIBUTING.md. Maintainer release steps are documented in RELEASE.md.

Disclaimer

This is an independent open-source project developed in my personal time and is not affiliated with my employer.

References

Useful background and comparison points include:

  • LINPACK Cholesky update/downdate routines, including DCHUD and DCHDD.
  • Seeger, M. Low Rank Updates for the Cholesky Decomposition.
  • MATLAB cholupdate.
  • JAX jax.lax.linalg.cholesky_update.
  • TensorFlow Probability tfp.math.cholesky_update.

Citation

If you use cholrot, please cite the archived Zenodo release:

Miryusupov, S. (2026). cholrot: Rank-one Cholesky update/downdate routines for Python/C++ (v0.1.1). Zenodo. https://doi.org/10.5281/zenodo.20382065

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

cholrot-0.1.3.tar.gz (36.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cholrot-0.1.3-cp314-cp314-win_amd64.whl (103.0 kB view details)

Uploaded CPython 3.14Windows x86-64

cholrot-0.1.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (144.2 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

cholrot-0.1.3-cp314-cp314-macosx_11_0_arm64.whl (101.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

cholrot-0.1.3-cp314-cp314-macosx_10_13_x86_64.whl (108.3 kB view details)

Uploaded CPython 3.14macOS 10.13+ x86-64

cholrot-0.1.3-cp313-cp313-win_amd64.whl (101.1 kB view details)

Uploaded CPython 3.13Windows x86-64

cholrot-0.1.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (144.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cholrot-0.1.3-cp313-cp313-macosx_11_0_arm64.whl (101.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cholrot-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl (108.1 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

cholrot-0.1.3-cp312-cp312-win_amd64.whl (101.1 kB view details)

Uploaded CPython 3.12Windows x86-64

cholrot-0.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (144.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cholrot-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (101.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cholrot-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl (108.1 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

File details

Details for the file cholrot-0.1.3.tar.gz.

File metadata

  • Download URL: cholrot-0.1.3.tar.gz
  • Upload date:
  • Size: 36.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cholrot-0.1.3.tar.gz
Algorithm Hash digest
SHA256 30426d4f3d200f3c8bdcdc98d8a0342b39f1289241b29e1d5a7a257b8f530c46
MD5 c38ccf2d13b52667dbe0dc4a68486da9
BLAKE2b-256 5984782cdbd865bf7d0c820f12b48f3420b58574f58069512de3d7952e8804d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3.tar.gz:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: cholrot-0.1.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 103.0 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cholrot-0.1.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1ea3733d98debfcbbf4a3b1862ec5458ee4ca0c1a35100814e8cd85e1e5f6563
MD5 18312f8c2dba4c4ff1bd5ff67856a7bf
BLAKE2b-256 fd05c60169d8da121458409900ea1f2fe097e16ec33f8a454d14ca3321d242b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp314-cp314-win_amd64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c346e9dd91f83201cb16d9ecfd228d72e3460cec2f742ad113709ebca9ba23ab
MD5 57d0b021048ba08ca1e3c2a358d552e1
BLAKE2b-256 8de1f3969f17f689f8058edfa5b7ff5afee767fd69931bb7d30aed049a403c9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9d422942c408ab6745a0f3b1938438bcae1deb84ea659f5c93acb88f14e6a3b
MD5 bd146f84d69394a848329045563bee55
BLAKE2b-256 269fcb00956111aabd586b47b1b03cf1f9c84230a44d8aee2e7765546e12cd82

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp314-cp314-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.3-cp314-cp314-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ecf8e10a16df237bd1ab3c86a02572edb7d94c25711e70d4e90e898c195ca558
MD5 445ad2731b61526a1c5b3d291f3c1fe4
BLAKE2b-256 4f888a06ed7f1808e5565789d6b5a4185b1693b65f8a7712343af76a1c958322

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp314-cp314-macosx_10_13_x86_64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: cholrot-0.1.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 101.1 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cholrot-0.1.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2b49141c01cdd4270193071c3231516a91f4d2c42cbaf15219e5146ba30b3531
MD5 3c869521d9a7465ba929cf26cbdd24d7
BLAKE2b-256 5b1022221a66a19fc34b19ea68a0356dcd639b1f742a50d734ed1164775a6a59

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp313-cp313-win_amd64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 1e65fa7ff7f4ca91f2a8b4c9864c2c2a183589b5f05443cad394e5d1db1adac0
MD5 0fc6006f74e72d3ee2e335952f5e1b03
BLAKE2b-256 6da7b7ccb7a059f8b3c27f4503451677a6202e8cb82110f76eb54c43ffa16c8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 86d6f514d24d2e454811ed0dfa6998843582bb95a39160ecdf37d0139165ff1d
MD5 74c267e2397e77d33039c1f581aab2d0
BLAKE2b-256 437b656305e8efbc3d71491571444908a76278ad40d85c1a8434ff20a22443f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d7d01e311f60b1c3ebca730df0d79b6d3d6b1e2883adb808e9d3a7de842710f0
MD5 c166dd35ac923c83e0888267ae496533
BLAKE2b-256 dedff48c9e113fefac847fe27defd1e6c9cdff930143f175e9d00683ba659446

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: cholrot-0.1.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 101.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cholrot-0.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 015d0c95912d6d381081165c31ab1509435406031ba7feaec620c285e50549ed
MD5 8aeb159373988f65d08fbe940af1d25d
BLAKE2b-256 1c461387f56b2a0d4a1f9cc4bdf435ecaf754e6ae807e49dd8b8a730990d4f1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 27202d82ae8cb11610e5640859e41f9194f4011219331a5e348cec03fc039cde
MD5 581b89bcf242ef0c06dd4c2ba1248549
BLAKE2b-256 d1f9ff7a62bb792e33e6cd4e2a0e3874536c2d1669dd0ca2dae8a933fbcf1bdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1c58bf098334519977e92649096fac83a07d343d2af8569f00159e337530f1ef
MD5 a81635e3a60e4a556199d195eb22e1a3
BLAKE2b-256 6a4422420bae880b339281880e0a6edc40f0b324ab78f58d355058852ba2f4e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cholrot-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d47342c586c652fbf4471b6a1550810858ab71559510c52b241cad5110cd92da
MD5 d61080b037d074cb481974a59d410b5a
BLAKE2b-256 ba351000dfebffc32dd7e898fc4a90d37025348735df31320d3f49474484855a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: wheels.yml on smiryusupov/cholrot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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