-
-
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
Let Base handle concatenation of arrays and numbers #48933
Conversation
Honestly, I believe we should backport this to v1.9, not sure if v1.8 is still necessary. @KristofferC Do you think this is feasible? |
Another possibility might be to change the existing |
I'm running local tests to see if my adoption of your proposal works. I'd like to keep the new methods in |
I'm getting poor benchmarks with the changes in using LinearAlgebra, BenchmarkTools
A = rand(3,4)
B = rand(3,3)
C = rand(0,3)
D = rand(2,0)
E = rand(1,3)
F = rand(3,1)
α = rand()
begin
@btime hcat($A, $(2I));
@btime hcat($E, $α);
@btime hcat($A, $(2I));
@btime hcat($E, $α);
@btime hcat($E, $α, 2I);
@btime vcat($A, $(2I));
@btime vcat($F, $α);
@btime vcat($F, $α, $(2I));
@btime hcat($C, $(2I));
@btime vcat($D, $(2I));
@btime hcat($I, $(3I), $A, $(2I));
@btime vcat($I, $(3I), $A, $(2I));
@btime hvcat((2,1,2), $B, $(2I), I, $(3I), $(4I));
@btime hvcat((3,1), $C, $C, I, $(3I));
@btime hvcat((2,2,2), $I, $(2I), $(3I), $(4I), $C, $C);
@btime hvcat((2,2,4), $C, $C, I, $(2I), $(3I), $(4I), $(5I), $D);
@btime hvcat((2,3,2), $B, $(2I), $C, $C, I, $(3I), $(4I));
@btime hvcat((3,2,1), $C, $C, I, $B, $(3I), $(2I));
@btime hvcat((1,2), $A, $E, $α);
@btime hvcat((2,2), $α, $E, $F, $(3I));
@btime hvcat((2,2), $(3I), $F, $E, $α);
end
|
Test failure is unrelated. I added one safe optimization, that is orthogonal to your suggestions @mikmoore and which yields significant speedup. We should look at the code for concatenation of |
Let Base handle concatenation of arrays and numbers (cherry picked from commit e6c84a1)
Fixes #48850.
The issue was that in Base the concatenation methods are completely generic, and that the methods in uniformscaling.jl are pirating the case when only a vecormat and numbers are present. This resolves the ambiguity, and simplifies the case where both uniform scalings and numbers are present. In that case, the scalings can only have size 1x1, or, equivalently, be numbers.