Skip to main content

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

Project description

cholrot

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.

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.1.tar.gz (35.7 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.1-cp314-cp314-win_amd64.whl (102.8 kB view details)

Uploaded CPython 3.14Windows x86-64

cholrot-0.1.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (144.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

cholrot-0.1.1-cp314-cp314-macosx_11_0_arm64.whl (101.5 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

cholrot-0.1.1-cp314-cp314-macosx_10_13_x86_64.whl (108.1 kB view details)

Uploaded CPython 3.14macOS 10.13+ x86-64

cholrot-0.1.1-cp313-cp313-win_amd64.whl (100.9 kB view details)

Uploaded CPython 3.13Windows x86-64

cholrot-0.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (144.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cholrot-0.1.1-cp313-cp313-macosx_11_0_arm64.whl (101.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cholrot-0.1.1-cp313-cp313-macosx_10_13_x86_64.whl (108.0 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

cholrot-0.1.1-cp312-cp312-win_amd64.whl (100.9 kB view details)

Uploaded CPython 3.12Windows x86-64

cholrot-0.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (144.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cholrot-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (101.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cholrot-0.1.1-cp312-cp312-macosx_10_13_x86_64.whl (108.0 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: cholrot-0.1.1.tar.gz
  • Upload date:
  • Size: 35.7 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.1.tar.gz
Algorithm Hash digest
SHA256 2dbe000626b297aa6e9c1be23f48102f4ced522b58607463c1744f88ffdaceb1
MD5 f334b5e9b55bc26d35336b62a4367875
BLAKE2b-256 5fc614ec9ddefd7f198cbb5f85a80699a79c71104f573bff6dea3d87b529f77f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1.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.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: cholrot-0.1.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 102.8 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.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 e73263158f8710d828c1ed7e9e07be33721be225ef8ee44d2e4ccf01eef1543b
MD5 f34aaf0a81bcf99b061950f539fe69b2
BLAKE2b-256 804a76bcecdec726843712d4549b031617b152835ea8e1ab51c1bfe28707d679

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 507c12554b7ded679438c54653cfb1a6fdf4bd942f8b92e23e45774afc44eb85
MD5 e79142d2664c8bd1cfcde67cf46cd380
BLAKE2b-256 0f20048c289b5dc0b1cfef2c429018f936cf3a5accf18583e3f6c7659ffdd169

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33061d3c870322d60d3bcdb2be030594242c9fdbaff26056370e9c591a59322b
MD5 196707dcb1b0c5c7a9ee0d5d2c03062d
BLAKE2b-256 7c1f52524c2ad5a2b3410d79d1a4a5ce5f315fd7e0c413753f98dc7df7d0afb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp314-cp314-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.1-cp314-cp314-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 052c9abdfc0e4a647d63815c9283fcb8dcc447ea5dab32577e41d7b01040d70e
MD5 1e8bd243f406426e6c24383ee080a7b1
BLAKE2b-256 649aa6672ed88ab40386106c38d4dfe892642b1bc16f22035694a02d872fe331

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: cholrot-0.1.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 100.9 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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8cfbf1276da47ea853f58bb43a8e4c3e670d05bf78fce56588cc3d9875835fba
MD5 c29c4c8963fd89e8fcd8785266c29818
BLAKE2b-256 c7fd43c9c466a92f4bd7edb99cb95d97e6465d85a56e2ce292618b13b38a0106

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 62d297c7140538f4f654e5cf6ca1c7fe6b79f3855050dda0de8d086967bff6f3
MD5 291c0dfe4677bfc7ca503cbe9da8cc6f
BLAKE2b-256 2b68ce9b3a5e5a8daee1841e5e5183a6ea1aae18f8149c59e0a6f4f7df1e66bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56f957c28738b1ba8a1a3d2d925e0715691136ba1bda898110f2164a967f2c82
MD5 160d9eb984dc7e067ba3c20a9d1f328f
BLAKE2b-256 1d6c9a85d5b05b26464e3d9de26faa4de32f266f35920d98291cc5e5369373a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b24148c7673ebfc2309636455447ef73dc0969359d57d1ea1423eea1e165e8cb
MD5 41ed20ab6fcff06cd9fa70decfcb1e80
BLAKE2b-256 792464eac8bfb9c343d65d31846afc96dec7317a56b3325f0b9ec54aab7da74b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: cholrot-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 100.9 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 410973fbe094eeca37b30ca8d15734e36d585093eae37e971ed7bc08416f23bc
MD5 b1330c6b6783df152f8d1965518b87f7
BLAKE2b-256 d6a23f18d3a50d397853e66b3b7c798ea25d0d8c1e9a032bf992011254459127

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0d9d46246235a46264cc09c0c2be3bad68fbeff264b0c6db079e21b8d45619cd
MD5 0dab325ed111cf2696873443c3ca021a
BLAKE2b-256 fdeedb537a650688e5b24eace833554e1065753ccd5f12d317e768b879af30b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ff625736884ba2d6538b828d763287931ec3cc0e2f2543694231f64419973ae
MD5 1ac5d0a82c0656bbec81004a0e4f2656
BLAKE2b-256 b54958b856bc68e5c7453d84277b309b4ac10ea3d1c3011bb5937acbbd5e8415

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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.1-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for cholrot-0.1.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 69470e77a68e1b88c63bd0093881459769662e88c247378dfb8e4ccd541a94e0
MD5 12d2b688a311fef2e40ecfd62203ec85
BLAKE2b-256 51200554b7c0ea1eb661ceb0bc2af5eb38762c424de8cb5c84401da473e22299

See more details on using hashes here.

Provenance

The following attestation bundles were made for cholrot-0.1.1-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