-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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: Refactoring to merge the code handling Adjoint and Transpose #33069
Conversation
true | ||
``` | ||
""" | ||
inplace(::typeof(adjoint)) = adjoint! |
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.
Another alternative would be
functor!(::Type{<:Adjoint}) = adjoint!
+1 on the refactor. The |
I find |
I'm also in favor but I agree with @antoine-levitt about the name. It looks like the change introduces some ambiguities. |
Also, +1 for the refactor but |
OK so does trans_or_adj(::Type{<:Adjoint}) = adjoint
trans_or_adj!(::Type{<:Adjoint}) = adjoint! look fine for everyone?
Can we do make ambiguity situation better? I suggest one simple solution in #33072. If there is no systematic solution I guess I'll do it the old way here... |
Actually, I guess it probably should be something like inplace_trans_or_adj(::Type{<:Adjoint}) = adjoint! since otherwise f! = trans_or_adj!(A)
f!(B) might looke like we are mutating |
I think the majority of code handling
Adjoint
andTranspose
can be merged. The trick is to define a trait functionjulia/stdlib/LinearAlgebra/src/adjtrans.jl
Lines 86 to 87 in 1e83dd4
so that we can write code like this
julia/stdlib/LinearAlgebra/src/triangular.jl
Lines 855 to 867 in 1e83dd4
Note that
adjA
can be aAdjoint
orTranspose
in above code. The functionf
isadjoint
ortranspose
depending on the type ofadjA
.I applied the idea to a few places so that you can see the impact of this change. You can already see that many lines can be removed.
What do you think? Does this refactoring makes sense?