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 scaled_preconditioners

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.1.tar.gz (5.2 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.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scaled_preconditioners-0.1.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.16 Linux/5.15.0-1035-azure

File hashes

Hashes for scaled_preconditioners-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b6f58f225eec199236169eb42fe7fbf8147afcf1a3dbf97e9d7289191d5e3942
MD5 8170317417268f5bac3a24f7f625545a
BLAKE2b-256 006e2e8c5b6d4117eb0018a297cf9385fc4ade9a99e83b5f014adeddcf686ad2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for scaled_preconditioners-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3eee8d927c3c0564577514af55abf0defea81d5406cbdb161b40ece835e20232
MD5 ad1a4314a06b0de5fdfd8d7c7387ed8d
BLAKE2b-256 2b9b38fb13aa90853a907785bc0237ba0ba2ba9f7801c3bc7a11e360b9e50c90

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