Skip to main content

CI codecov License

PyLanczos

Overview

PyLanczos is a Lanczos diagonalization library. Its core part is written in C++ as LambdaLanczos.

Usage

All samples are available here.

NumPy and SciPy matrix

matrix = np.array([[2.0, 1.0, 1.0],
                   [1.0, 2.0, 1.0],
                   [1.0, 1.0, 2.0]])

engine = PyLanczos(matrix, True, 2)  # Find 2 maximum eigenpairs
eigenvalues, eigenvectors = engine.run()
print("Eigenvalue: {}".format(eigenvalues))
print("Eigenvector:")
print(eigenvectors)

Note: Use of SciPy sparse matrix is recommended to take full advantage of Lanczos algorithm.

Customized operation

You can also attach your customized function:

tensor = np.zeros((2, 2, 2, 2), dtype='float64')
tensor[0, 0, 0, 0] = 1
# and so on...

## Matrix-vector (or tensor-matrix) multiplication function
def mv_mul(v_in, v_out):
    v_in.shape = (2, 2)
    v_out.shape = (2, 2)

    np.einsum("ijkl, kl -> ij", tensor, v_in, out=v_out, optimize="optimal")

## Calculate an "eigenmatrix" for the 4th-order tensor.
engine = PyLanczos.create_custom(mv_mul, n, 'float64', False, 1) # Find 1 minimum eigenpair
eigenvalues, eigenmatrices = engine.run()
eigenmatrices.shape = (2, 2)
print("Eigenvalue: {}".format(eigenvalues))
print("Eigenmatrix:")
print(eigenmatrices)

There is a full sample with detailed description.

Installation

pip install pylanczos

Requirements

C++11 compatible environment

License

MIT

Author

mrcdr

PyPI repository

pylanczos

Metadata

Release files for pylanczos 2.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylanczos 2.1.2
File Size Uploaded Provenance Actions
pylanczos-2.1.2.tar.gz 20.8 kB Without provenance Details for pylanczos-2.1.2.tar.gz

Release files / pylanczos-2.1.2.tar.gz

Download URL pylanczos-2.1.2.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a6b86f2af8175c4dc316e1b9e389914ecb9e07973920e36352aac3176c09abd8
BLAKE2b-256 checksum
How to use checksums
058dd4dbcda62dbaf8a749c13848a62d67ba7d5f275c70a63c41201dba7b2f62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for pylanczos 2.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page