-
-
Notifications
You must be signed in to change notification settings - Fork 27
Specialize lmul!/rmul! for adjoint/transpose #1388
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
base: master
Are you sure you want to change the base?
Conversation
de35d8c
to
a359c7c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1388 +/- ##
=======================================
Coverage 93.81% 93.82%
=======================================
Files 34 34
Lines 15722 15724 +2
=======================================
+ Hits 14750 14753 +3
+ Misses 972 971 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@@ -809,4 +809,23 @@ end | |||
end | |||
end | |||
|
|||
@testset "lmul!/rmul! by numbers" begin |
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.
Do we have some sort of Quaternions
available? We should test this on something that is not commutative, because otherwise the whole left- and right-multiplication difference doesn't become visible.
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.
Turns out that this only holds for commutative numbers, so I have restricted this to real and complex numbers. This should cover most use cases.
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.
For the adjoint case, this should work, because we still have (xy)' = y'x'
.
rmul!(X::AdjOrTrans{<:Union{Real,Complex}}, s::Union{Real,Complex}) = (lmul!(wrapperop(X)(s), parent(X)); X) | ||
lmul!(s::Union{Real,Complex}, X::AdjOrTrans{<:Union{Real,Complex}}) = (rmul!(parent(X), wrapperop(X)(s)); X) |
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.
I'd suggest to split this and make it available to non-commutative types in the adjoint case.
rmul!(X::AdjOrTrans{<:Union{Real,Complex}}, s::Union{Real,Complex}) = (lmul!(wrapperop(X)(s), parent(X)); X) | |
lmul!(s::Union{Real,Complex}, X::AdjOrTrans{<:Union{Real,Complex}}) = (rmul!(parent(X), wrapperop(X)(s)); X) | |
rmul!(X::Transpose{<:Union{Real,Complex}}, s::Union{Real,Complex}) = (lmul!(s, parent(X)); X) | |
rmul!(X::Adjoint, s::Number) = (lmul!(s', parent(X)); X) | |
lmul!(s::Union{Real,Complex}, X::Transpose{<:Union{Real,Complex}}) = (rmul!(parent(X), s); X) | |
lmul!(s::Number, X::Adjoint) = (rmul!(parent(X), s'); X) |
This ensures that the scaling happens in a cache-friendly manner, which improves performance.