Skip to main content

A package dedicated to lazy linear operators based on diverse backends/libraries.

Project description

Lazylinop

License Downloads Downloads PyPI version

Lazylinop is a python toolbox to ease and accelerate computations with ("matrix-free") linear operators. It provides glue to combine linear operators as easily as NumPy arrays, PyTorch/CuPy compatibility, standard signal/image processing linear operators, as well as advanced tools to approximate large matrices by efficient butterfly operators.

A LazyLinOp is a high-level linear operator based on an arbitrary underlying implementation, such as:

- custom Python functions,
- a [NumPy array](https://numpy.org/doc/stable/reference/generated/numpy.array.html),
- a [SciPy matrix](https://docs.scipy.org/doc/scipy/reference/sparse.html),
- a [CuPy array](https://docs.cupy.dev/en/stable/reference/generated/cupy.array.html),
- a [torch tensor](https://docs.pytorch.org/docs/stable/tensors.html),
- a [Faust](https://faustgrp.gitlabpages.inria.fr/faust/last-doc/html/classpyfaust_1_1Faust.html) object,
- any Python linear operator.

Thanks to the Lazylinop API, this operator can be easily manipulated, transformed or aggregated with other linear operators to form more complex LazyLinOp objects. Thus, many operations are available such as the addition, concatenation, adjoint etc. These operations are all ruled by the lazy paradigm: their evaluation is delayed until the resulting LazyLinOp is actually applied to a vector (or to a collection of vectors, seen as a matrix).

Get started with lazylinop

Run the following command to install the lazylinop package from PyPI:

pip install lazylinop

Run the following commands to install from conda:

conda config --add channels conda-forge
conda config --add channels lazylinop
conda install lazylinop

First steps

Build 2D FFT from 1D FFT and Kronecker product:

from lazylinop.signal import fft
from lazylinop.basicops import kron
fft2d = kron(fft(N), fft(N))
x = np.random.randn(fft2d.shape[1])
y = fft2d @ x

Build circular convolution from 1D FFT:

from lazylinop.signal import fft
from lazylinop.basicops import diag
DFT = fft(N) * np.sqrt(N)
D = diag(DFT @ filter, k=0)
L = (DFT / N).H @ D @ DFT

Authors

  • Pascal Carrivain
  • Simon Delamare
  • Hakim Hadj-Djilani
  • Remi Gribonval

Contribute to lazylinop

You can contribute to lazylinop with bug report, feature request and merge request.

Useful links

Running unit tests

    cd tests
    python3 -m unittest TestLazyLinOp.py
    python3 -m unittest TestSignal.py

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

lazylinop-1.24.3-py3-none-any.whl (303.0 kB view details)

Uploaded Python 3

File details

Details for the file lazylinop-1.24.3-py3-none-any.whl.

File metadata

  • Download URL: lazylinop-1.24.3-py3-none-any.whl
  • Upload date:
  • Size: 303.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for lazylinop-1.24.3-py3-none-any.whl
Algorithm Hash digest
SHA256 21608a2dcdd84d7ce793fe1c030dace813d770d017a1434dc252c066ce31f523
MD5 9f5e455ec499656a27aa39c2914026ce
BLAKE2b-256 1ca012f781280c28ee5b2a83aaf0cf9a451ffdddcd3c195a9a1a1d3ef60b781d

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