-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Hi folks,
Firstly, thanks for the awesome package! I have found delightful use in it to handle collections of storing and using combinations of large structured covariance matrices!
Feature suggestion
It would be nice to have some other diagnostics (particularly norm ) of the type available in LinearAlgebra.jl, also defined for LinearMaps too.
I understand that more more complex operations (e.g. performing SVD ) there are other packages defining this (say, TSVD, or LowRankApprox) but not much of the simple stuff is implemented. Furthermore I think LinearMaps is the right place to do this, because if anyone other package extends these functions to LinearMap objects it is type piracy.
Possible solution for norm
One can define the norm (and probably many diagnostics) of Amap::LinearMap by applying it to a basis Amap*X, and using norms of the mat-vec products.
What we are using right now
An example of norm_linear_map(A,p) that we use is randomly approximates norm(A,p) - In case someone wants a quick solution.
using LinearAlgebra, LinearMaps, Random
function norm_linear_map(A::LM, p::Real = 2; n_eval = nothing, rng = Random.default_rng()) where {LM <: LinearMap}
m, n = size(A)
n_basis = isa(n_eval, Nothing) ? n : n_eval
samples = randn(n, n_basis) # use unit-normalized gaussian vectors
for i in 1:size(samples,2)
samples[:,i] /= norm(samples[:,i])
end
out = zeros(m,n_basis)
mul!(out,A,samples)
norm_val = (n/n_basis)^(1/p) * norm(out,p)
return norm_val
endbut one can also do this deterministically with samples being a full basis, and taking the maximum over the p-norms I think.