-
Notifications
You must be signed in to change notification settings - Fork 39
Add a kwarg storagetype for PreallocatedLinearOperators #141
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #141 +/- ##
======================================
Coverage 96.3% 96.3%
======================================
Files 14 14
Lines 623 623
======================================
Hits 600 600
Misses 23 23
Continue to review full report at Codecov.
|
|
Please give some background and reasoning for this change. |
|
PreallocatedLinearOperator can be only preallocated with |
|
In other constructors, the user must pass in the storage (with the type that they want). The main constructor was intended to do things automatically, but now if the user needs to specify the storage type, it seems to me that it defeats the purpose. Isn't it just as easy to always ask the user to pass in the storage? Something like (untested): # main constructor, assume symmetric==false and hermitian==false
function PreallocatedLinearOperator(Mv :: AbstractVector{T},
Mtu :: AbstractVector{T},
Maw :: AbstractVector{T},
M :: AbstractMatrix{T}) where T
nrow, ncol = size(M)
@assert length(Mv) == nrow
@assert length(Mtu) == ncol
@assert length(Maw) == ncol
prod = @closure v -> mul!(Mv, M, v)
tprod = @closure u -> mul!(Mtu, transpose(M), u)
ctprod = @closure w -> mul!(Maw, adjoint(M), w)
PreallocatedLinearOperator{T}(nrow, ncol, symmetric, hermitian, prod, tprod, ctprod)
end
# convenience constructors
function PreallocatedLinearOperator(Mv :: AbstractVector{T},
M :: Hermitian{T, <:AbstractMatrix{T}) where T
PreallocatedLinearOperator(Mv, Mv, Mv, M)
end
function PreallocatedLinearOperator(Mv :: AbstractVector{T},
M :: Symmetric{T, <:AbstractMatrix{T}) where T
PreallocatedLinearOperator(Mv, Mv, Mv, M)
endIn the main constructor, there's nothing to prevent the user from passing in three times the same array if they know that products with the transposed and adjoint won't be needed. The assertions could be removed if they're annoying. What's missing in this design? |
|
I also updated this generic function, |
|
Ok, thank you. |
No description provided.