Skip to content

Commit

Permalink
Merge pull request JuliaLang#20565 from fredrikekre/fe/repmat
Browse files Browse the repository at this point in the history
fix repmat overflow
  • Loading branch information
JeffBezanson committed Feb 11, 2017
2 parents 43e2aad + 12d25f9 commit 338581f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ function repmat(a::AbstractVector, m::Int)
return b
end

@inline repmat(a, m::Integer...) = repmat(a, convert(Dims, m)...)
@inline repmat(a::AbstractVecOrMat, m::Integer, n::Integer=1) = repmat(a, Int(m), Int(n))
@inline repmat(a::AbstractVector, m::Integer) = repmat(a, Int(m))

"""
repeat(A::AbstractArray; inner=ntuple(x->1, ndims(A)), outer=ntuple(x->1, ndims(A)))
Expand Down
5 changes: 5 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,11 @@ end
A3 = reshape(repmat([1 2 3 4],UInt32(6),UInt32(1)),2,3,4)
@test isequal(cumsum(A,3),A3)
@test repmat([1,2,3,4], UInt32(1)) == [1,2,3,4]
@test repmat([1 2], UInt32(2)) == repmat([1 2], UInt32(2), UInt32(1))

# issue 20564
@test_throws MethodError repmat(1, 2, 3)
@test_throws MethodError repmat([1, 2], 1, 2, 3)


R = repeat([1, 2])
Expand Down

0 comments on commit 338581f

Please sign in to comment.