Repository navigation
Feat: add Lipschitz method to LinearOperator - #813
Open
Megumi1773 wants to merge 1 commit into
Open
Megumi1773 wants to merge 1 commit into
Megumi1773 wants to merge 1 commit into
Conversation
Add LinearOperator.Lipschitz to compute the Lipschitz constant of an operator, defined as its largest singular value (sqrt(max eigenvalue of Op.H * Op)). A square=True flag returns the squared value directly, which is what gradient-based solvers need for their step size. This replaces the recurring Op1 = Op.H * Op; L = abs(Op1.eigs(...)) pattern seen across examples and solvers. For the numpy backend the largest eigenvalue is estimated with LinearOperator.eigs (symmetric); for cupy/jax it defers to optimization.eigs.power_iteration. Closes PyLops#812
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a
Lipschitzmethod toLinearOperatorthat returns the Lipschitz constant of the operator, i.e. its largest singular value:A
square=Trueflag returns the squared value (max eigenvalue of A.H @ A) directly.Why
Closes #812. The issue notes that this exact pattern appears in many examples, tutorials and notebooks (especially with pyproximal solvers):
Having it as a first-class method avoids re-deriving the step size in every example and gives operators with a closed-form Lipschitz constant (e.g.
Diagonal,Restriction,Blending,FFT) a single place to override it.How
numpybackend: usesLinearOperator.eigson the Hermitian normal operator (symmetric=True), as suggested in the issue.cupy/jaxbackends: defers topylops.optimization.eigs.power_iteration, mirroring howpylops.optimization.cls_sparsityalready handles non-numpy backends.Testing
Added
test_lipschitztopytests/test_linearoperator.py, parametrized over real/complex and square/overdetermined operators. It checks:Diagonaloperator, where the largest singular value is the largest diagonal entry;square=TrueequalsLipschitz()**2;MatrixMult, compared againstnp.linalg.svd(M, compute_uv=False)[0].Full
pytests/test_linearoperator.py+pytests/test_eigs.py: 54 passed.ruff checkon both changed files passes.Notes
I could not run
make tests_gpu, so thecupy/jaxbranch is written to match the existingpower_iterationcall convention incls_sparsitybut was not exercised on a GPU here.