Concatenation with I (UniformScaling) and numbers#33363
Concatenation with I (UniformScaling) and numbers#33363dkarrasch wants to merge 7 commits intoJuliaLang:masterfrom dkarrasch:hvcat_scaling_number
Conversation
|
EDIT: I think that's fixed now. |
| # so that the same promotion code can be used for hvcat. We pass the type T | ||
| # so that we can re-use this code for sparse-matrix hcat etcetera. | ||
| promote_to_arrays_(n::Int, ::Type{Matrix}, J::UniformScaling{T}) where {T} = copyto!(Matrix{T}(undef, n,n), J) | ||
| promote_to_arrays_(n::Int, ::Type, a::T) where {T<:Number} = copyto!(Vector{T}(undef, 1), a) |
There was a problem hiding this comment.
A little unfortunate that for every scalar it will now allocate a Vector first … seems like it would be better to change the logic elsewhere.
|
@stevengj Thanks for the comment. I made a second attempt without allocating vectors. The resulting method is more special than the generic |
|
I'm running out of ideas... I had added I was trying to circumvent this by calling To resolve this, we would need to call straigt |
Fixes JuliaLang/LinearAlgebra.jl#666.
The
hvcatmethod used to error (see JuliaLang/LinearAlgebra.jl#666), so this is kind of a bugfix, but one could also say a new feature. Thehcat/vcatis not a new feature since it currently returns an array ofAnywhen concatenating matrices, uniform scalings and numbers:So probably this part is breaking (and could be removed from this PR or even altogether if people see some conflict).
EDIT: I think it's technically breaking, but hard to imagine that people have specifically used this with the above behavior.