-
Notifications
You must be signed in to change notification settings - Fork 106
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
Replace AbstractMatrixCFcn for new type LinearMap #85
Conversation
Maybe you are aware but remember that functions have types in 0.5 so it might not be necessary to wrap them in a type. E.g. you can define Base.eltype(::typeof(f)) = Float64
Base.size(::typeof(f)) = (10,10)
Base.*(::typeof(f), x) = f(x) I'm not sure if it fits all your needs here but I could get a long way with this recently when I wrote an iterative algorithm. |
I think it won't help in this case, the type wraps two functions: multiplication and ctranspose multiplication. When ctransposing it is desirable to have the wrapper to organize which function to use. |
Codecov Report
@@ Coverage Diff @@
## master #85 +/- ##
=========================================
- Coverage 87.73% 86.2% -1.53%
=========================================
Files 18 17 -1
Lines 1223 1124 -99
=========================================
- Hits 1073 969 -104
- Misses 150 155 +5
Continue to review full report at Codecov.
|
In the code it would be worth adding comments as to what the |
@lopezm94 has tried the function type approach in this branch: https://github.com/lopezm94/IterativeSolvers.jl/blob/FunctionDispatch/src/common.jl#L79-L117 Basically the main problems are that of scope and delaying the evaluation of the definitions. @andreasnoack any thoughts? |
Can either of you explain the "delaying" part to me? Couldn't it be e.g. |
Reason: julia> function f(g::Function)
k(::typeof(g)) = nothing
end
ERROR: UndefVarError: g not defined Julia does something to julia> function f(g::Function)
@eval k(::typeof($g)) = nothing
end
f (generic function with 1 method)
julia> f(identity)
k (generic function with 1 method) |
And then there's the problem with the scope, if the user deletes the object the functions might be left behind. |
Closing in favor of #104 |
Replace
AbstractMatrixCFcn
and children for a new unique typeLinearMap
. LinearMap can be created without any functions and defaults them to identity, multiplication and ctranspose multiplication can be added individually. It also switches the functions when it is ctransposed to know at every moment which function to use.Simpler to use and there is only one type for the user to handle.