Skip to content

Commit

Permalink
allow zeros, ones, infs, nans to accept any array, not just matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Mar 2, 2014
1 parent 73d6a45 commit 517039e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ fill(v, dims::Integer...) = fill!(Array(typeof(v), dims...), v)

for (fname, felt) in ((:zeros,:zero),
(:ones,:one),
(:infs,:inf),
(:infs,:inf),
(:nans,:nan))
@eval begin
($fname){T}(::Type{T}, dims...) = fill!(Array(T, dims...), ($felt)(T))
($fname)(dims...) = fill!(Array(Float64, dims...), ($felt)(Float64))
($fname){T}(x::AbstractMatrix{T}) = ($fname)(T, size(x, 1), size(x, 2))
($fname){T}(::Type{T}, dims...) = fill!(Array(T, dims...), ($felt)(T))
($fname)(dims...) = fill!(Array(Float64, dims...), ($felt)(Float64))
($fname){T}(x::AbstractArray{T}) = ($fname)(T, size(x))
end
end

Expand Down

0 comments on commit 517039e

Please sign in to comment.