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.

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

Uploaded CPython 3.14Windows x86-64

cholrot-0.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (144.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

cholrot-0.1.0-cp314-cp314-macosx_11_0_arm64.whl (101.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

cholrot-0.1.0-cp314-cp314-macosx_10_13_x86_64.whl (108.0 kB view details)

Uploaded CPython 3.14macOS 10.13+ x86-64

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

Uploaded CPython 3.13Windows x86-64

cholrot-0.1.0-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.0-cp313-cp313-macosx_11_0_arm64.whl (101.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

cholrot-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl (107.9 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

cholrot-0.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (143.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cholrot-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (101.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

cholrot-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl (107.9 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: cholrot-0.1.0.tar.gz
  • Upload date:
  • Size: 35.5 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.0.tar.gz
Algorithm Hash digest
SHA256 f4d2afff0e9071941eceb1229ab05d3d91a0fa7a5ec4775cfbb2369bc55c48cf
MD5 7fef9f02afc418fbed3fd39c8d6e6259
BLAKE2b-256 ee2e008276838c8bf3c842c2aec84075f03c40ede8683acf52854d76a4a2c4c6

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: cholrot-0.1.0-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.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 0d3219c675e10f7e686401a159f5adf96c209c819dc57f2c91933062e2a52d29
MD5 2964a06cb8e5fe967798d5952adf61a8
BLAKE2b-256 76bd2b4a9ee110e2466ddc7eb592077bf4ec6d59b69269834fbe543a8abd21f3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cholrot-0.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 db96cfedb7355a6e15753edcb5178cf85641f804926ea5067183665226180d52
MD5 8d7c4f49dd8a7edf368a5fa857c21434
BLAKE2b-256 8eddc5b0a6758ffa16320340b425285139b299b66b06e7321939055331c52dd7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cholrot-0.1.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b2e1646e99e3239a365153ea5a1c1b6c4f290f21ec8f07af7db2831599796e4
MD5 a234e0216cb193f560cc13de52b3913a
BLAKE2b-256 7c3bcf09a1dca394040eaff2b3b2c5e1293424d6c8a805e4036d329a2dc1d394

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cholrot-0.1.0-cp314-cp314-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ffd994c8e56d0cfd3139d8499ba1e3a323907f78c93fa4d186dc26330fba73b1
MD5 a6fd9e575de9fc6d66e8608fcf40531b
BLAKE2b-256 2805b867d7bdc2b795218e9d932b146ff70cb75ce14cccf0ab938b374c69754e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: cholrot-0.1.0-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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1c9881ec26bee5af7d1308fcf573fb4705eb614fe4b88c42d5e330d6d0593164
MD5 78e6dad5dd94d6f97c37f2423d99b84d
BLAKE2b-256 db4811434d88b9990b3275efeb90165603cea3e5b76a516424e55e40917189ed

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cholrot-0.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 057d6450b03b3588cd4f4ed2b7fe8c1151635e0a12cecd0f872a505dae0cfd26
MD5 3864bc6620dedc6478b3b20279b81fc9
BLAKE2b-256 c2225910c9197f4de4835026b66e74477344d89993dd19d3dc693d38072cb954

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cholrot-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c6e295a2e363636f2f141cee8070ebc6e8ff00dc4eed06dcc81d8df7e9a23c12
MD5 445d113f10989267f53eb23fe8e66041
BLAKE2b-256 9f7465f132b78cbfb8597259e05a6175dea4912257e151732dfce436505b7fd0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cholrot-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 01c1906ab0b131b189ec8774e67a89b77c44f2bbda3afbe8c070d4c619ae732a
MD5 28a658936e87d6ddf98d095de6fe5d2d
BLAKE2b-256 96f35e2363bcdcb3ea7f018dcd00fdd4bb41c2e77e407cc6d77e997f9a88e2e9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: cholrot-0.1.0-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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 73a365ef6a9d47dbbf665c30c8ea028a487caffacfed0f70bc44ae86a926e2cc
MD5 6e2882b936532e42fe612307c37998a4
BLAKE2b-256 cf633b486bfee2a41f3ddc517f700d276667f3caf8f4fadb934409704f5d9c41

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cholrot-0.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 da94fe995b921f7becbed8dfcd787e0643a26b3b41de90c457246b2252136378
MD5 f0b5ec500602486990a030738585a36e
BLAKE2b-256 7584c39e981992276ac1362e20275f27b2179fe2fa2ab478804a93c2f538e899

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cholrot-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5694ae21f1a8529900245be21b6c285f95135ac7b10ac8c2daa2adf25fd69ef
MD5 5509f2b414b1b693222df39d9198a4f2
BLAKE2b-256 eee83bbe316ae711178bc3c555040592a5fc74d1672ed9e9df14df553c73f2e3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cholrot-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 02c76e7b9c9f57f51c2a3797a0c39d0d1c4442c840c60c38db1cef81fb445af9
MD5 cc9831067567e2985314aaf0f9aca75b
BLAKE2b-256 a60ec14c1817cf458e15f47e600548ab7904c1d08529762e2cf391670e53673d

See more details on using hashes here.

Provenance

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