Skip to content

Commit

Permalink
Avoid potential ambiguities for [h/v/hv]cat in packages (JuliaLang#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarrasch authored Aug 18, 2021
1 parent 5e1670e commit 2e82c0d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions stdlib/LinearAlgebra/src/uniformscaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,11 @@ promote_to_arrays(n,k, ::Type{T}, A, B, Cs...) where {T} =
(promote_to_arrays_(n[k], T, A), promote_to_arrays_(n[k+1], T, B), promote_to_arrays(n,k+2, T, Cs...)...)
promote_to_array_type(A::Tuple{Vararg{Union{AbstractVecOrMat,UniformScaling,Number}}}) = Matrix

for (f,dim,name) in ((:hcat,1,"rows"), (:vcat,2,"cols"))
for (f, _f, dim, name) in ((:hcat, :_hcat, 1, "rows"), (:vcat, :_vcat, 2, "cols"))
@eval begin
function $f(A::Union{AbstractVecOrMat,UniformScaling,Number}...)
@inline $f(A::Union{AbstractVecOrMat,UniformScaling}...) = $_f(A...)
@inline $f(A::Union{AbstractVecOrMat,UniformScaling,Number}...) = $_f(A...)
function $_f(A::Union{AbstractVecOrMat,UniformScaling,Number}...)
n = -1
for a in A
if !isa(a, UniformScaling)
Expand All @@ -424,8 +426,9 @@ for (f,dim,name) in ((:hcat,1,"rows"), (:vcat,2,"cols"))
end
end


function hvcat(rows::Tuple{Vararg{Int}}, A::Union{AbstractVecOrMat,UniformScaling,Number}...)
hvcat(rows::Tuple{Vararg{Int}}, A::Union{AbstractVecOrMat,UniformScaling}...) = _hvcat(rows, A...)
hvcat(rows::Tuple{Vararg{Int}}, A::Union{AbstractVecOrMat,UniformScaling,Number}...) = _hvcat(rows, A...)
function _hvcat(rows::Tuple{Vararg{Int}}, A::Union{AbstractVecOrMat,UniformScaling,Number}...)
require_one_based_indexing(A...)
nr = length(rows)
sum(rows) == length(A) || throw(ArgumentError("mismatch between row sizes and number of arguments"))
Expand Down

0 comments on commit 2e82c0d

Please sign in to comment.