-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Add estimates of operator norms #39058
Conversation
This reverts commit 81da93c.
The previous code was quite complicated and hard to read and not much more efficient
stdlib/SparseArrays/test/sparse.jl
Outdated
end | ||
@test_throws DimensionMismatch SparseArrays.opnormestinv(sprand(3,5,.9)) | ||
@test_throws DimensionMismatch (@test_deprecated SparseArrays.opnormestinv(sprand(3,5,.9))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These currently error. It doesn't seem that chaining @test_deprecated
for these tests actually works.
Ideally would also test values, but that doesn't seem to work with depwarn=error
@sethaxen It looks like this PR touches five files. Three of those files are in the LinearAlgebra stdlib, and the remaining two files are in the SparseArrays stdlib. We have moved the SparseArrays stdlib to an external repository. Therefore, for the portion of this PR that modifies the SparseArrays stdlib, can you please:
Thank you! |
We have moved the LinearAlgebra stdlib to an external repo: https://github.com/JuliaLang/LinearAlgebra.jl @sethaxen If you think that this PR is still relevant, please open a new PR on the LinearAlgebra.jl repo. |
This PR adds
threemethods:opnormest1(A)
: lower-bound estimate ofopnorm(A, 1)
opnormestprod1(As...)
/opnormestprod1(A,p::Integer)
: lower-bound estimate ofopnorm(prod(As), 1)
opnormestinv1(A)
: lower-bound estimate ofopnorm(inv(A), 1)
The implementation of
opnormest1
comes from the paper by Higham and Tisseur. It is especially useful when computing the actions of matrix functions (e.g.exp(A)*b
) for large and sparseA
. Edit: It also works on any object that implements a minimal interface of a linear operator.There was already an implementation of
opnormestinv1
opnormest(inv, A, 1)
(calledopnormestinv(A)
) in SparseArrays which served as the starting point for this implementation and is now superseded. From a quick scan, future PRs could make use of this estimate for computing condition numbers and for speeding up the matrix logarithm, which currently callsopnorm(A^p, 1)
for powers of 1 through 5. Even for a denseA
, the estimate is faster and on my machine gives a 20% speed-up for a large matrix. Edit: this implementation also minimizes the number of allocations, which causes a substantial speed-upI've marked this as RFC because I'm not very satisfied with the interface thus far, in particular the interface to return vectors corresponding to the estimate (see docstrings).
Edit: I've added the
opnormest
function which is exported. The public interface is now:opnormest(A, p=2)
: estimateopnorm(A, p)
opnormest(f, A, p=2)
: estimateopnorm(f(A), p)
for certainf
(pinv
,inv
, andprod
already supported). While clean, this interface is not very extensible. e.g., if we want to supportf(A) = A^n
orf(A) = A^(-n)
, there's not an obvious existingf
we can use (except maybeBase.Fix2
, but we would need to add^(n::Integer) = Base.Fix2(^, n)
to make it user-friendly).I also added a power iteration method for estimating the 2-norm, which I believe is the approach matlab's
normest
function uses.Relates #12609, JuliaLang/LinearAlgebra.jl#232