linear-operator
A linear operator implementation, primarily designed for finite-dimensional positive definite operators (i.e. kernel matrices).
What it is and what it does
LinearOperator is a PyTorch package that lets you define and work with structured matrices—such as low-rank-plus-diagonal or triangular matrices—without explicitly constructing them as dense tensors. Instead of materializing a large matrix in memory, you define it compositionally (e.g., `LowRankRootLinearOperator(C) + DiagLinearOperator(d)`) and LinearOperator automatically routes operations like solves and matrix-vector products through efficient structure-exploiting routines. It depends on torch and scipy and integrates with PyTorch's standard linear algebra API.
The package is currently in beta and supports positive semi-definite and triangular matrices. Its main value is enabling memory-efficient and computationally efficient workflows for large structured matrices—particularly useful in probabilistic modeling and kernel methods—without requiring you to hand-code specialized linear algebra routines. Operations like `torch.linalg.solve(A, b)` work transparently on LinearOperator objects, dispatching to the best available algorithm based on the matrix's declared structure.
Use it for:
- Sampling from high-dimensional multivariate Gaussians with structured covariance matrices without materializing the full matrix.
- Solving linear systems with low-rank-plus-diagonal structure efficiently via the Woodbury formula.
- Kernel matrix operations in Gaussian process inference where the kernel matrix is too large to fit in memory.
- Composing multiple structured matrix types and automatically leveraging efficient algorithms for the resulting composite structure.
- Prototyping different structured matrix approximations for a model without rewriting linear algebra code for each variant.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
LinearOperator abstracts structured matrix operations in PyTorch, enabling efficient computation on large matrices without materializing them in memory by exploiting their algebraic structure.
Yes, if you work with large structured matrices in PyTorch and need memory efficiency or computational speed. The low install friction and active maintenance support adoption. However, the pre-alpha status and incomplete feature set (symmetric, generic square, rectangular, and sparse operators not yet implemented) mean you should verify that positive semi-definite and triangular operators cover your use case and accept that the API may change.
Install
linear-operator on PyPI
pip
pip install linear-operatoruv
uv add linear-operatorpoetry
poetry add linear-operatorInstalling linear-operator
Before you install
Low friction install with only torch and scipy as runtime dependencies. Active maintenance with recent releases; currently in pre-alpha (Development Status :: 2 - Pre-Alpha), so expect API changes and incomplete feature coverage.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal obligations—suitable for both open and proprietary projects.
Quickstart
pip install linear_operator
from linear_operator.operators import DiagLinearOperator, LowRankRootLinearOperator
import torch
C = torch.randn(1000, 20)
d = torch.randn(1000)
b = torch.randn(1000)
A = LowRankRootLinearOperator(C) + DiagLinearOperator(d)
result = torch.linalg.solve(A, b)
Requires Python >= 3.10 and torch installed.
Verify before relying
- Whether positive semi-definite and triangular operators cover your specific matrix structure needs, given the package's stated beta limitations
- Performance gains on your hardware and matrix sizes relative to dense PyTorch operations
- Stability of the API given pre-alpha status and the incomplete roadmap (symmetric, generic square, rectangular, and sparse operators still pending)
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — torch, scipy |
| Maintenance | actively maintained — 168 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,139,454/month — #4,309 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: linear_operator-0.6.1-py3-none-any.whl
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
nvidia-cusolverProvides CUDA solver native runtime libraries…
unclear · top 1,000 on PyPI
blisProvides fast BLAS-like linear algebra…
permissive · top 1,000 on PyPI
nvidia-cusolver-cu12Provides CUDA solver native runtime libraries…
unclear · top 1,000 on PyPI
lineaxLineax solves linear systems and least-squares…
permissive · top 15,000 on PyPI
eigenpyEigenPy provides Python bindings between NumPy…
permissive · top 5,000 on PyPI
nvidia-cublasProvides NVIDIA CUBLAS native runtime libraries…
unclear · top 1,000 on PyPI
nvidia-cublas-cu12Provides NVIDIA CUBLAS native runtime libraries…
unclear · top 1,000 on PyPI
xarray-einstatsProvides xarray-friendly wrappers around NumPy…
permissive · top 5,000 on PyPI
scikit-femTransforms bilinear and linear forms into…
permissive · top 15,000 on PyPI
tabmatProvides efficient matrix classes for tabular…
unclear · top 15,000 on PyPI