Skip to content

Conversation

farhadrclass
Copy link
Contributor

Introduces a new opnorm function that efficiently computes the operator 2-norm for matrices and linear operators, dispatching to LAPACK, ARPACK, or TSVD as appropriate. Adds comprehensive tests for opnorm covering both Float64 and BigFloat types, and integrates the new test file into the test suite.

Update Project.toml

Introduces a new opnorm function that efficiently computes the operator 2-norm for matrices and linear operators, dispatching to LAPACK, ARPACK, or TSVD as appropriate. Adds comprehensive tests for opnorm covering both Float64 and BigFloat types, and integrates the new test file into the test suite.

Update Project.toml
@farhadrclass farhadrclass requested a review from dpo August 21, 2025 21:15
@farhadrclass
Copy link
Contributor Author

@tmigot and @MaxenceGollier

Copy link

codecov bot commented Aug 21, 2025

Codecov Report

❌ Patch coverage is 31.37255% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.59%. Comparing base (32dbc5e) to head (a67ac20).
⚠️ Report is 48 commits behind head on main.

Files with missing lines Patch % Lines
src/utilities.jl 31.37% 35 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #375      +/-   ##
==========================================
- Coverage   95.00%   91.59%   -3.41%     
==========================================
  Files          17       20       +3     
  Lines        1100     1202     +102     
==========================================
+ Hits         1045     1101      +56     
- Misses         55      101      +46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@tmigot tmigot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @farhadrclass that will be a great add. I made a first batch of comments

- The estimated operator 2-norm of `B` (largest singular value or eigenvalue in absolute value).
"""

function LinearAlgebra.opnorm(B; kwargs...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as before. Do we really want to override the default opnorm from LinearAlgebra?
If someone uses this function in its code and add LinearOperators.jl it will mess everything up.

I think it's fine to import function to extand them, but here you override a default behavior.

I would suggest finding a better name and document the similarity with opnorm

# Fallback for everything else
function _opnorm(B, ::Type{T}; kwargs...) where {T}
_, s, _ = tsvd(B)
return s[1], true # return largest singular value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you avoid the documentation like this as it doesn't really provide much info

function opnorm_eig(B; max_attempts::Int = 3)
n = size(B, 1)
# 1) tiny dense Float64: direct LAPACK
if n ≤ 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 should be a parameter then

end

return σ, have_svd
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the formatter to avoid this

@@ -0,0 +1,33 @@
function test_opnorm()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid encapsulating test sets in a function

@@ -31,13 +33,15 @@ AMDGPU = "2"
CUDA = "5"
ChainRulesCore = "1"
FastClosures = "0.2, 0.3"
GenericLinearAlgebra = "0.3.18"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you expand a bit on why we need these new deps and should we have them by default and not in package extension?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants