Skip to main content

No project description provided

Project description

Preconditioner Design via Bregman Divergences

This package implements the preconditioners in [1]. A simple use case is demonstrated below. See examples/example_pcg.py for a demo of all the preconditioners defined in this package.

[1] TODO

Build Status

Tests

Installation

pip install bregman_approx

A simple example

Define some parameters

dimension = 100
psd_rank = 50

Construct S = A + B

F = csc_matrix(np.random.rand(dimension, psd_rank))
B = F @ F.T
Q = csc_matrix(np.random.rand(dimension, dimension))
S = Q @ Q.T + B

Construct the preconditioner

Here we use a randomised SVD, other options include truncated SVD, the Nyström approximation. There is support for oversampling and power iteration schemes.

rank_approx = 15
pc = compute_preconditioner(
    Q,
    B,
    algorithm="randomized",
    rank_approx=rank_approx,
    n_oversamples=4,
    n_power_iter=0,
)

Set up a right-hand side

rhs = np.random.rand(dimension)
counter = ConjugateGradientCounter()

Solve Sx=b with and without a preconditioner

_, info = linalg.cg(S, rhs, callback=counter)
print("No preconditioner:")
print(f"\t Converged: {info == 0}")
print(f"\t Iterations: {counter.n_iter}\n")

counter.reset()
_, info = linalg.cg(S, rhs, M=rsvd_pc, callback=counter)
print("Randomised SVD preconditioner:")
print(f"\t Converged: {info == 0}")
print(f"\t Iterations: {counter.n_iter}\n")

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

scaled_preconditioners-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

scaled_preconditioners-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scaled_preconditioners-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.16 Darwin/21.6.0

File hashes

Hashes for scaled_preconditioners-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bfd9ff9830ad08339f429bcdf06250430cd82e5dadbcf66fd5619229f6aa5902
MD5 2bf99f8686f17ccd2e461456ab6a17d2
BLAKE2b-256 622154722216760990ba0c7f2e51f35a361b08a768ac875ebe9f9f502f41e5d7

See more details on using hashes here.

File details

Details for the file scaled_preconditioners-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for scaled_preconditioners-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6535659b3b04a928832fcb0cb6e602c183591c82eb550f534b1d26d5fb39d3e6
MD5 74ff5a6ad6af49f3132b3306eb28db77
BLAKE2b-256 ddd1700bb0d5025dff2038a5c630a57d6f8bb9f28fccd575a3116762c8f65102

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