From 2152bf93b98089ccc5e4373d57af336a2ea9c10e Mon Sep 17 00:00:00 2001 From: Patrick Kofod Mogensen Date: Wed, 25 May 2016 13:43:40 +0200 Subject: [PATCH] Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in /base/ (#16498) * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) for arrays. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/pkg/. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/linalg/. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/strings/. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/unicode/. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/grisu/. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/fft/. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/ for files starting b-e. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/docs/. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/ for files starting with f-i. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/dSFMT.jl, base/Enums.jl, and base/LineEdit.jl. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/ for files starting with l-m. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/ for files starting with p-r. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/ for files starting with s-t. * Replace deprecated Array(T..., dims...) with Array{T...}(dims...) in base/special/. * Additional changes from Array(T, dim) to Array{T}(dim). * Further changes. * fix constructors.rst --- base/Enums.jl | 2 +- base/LineEdit.jl | 2 +- base/abstractarray.jl | 28 +- base/abstractarraymath.jl | 2 +- base/array.jl | 58 +-- base/base.jl | 4 +- base/bitarray.jl | 22 +- base/broadcast.jl | 26 +- base/channels.jl | 2 +- base/collections.jl | 4 +- base/dSFMT.jl | 2 +- base/datafmt.jl | 10 +- base/deprecated.jl | 3 +- base/dft.jl | 8 +- base/dict.jl | 10 +- base/docs/helpdb/Base.jl | 2 +- base/docs/utils.jl | 2 +- base/dsp.jl | 2 +- base/env.jl | 2 +- base/essentials.jl | 2 +- base/fft/FFTW.jl | 38 +- base/fft/dct.jl | 6 +- base/file.jl | 10 +- base/filesystem.jl | 4 +- base/float16.jl | 4 +- base/grisu.jl | 2 +- base/grisu/bignums.jl | 2 +- base/grisu/fastprecision.jl | 2 +- base/grisu/fastshortest.jl | 2 +- base/inference.jl | 2 +- base/intfuncs.jl | 10 +- base/io.jl | 6 +- base/iobuffer.jl | 20 +- base/iostream.jl | 6 +- base/libc.jl | 6 +- base/libgit2/reference.jl | 2 +- base/libgit2/strarray.jl | 2 +- base/linalg/arpack.jl | 28 +- base/linalg/bidiag.jl | 2 +- base/linalg/blas.jl | 4 +- base/linalg/dense.jl | 8 +- base/linalg/lapack.jl | 504 +++++++++++----------- base/linalg/lu.jl | 4 +- base/linalg/matmul.jl | 8 +- base/linalg/qr.jl | 2 +- base/linalg/triangular.jl | 12 +- base/linalg/tridiag.jl | 2 +- base/loading.jl | 2 +- base/math.jl | 2 +- base/mmap.jl | 2 +- base/mpfr.jl | 6 +- base/multi.jl | 3 +- base/multidimensional.jl | 8 +- base/pcre.jl | 2 +- base/pkg/query.jl | 4 +- base/pkg/resolve.jl | 4 +- base/pkg/resolve/interface.jl | 8 +- base/pkg/resolve/maxsum.jl | 2 +- base/pkg/resolve/versionweight.jl | 4 +- base/profile.jl | 24 +- base/quadgk.jl | 4 +- base/random.jl | 36 +- base/range.jl | 2 +- base/refpointer.jl | 4 +- base/serialize.jl | 8 +- base/sharedarray.jl | 12 +- base/show.jl | 2 +- base/socket.jl | 6 +- base/special/bessel.jl | 10 +- base/special/gamma.jl | 8 +- base/stacktraces.jl | 2 +- base/stat.jl | 2 +- base/statistics.jl | 6 +- base/strings/basic.jl | 4 +- base/strings/io.jl | 6 +- base/strings/types.jl | 2 +- base/subarray.jl | 2 +- base/sysinfo.jl | 10 +- base/threadcall.jl | 2 +- base/tuple.jl | 2 +- base/unicode/utf16.jl | 6 +- base/unicode/utf32.jl | 8 +- base/unicode/utf8.jl | 4 +- base/util.jl | 2 +- doc/devdocs/subarrays.rst | 2 +- doc/manual/arrays.rst | 2 +- doc/manual/calling-c-and-fortran-code.rst | 6 +- doc/manual/constructors.rst | 2 +- doc/manual/interfaces.rst | 3 +- doc/manual/metaprogramming.rst | 4 +- doc/manual/performance-tips.rst | 12 +- doc/manual/style-guide.rst | 2 +- doc/manual/variables-and-scoping.rst | 6 +- doc/stdlib/arrays.rst | 3 +- examples/lru.jl | 4 +- examples/ndgrid.jl | 2 +- examples/queens.jl | 2 +- test/abstractarray.jl | 8 +- test/arrayops.jl | 22 +- test/bitarray.jl | 2 +- test/core.jl | 36 +- test/datafmt.jl | 3 +- test/dates/ranges.jl | 4 +- test/fft.jl | 2 +- test/file.jl | 2 +- test/functional.jl | 2 +- test/grisu.jl | 2 +- test/iobuffer.jl | 4 +- test/linalg/generic.jl | 2 +- test/linalg/matmul.jl | 20 +- test/linalg/pinv.jl | 9 +- test/mmap.jl | 8 +- test/mod2pi.jl | 2 +- test/netload/memtest.jl | 2 +- test/parallel_exec.jl | 4 +- test/perf/cat/perf.jl | 9 +- test/perf/kernel/perf.jl | 2 +- test/perf/perfutil.jl | 2 +- test/perf/shootout/fannkuch.jl | 2 +- test/perf/shootout/fasta.jl | 2 +- test/perf/shootout/k_nucleotide.jl | 2 +- test/perf/shootout/meteor_contest.jl | 2 +- test/perf/sort/perf.jl | 8 +- test/perf/threads/laplace3d/laplace3d.jl | 9 +- test/perf/threads/lbm3d/lbm3d.jl | 21 +- test/perf/threads/stockcorr/pstockcorr.jl | 5 +- test/pollfd.jl | 6 +- test/random.jl | 36 +- test/serialize.jl | 2 +- test/simdloop.jl | 10 +- test/sparsedir/sparse.jl | 10 +- test/sparsedir/sparsevector.jl | 2 +- test/staged.jl | 2 +- test/subarray.jl | 4 +- test/threads.jl | 4 +- test/unicode/utf32.jl | 2 +- 136 files changed, 715 insertions(+), 723 deletions(-) diff --git a/base/Enums.jl b/base/Enums.jl index 1be3206a7a354..1d1a46316e220 100644 --- a/base/Enums.jl +++ b/base/Enums.jl @@ -34,7 +34,7 @@ macro enum(T,syms...) throw(ArgumentError("invalid type expression for enum $T")) end typename = T - vals = Array(Tuple{Symbol,Integer},0) + vals = Array{Tuple{Symbol,Integer}}(0) lo = hi = 0 i = Int32(-1) hasexpr = false diff --git a/base/LineEdit.jl b/base/LineEdit.jl index b3fe858b9ad1a..c7af86e2dc69f 100644 --- a/base/LineEdit.jl +++ b/base/LineEdit.jl @@ -854,7 +854,7 @@ function keymap_merge(target,source) for key in setdiff(keys(source), keys(direct_keys)) # We first resolve redirects in the source value = source[key] - visited = Array(Any,0) + visited = Array{Any}(0) while isa(value, Union{Char,AbstractString}) value = normalize_key(value) if value in visited diff --git a/base/abstractarray.jl b/base/abstractarray.jl index d29a02ed23be7..c9668fd467584 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -9,14 +9,14 @@ typealias RangeIndex Union{Int, Range{Int}, UnitRange{Int}, Colon} ## Basic functions ## -vect() = Array(Any, 0) +vect() = Array{Any}(0) vect{T}(X::T...) = T[ X[i] for i=1:length(X) ] function vect(X...) T = promote_typeof(X...) #T[ X[i] for i=1:length(X) ] # TODO: this is currently much faster. should figure out why. not clear. - copy!(Array(T,length(X)), X) + copy!(Array{T}(length(X)), X) end size{T,N}(t::AbstractArray{T,N}, d) = d <= N ? size(t)[d] : 1 @@ -156,7 +156,7 @@ similar{T}(a::AbstractArray{T}, dims::Integer...) = similar(a, T, dims) similar( a::AbstractArray, T::Type, dims::Integer...) = similar(a, T, dims) # similar creates an Array by default similar( a::AbstractArray, T::Type, dims::DimsInteger) = similar(a, T, convert(Dims, dims)) -similar( a::AbstractArray, T::Type, dims::Dims) = Array(T, dims) +similar( a::AbstractArray, T::Type, dims::Dims) = Array{T}(dims) ## from general iterable to any array @@ -597,12 +597,12 @@ promote_eltype() = Bottom promote_eltype(v1, vs...) = promote_type(eltype(v1), promote_eltype(vs...)) #TODO: ERROR CHECK -cat(catdim::Integer) = Array(Any, 0) +cat(catdim::Integer) = Array{Any}(0) -vcat() = Array(Any, 0) -hcat() = Array(Any, 0) -typed_vcat(T::Type) = Array(T, 0) -typed_hcat(T::Type) = Array(T, 0) +vcat() = Array{Any}(0) +hcat() = Array{Any}(0) +typed_vcat(T::Type) = Array{T}(0) +typed_hcat(T::Type) = Array{T}(0) ## cat: special cases vcat{T}(X::T...) = T[ X[i] for i=1:length(X) ] @@ -610,10 +610,10 @@ vcat{T<:Number}(X::T...) = T[ X[i] for i=1:length(X) ] hcat{T}(X::T...) = T[ X[j] for i=1, j=1:length(X) ] hcat{T<:Number}(X::T...) = T[ X[j] for i=1, j=1:length(X) ] -vcat(X::Number...) = hvcat_fill(Array(promote_typeof(X...),length(X)), X) -hcat(X::Number...) = hvcat_fill(Array(promote_typeof(X...),1,length(X)), X) -typed_vcat(T::Type, X::Number...) = hvcat_fill(Array(T,length(X)), X) -typed_hcat(T::Type, X::Number...) = hvcat_fill(Array(T,1,length(X)), X) +vcat(X::Number...) = hvcat_fill(Array{promote_typeof(X...)}(length(X)), X) +hcat(X::Number...) = hvcat_fill(Array{promote_typeof(X...)}(1,length(X)), X) +typed_vcat(T::Type, X::Number...) = hvcat_fill(Array{T}(length(X)), X) +typed_hcat(T::Type, X::Number...) = hvcat_fill(Array{T}(1,length(X)), X) vcat(V::AbstractVector...) = typed_vcat(promote_eltype(V...), V...) vcat{T}(V::AbstractVector{T}...) = typed_vcat(T, V...) @@ -833,7 +833,7 @@ function hvcat{T<:Number}(rows::Tuple{Vararg{Int}}, xs::T...) nr = length(rows) nc = rows[1] - a = Array(T, nr, nc) + a = Array{T}(nr, nc) if length(a) != length(xs) throw(ArgumentError("argument count does not match specified shape (expected $(length(a)), got $(length(xs)))")) end @@ -874,7 +874,7 @@ function typed_hvcat(T::Type, rows::Tuple{Vararg{Int}}, xs::Number...) if nr*nc != len throw(ArgumentError("argument count $(len) does not match specified shape $((nr,nc))")) end - hvcat_fill(Array(T, nr, nc), xs) + hvcat_fill(Array{T}(nr, nc), xs) end function hvcat(rows::Tuple{Vararg{Int}}, xs::Number...) diff --git a/base/abstractarraymath.jl b/base/abstractarraymath.jl index effd5f88a2b36..53b70ea611180 100644 --- a/base/abstractarraymath.jl +++ b/base/abstractarraymath.jl @@ -167,7 +167,7 @@ end ## ipermutedims in terms of permutedims ## function ipermutedims(A::AbstractArray,perm) - iperm = Array(Int,length(perm)) + iperm = Array{Int}(length(perm)) for (i,p) = enumerate(perm) iperm[p] = i end diff --git a/base/array.jl b/base/array.jl index 7d4c82a2d8f4e..0feef9cb3a51b 100644 --- a/base/array.jl +++ b/base/array.jl @@ -118,19 +118,19 @@ end ## Constructors ## -similar(a::Array, T::Type, dims::Dims) = Array(T, dims) -similar{T}(a::Array{T,1}) = Array(T, size(a,1)) -similar{T}(a::Array{T,2}) = Array(T, size(a,1), size(a,2)) -similar{T}(a::Array{T,1}, dims::Dims) = Array(T, dims) -similar{T}(a::Array{T,1}, m::Int) = Array(T, m) -similar{T}(a::Array{T,1}, S::Type) = Array(S, size(a,1)) -similar{T}(a::Array{T,2}, dims::Dims) = Array(T, dims) -similar{T}(a::Array{T,2}, m::Int) = Array(T, m) -similar{T}(a::Array{T,2}, S::Type) = Array(S, size(a,1), size(a,2)) +similar(a::Array, T::Type, dims::Dims) = Array{T}(dims) +similar{T}(a::Array{T,1}) = Array{T}(size(a,1)) +similar{T}(a::Array{T,2}) = Array{T}(size(a,1), size(a,2)) +similar{T}(a::Array{T,1}, dims::Dims) = Array{T}(dims) +similar{T}(a::Array{T,1}, m::Int) = Array{T}(m) +similar{T}(a::Array{T,1}, S::Type) = Array{S}(size(a,1)) +similar{T}(a::Array{T,2}, dims::Dims) = Array{T}(dims) +similar{T}(a::Array{T,2}, m::Int) = Array{T}(m) +similar{T}(a::Array{T,2}, S::Type) = Array{S}(size(a,1), size(a,2)) # T[x...] constructs Array{T,1} function getindex(T::Type, vals...) - a = Array(T,length(vals)) + a = Array{T}(length(vals)) @inbounds for i = 1:length(vals) a[i] = vals[i] end @@ -139,7 +139,7 @@ end getindex(T::Type) = Array{T}(0) function getindex(::Type{Any}, vals::ANY...) - a = Array(Any,length(vals)) + a = Array{Any}(length(vals)) @inbounds for i = 1:length(vals) a[i] = vals[i] end @@ -160,16 +160,16 @@ function fill!{T<:Union{Integer,AbstractFloat}}(a::Array{T}, x) return a end -fill(v, dims::Dims) = fill!(Array(typeof(v), dims), v) -fill(v, dims::Integer...) = fill!(Array(typeof(v), dims...), v) +fill(v, dims::Dims) = fill!(Array{typeof(v)}(dims), v) +fill(v, dims::Integer...) = fill!(Array{typeof(v)}(dims...), v) -cell(dims::Integer...) = Array(Any, dims...) -cell(dims::Tuple{Vararg{Integer}}) = Array(Any, convert(Tuple{Vararg{Int}}, dims)) +cell(dims::Integer...) = Array{Any}(dims...) +cell(dims::Tuple{Vararg{Integer}}) = Array{Any}(convert(Tuple{Vararg{Int}}, dims)) for (fname, felt) in ((:zeros,:zero), (:ones,:one)) @eval begin - ($fname)(T::Type, dims...) = fill!(Array(T, dims...), ($felt)(T)) - ($fname)(dims...) = fill!(Array(Float64, dims...), ($felt)(Float64)) + ($fname)(T::Type, dims...) = fill!(Array{T}(dims...), ($felt)(T)) + ($fname)(dims...) = fill!(Array{Float64}(dims...), ($felt)(Float64)) ($fname){T}(A::AbstractArray{T}) = fill!(similar(A), ($felt)(T)) end end @@ -198,7 +198,7 @@ convert{T,n}(::Type{Array{T}}, x::Array{T,n}) = x convert{T,n}(::Type{Array{T,n}}, x::Array{T,n}) = x convert{T,n,S}(::Type{Array{T}}, x::AbstractArray{S, n}) = convert(Array{T, n}, x) -convert{T,n,S}(::Type{Array{T,n}}, x::AbstractArray{S,n}) = copy!(Array(T, size(x)), x) +convert{T,n,S}(::Type{Array{T,n}}, x::AbstractArray{S,n}) = copy!(Array{T}(size(x)), x) promote_rule{T,n,S}(::Type{Array{T,n}}, ::Type{Array{S,n}}) = Array{promote_type(T,S),n} @@ -691,7 +691,7 @@ function vcat{T}(arrays::Vector{T}...) for a in arrays n += length(a) end - arr = Array(T, n) + arr = Array{T}(n) ptr = pointer(arr) offset = 0 if isbits(T) @@ -792,13 +792,13 @@ findlast(testf::Function, A) = findprev(testf, A, length(A)) function find(testf::Function, A) # use a dynamic-length array to store the indexes, then copy to a non-padded # array for the return - tmpI = Array(Int, 0) + tmpI = Array{Int}(0) for (i,a) = enumerate(A) if testf(a) push!(tmpI, i) end end - I = Array(Int, length(tmpI)) + I = Array{Int}(length(tmpI)) copy!(I, tmpI) I end @@ -816,8 +816,8 @@ function find(A) return I end -find(x::Number) = x == 0 ? Array(Int,0) : [1] -find(testf::Function, x::Number) = !testf(x) ? Array(Int,0) : [1] +find(x::Number) = x == 0 ? Array{Int}(0) : [1] +find(testf::Function, x::Number) = !testf(x) ? Array{Int}(0) : [1] findn(A::AbstractVector) = find(A) @@ -840,7 +840,7 @@ function findnz{T}(A::AbstractMatrix{T}) nnzA = countnz(A) I = zeros(Int, nnzA) J = zeros(Int, nnzA) - NZs = Array(T, nnzA) + NZs = Array{T}(nnzA) count = 1 if nnzA > 0 for j=1:size(A,2), i=1:size(A,1) @@ -903,7 +903,7 @@ function indexin(a::AbstractArray, b::AbstractArray) end function findin(a, b) - ind = Array(Int, 0) + ind = Array{Int}(0) bset = Set(b) @inbounds for (i,ai) in enumerate(a) ai in bset && push!(ind, i) @@ -952,7 +952,7 @@ function filter!(f, a::Vector) end function filter(f, a::Vector) - r = Array(eltype(a), 0) + r = Array{eltype(a)}(0) for ai in a if f(ai) push!(r, ai) @@ -965,7 +965,7 @@ end # These are moderately efficient, preserve order, and remove dupes. function intersect(v1, vs...) - ret = Array(eltype(v1),0) + ret = Array{eltype(v1)}(0) for v_elem in v1 inall = true for vsi in vs @@ -981,7 +981,7 @@ function intersect(v1, vs...) end function union(vs...) - ret = Array(promote_eltype(vs...),0) + ret = Array{promote_eltype(vs...)}(0) seen = Set() for v in vs for v_elem in v @@ -997,7 +997,7 @@ end function setdiff(a, b) args_type = promote_type(eltype(a), eltype(b)) bset = Set(b) - ret = Array(args_type,0) + ret = Array{args_type}(0) seen = Set{eltype(a)}() for a_elem in a if !in(a_elem, seen) && !in(a_elem, bset) diff --git a/base/base.jl b/base/base.jl index d2b1ae847ccb0..0104a08e0a7cf 100644 --- a/base/base.jl +++ b/base/base.jl @@ -85,7 +85,7 @@ gc_enable(on::Bool) = ccall(:jl_gc_enable, Cint, (Cint,), on)!=0 # used by { } syntax function cell_1d(xs::ANY...) n = length(xs) - a = Array(Any,n) + a = Array{Any}(n) for i=1:n arrayset(a,xs[i],i) end @@ -93,7 +93,7 @@ function cell_1d(xs::ANY...) end function cell_2d(nr, nc, xs::ANY...) - a = Array(Any,nr,nc) + a = Array{Any}(nr,nc) for i=1:(nr*nc) arrayset(a,xs[i],i) end diff --git a/base/bitarray.jl b/base/bitarray.jl index ac477d4d4f510..22d44bd12e541 100644 --- a/base/bitarray.jl +++ b/base/bitarray.jl @@ -18,7 +18,7 @@ type BitArray{N} <: DenseArray{Bool, N} i += 1 end nc = num_bit_chunks(n) - chunks = Array(UInt64, nc) + chunks = Array{UInt64}(nc) nc > 0 && (chunks[end] = UInt64(0)) b = new(chunks, n) N != 1 && (b.dims = dims) @@ -365,7 +365,7 @@ similar(B::BitArray, dims::Dims) = BitArray(dims...) similar(B::BitArray, T::Type{Bool}, dims::Dims) = BitArray(dims) # changing type to a non-Bool returns an Array # (this triggers conversions like float(bitvector) etc.) -similar(B::BitArray, T::Type, dims::Dims) = Array(T, dims) +similar(B::BitArray, T::Type, dims::Dims) = Array{T}(dims) function fill!(B::BitArray, x) y = convert(Bool, x) @@ -474,7 +474,7 @@ end convert{T,N}(::Type{Array{T}}, B::BitArray{N}) = convert(Array{T,N}, B) convert{T,N}(::Type{Array{T,N}}, B::BitArray{N}) = _convert(Array{T,N}, B) # see #15801 function _convert{T,N}(::Type{Array{T,N}}, B::BitArray{N}) - A = Array(T, size(B)) + A = Array{T}(size(B)) Bc = B.chunks @inbounds for i = 1:length(A) A[i] = unsafe_bitgetindex(Bc, i) @@ -1021,7 +1021,7 @@ end for f in (:+, :-) @eval function ($f)(A::BitArray, B::BitArray) - r = Array(Int, promote_shape(size(A), size(B))) + r = Array{Int}(promote_shape(size(A), size(B))) ai = start(A) bi = start(B) ri = 1 @@ -1040,7 +1040,7 @@ for (f) in (:.+, :.-) (:(x::Bool) , :(B::BitArray), Int , :(x, b)), (:(x::Number) , :(B::BitArray), :(promote_array_type($f, typeof(x), BitArray)), :(x, b))) @eval function ($f)($arg1, $arg2) - r = Array($T, size(B)) + r = Array{$T}(size(B)) bi = start(B) ri = 1 while !done(B, bi) @@ -1106,7 +1106,7 @@ end for f in (:div, :mod) @eval begin function ($f)(B::BitArray, x::Number) - F = Array(promote_array_type($f, BitArray, typeof(x)), size(B)) + F = Array{promote_array_type($f, BitArray, typeof(x))}(size(B)) for i = 1:length(F) F[i] = ($f)(B[i], x) end @@ -1198,7 +1198,7 @@ function (.^){T<:Number}(B::BitArray, x::T) else t = typeof(u) end - F = Array(t, size(B)) + F = Array{t}(size(B)) for i = 1:length(B) if B[i] if uerr === nothing @@ -1607,7 +1607,7 @@ end function find(B::BitArray) l = length(B) nnzB = countnz(B) - I = Array(Int, nnzB) + I = Array{Int}(nnzB) nnzB == 0 && return I Bc = B.chunks Bcount = 1 @@ -1641,8 +1641,8 @@ findn(B::BitVector) = find(B) function findn(B::BitMatrix) nnzB = countnz(B) - I = Array(Int, nnzB) - J = Array(Int, nnzB) + I = Array{Int}(nnzB) + J = Array{Int}(nnzB) count = 1 for j = 1:size(B,2), i = 1:size(B,1) if B[i,j] @@ -1969,7 +1969,7 @@ function cat(catdim::Integer, X::Union{BitArray, Integer}...) if !has_integer || typeC == Bool C = BitArray(dimsC) else - C = Array(typeC, dimsC) + C = Array{typeC}(dimsC) end range = 1 diff --git a/base/broadcast.jl b/base/broadcast.jl index 27b682bc8a035..4d3ace2e00d12 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -111,7 +111,7 @@ function gen_broadcast_body_cartesian_tobitarray(nd::Int, narrays::Int, f) quote @assert ndims(B) == $nd @ncall $narrays check_broadcast_shape size(B) k->A_k - C = Array(Bool, bitcache_size) + C = Array{Bool}(bitcache_size) Bc = B.chunks ind = 1 cind = 1 @@ -140,7 +140,7 @@ function gen_broadcast_body_iter_tobitarray(nd::Int, narrays::Int, f) quote @assert ndims(B) == $nd @ncall $narrays check_broadcast_shape size(B) k->A_k - C = Array(Bool, bitcache_size) + C = Array{Bool}(bitcache_size) Bc = B.chunks ind = 1 cind = 1 @@ -217,14 +217,14 @@ for (Bsig, Asig, gbf, gbb) in end -broadcast(f, As...) = broadcast!(f, Array(promote_eltype_op(f, As...), broadcast_shape(As...)), As...) +broadcast(f, As...) = broadcast!(f, Array{promote_eltype_op(f, As...)}(broadcast_shape(As...)), As...) bitbroadcast(f, As...) = broadcast!(f, BitArray(broadcast_shape(As...)), As...) broadcast!_function(f) = (B, As...) -> broadcast!(f, B, As...) broadcast_function(f) = (As...) -> broadcast(f, As...) -broadcast_getindex(src::AbstractArray, I::AbstractArray...) = broadcast_getindex!(Array(eltype(src), broadcast_shape(I...)), src, I...) +broadcast_getindex(src::AbstractArray, I::AbstractArray...) = broadcast_getindex!(Array{eltype(src)}(broadcast_shape(I...)), src, I...) @generated function broadcast_getindex!(dest::AbstractArray, src::AbstractArray, I::AbstractArray...) N = length(I) Isplat = Expr[:(I[$d]) for d = 1:N] @@ -278,22 +278,22 @@ end eltype_plus(As::AbstractArray...) = promote_eltype_op(+, As...) -.+(As::AbstractArray...) = broadcast!(+, Array(eltype_plus(As...), broadcast_shape(As...)), As...) +.+(As::AbstractArray...) = broadcast!(+, Array{eltype_plus(As...)}(broadcast_shape(As...)), As...) function .-(A::AbstractArray, B::AbstractArray) - broadcast!(-, Array(promote_op(-, eltype(A), eltype(B)), broadcast_shape(A,B)), A, B) + broadcast!(-, Array{promote_op(-, eltype(A), eltype(B))}(broadcast_shape(A,B)), A, B) end eltype_mul(As::AbstractArray...) = promote_eltype_op(*, As...) -.*(As::AbstractArray...) = broadcast!(*, Array(eltype_mul(As...), broadcast_shape(As...)), As...) +.*(As::AbstractArray...) = broadcast!(*, Array{eltype_mul(As...)}(broadcast_shape(As...)), As...) function ./(A::AbstractArray, B::AbstractArray) - broadcast!(/, Array(promote_op(/, eltype(A), eltype(B)), broadcast_shape(A, B)), A, B) + broadcast!(/, Array{promote_op(/, eltype(A), eltype(B))}(broadcast_shape(A, B)), A, B) end function .\(A::AbstractArray, B::AbstractArray) - broadcast!(\, Array(promote_op(\, eltype(A), eltype(B)), broadcast_shape(A, B)), A, B) + broadcast!(\, Array{promote_op(\, eltype(A), eltype(B))}(broadcast_shape(A, B)), A, B) end typealias RatIntT{T<:Integer} Union{Type{Rational{T}},Type{T}} @@ -303,11 +303,11 @@ type_rdiv{T<:Integer,S<:Integer}(::RatIntT{T}, ::RatIntT{S}) = type_rdiv{T<:Integer,S<:Integer}(::CRatIntT{T}, ::CRatIntT{S}) = Complex{Rational{promote_type(T,S)}} function .//(A::AbstractArray, B::AbstractArray) - broadcast!(//, Array(type_rdiv(eltype(A), eltype(B)), broadcast_shape(A, B)), A, B) + broadcast!(//, Array{type_rdiv(eltype(A), eltype(B))}(broadcast_shape(A, B)), A, B) end function .^(A::AbstractArray, B::AbstractArray) - broadcast!(^, Array(promote_op(^, eltype(A), eltype(B)), broadcast_shape(A, B)), A, B) + broadcast!(^, Array{promote_op(^, eltype(A), eltype(B))}(broadcast_shape(A, B)), A, B) end ## element-wise comparison operators returning BitArray ## @@ -372,7 +372,7 @@ for (f, cachef, scalarf) in ((:.==, :bitcache_eq , :(==)), l = length(F) l == 0 && return F Fc = F.chunks - C = Array(Bool, bitcache_size) + C = Array{Bool}(bitcache_size) ind = 1 cind = 1 for i = 1:div(l + bitcache_size - 1, bitcache_size) @@ -414,7 +414,7 @@ function (.^){T<:Integer}(A::BitArray, B::Array{T}) l == 0 && return F Ac = A.chunks Fc = F.chunks - C = Array(Bool, bitcache_size) + C = Array{Bool}(bitcache_size) ind = 1 cind = 1 for i = 1:div(l + bitcache_size - 1, bitcache_size) diff --git a/base/channels.jl b/base/channels.jl index 0fcf92a1c0fb2..c84e2da112f85 100644 --- a/base/channels.jl +++ b/base/channels.jl @@ -14,7 +14,7 @@ type Channel{T} <: AbstractChannel function Channel(sz) sz_max = sz == typemax(Int) ? typemax(Int) - 1 : sz - new(Condition(), Condition(), :open, Array(T, 0), sz_max) + new(Condition(), Condition(), :open, Array{T}(0), sz_max) end end diff --git a/base/collections.jl b/base/collections.jl index dcaa9eda31feb..2f64f3a48c5f4 100644 --- a/base/collections.jl +++ b/base/collections.jl @@ -148,7 +148,7 @@ type PriorityQueue{K,V,O<:Ordering} <: Associative{K,V} index::Dict{K, Int} function PriorityQueue(o::O) - new(Array(Pair{K,V}, 0), o, Dict{K, Int}()) + new(Array{Pair{K,V}}(0), o, Dict{K, Int}()) end PriorityQueue() = PriorityQueue{K,V,O}(Forward) @@ -163,7 +163,7 @@ type PriorityQueue{K,V,O<:Ordering} <: Associative{K,V} end function PriorityQueue(itr, o::O) - xs = Array(Pair{K,V}, length(itr)) + xs = Array{Pair{K,V}}(length(itr)) index = Dict{K, Int}() for (i, (k, v)) in enumerate(itr) xs[i] = Pair{K,V}(k, v) diff --git a/base/dSFMT.jl b/base/dSFMT.jl index 5107c79e18ba4..79b6a4f1a3b2a 100644 --- a/base/dSFMT.jl +++ b/base/dSFMT.jl @@ -21,7 +21,7 @@ const JPOLY1e21 = "e172e20c5d2de26b567c0cace9e7c6cc4407bd5ffcd22ca59d37b73d54fd type DSFMT_state val::Vector{Int32} - DSFMT_state() = new(Array(Int32, JN32)) + DSFMT_state() = new(Array{Int32}(JN32)) DSFMT_state(val::Vector{Int32}) = new(val) end diff --git a/base/datafmt.jl b/base/datafmt.jl index 7741ab3480fa5..3ae4f60196704 100644 --- a/base/datafmt.jl +++ b/base/datafmt.jl @@ -18,7 +18,7 @@ const offs_chunk_size = 5000 countlines(f::AbstractString, eol::Char='\n') = open(io->countlines(io,eol), f)::Int function countlines(io::IO, eol::Char='\n') isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported")) - a = Array(UInt8, 8192) + a = Array{UInt8}(8192) nl = 0 while !eof(io) nb = readbytes!(io, a) @@ -78,8 +78,8 @@ type DLMOffsets <: DLMHandler bufflen::Int function DLMOffsets(sbuff::String) - offsets = Array(Array{Int,1}, 1) - offsets[1] = Array(Int, offs_chunk_size) + offsets = Array{Array{Int,1}}(1) + offsets[1] = Array{Int}(offs_chunk_size) thresh = ceil(min(typemax(UInt), Base.Sys.total_memory()) / sizeof(Int) / 5) new(offsets, 1, thresh, length(sbuff.data)) end @@ -103,7 +103,7 @@ function store_cell(dlmoffsets::DLMOffsets, row::Int, col::Int, return end end - offsets = Array(Int, offs_chunk_size) + offsets = Array{Int}(offs_chunk_size) push!(oarr, offsets) offidx = 1 end @@ -142,7 +142,7 @@ function DLMStore{T}(::Type{T}, dims::NTuple{2,Integer}, nrows <= 0 && throw(ArgumentError("number of rows in dims must be > 0, got $nrows")) ncols <= 0 && throw(ArgumentError("number of columns in dims must be > 0, got $ncols")) hdr_offset = has_header ? 1 : 0 - DLMStore{T}(fill(SubString(sbuff,1,0), 1, ncols), Array(T, nrows-hdr_offset, ncols), + DLMStore{T}(fill(SubString(sbuff,1,0), 1, ncols), Array{T}(nrows-hdr_offset, ncols), nrows, ncols, 0, 0, hdr_offset, sbuff, auto, eol) end diff --git a/base/deprecated.jl b/base/deprecated.jl index 5dde191588179..c60c47f869d8e 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -972,7 +972,7 @@ end @noinline function fieldoffsets(x::DataType) depwarn("fieldoffsets is deprecated. use `map(idx->fieldoffset(x, idx), 1:nfields(x))` instead", :fieldoffsets) nf = nfields(x) - offsets = Array(Int, nf) + offsets = Array{Int}(nf) for i = 1:nf offsets[i] = fieldoffset(x, i) end @@ -1184,6 +1184,7 @@ end @deprecate ==(x::Integer, y::Char) x == UInt32(y) @deprecate isless(x::Char, y::Integer) UInt32(x) < y @deprecate isless(x::Integer, y::Char) x < UInt32(y) + # delete these methods along with deprecations: isequal(x::Char, y::Integer) = false isequal(x::Integer, y::Char) = false diff --git a/base/dft.jl b/base/dft.jl index bc4ea46f26d9b..6379968e022ea 100644 --- a/base/dft.jl +++ b/base/dft.jl @@ -24,9 +24,9 @@ complexfloat{T<:AbstractFloat}(x::AbstractArray{Complex{T}}) = x # return an Array, rather than similar(x), to avoid an extra copy for FFTW # (which only works on StridedArray types). -complexfloat{T<:Complex}(x::AbstractArray{T}) = copy!(Array(typeof(float(one(T))), size(x)), x) -complexfloat{T<:AbstractFloat}(x::AbstractArray{T}) = copy!(Array(typeof(complex(one(T))), size(x)), x) -complexfloat{T<:Real}(x::AbstractArray{T}) = copy!(Array(typeof(complex(float(one(T)))), size(x)), x) +complexfloat{T<:Complex}(x::AbstractArray{T}) = copy!(Array{typeof(float(one(T)))}(size(x)), x) +complexfloat{T<:AbstractFloat}(x::AbstractArray{T}) = copy!(Array{typeof(complex(one(T)))}(size(x)), x) +complexfloat{T<:Real}(x::AbstractArray{T}) = copy!(Array{typeof(complex(float(one(T))))}(size(x)), x) # implementations only need to provide plan_X(x, region) # for X in (:fft, :bfft, ...): @@ -191,7 +191,7 @@ rfft{T<:Union{Integer,Rational}}(x::AbstractArray{T}, region=1:ndims(x)) = rfft( plan_rfft{T<:Union{Integer,Rational}}(x::AbstractArray{T}, region; kws...) = plan_rfft(float(x), region; kws...) # only require implementation to provide *(::Plan{T}, ::Array{T}) -*{T}(p::Plan{T}, x::AbstractArray) = p * copy!(Array(T, size(x)), x) +*{T}(p::Plan{T}, x::AbstractArray) = p * copy!(Array{T}(size(x)), x) # Implementations should also implement A_mul_B!(Y, plan, X) so as to support # pre-allocated output arrays. We don't define * in terms of A_mul_B! diff --git a/base/dict.jl b/base/dict.jl index ecb8eaa38689f..2b2da1efc432d 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -104,7 +104,7 @@ function show{K,V}(io::IO, t::Associative{K,V}) rows -= 2 # Subtract the summary and final ⋮ continuation lines # determine max key width to align the output, caching the strings - ks = Array(AbstractString, min(rows, length(t))) + ks = Array{AbstractString}(min(rows, length(t))) keylen = 0 for (i, k) in enumerate(keys(t)) i > rows && break @@ -251,7 +251,7 @@ function merge(d::Associative, others::Associative...) end function filter!(f, d::Associative) - badkeys = Array(keytype(d), 0) + badkeys = Array{keytype(d)}(0) for (k,v) in d # don't delete!(d, k) here, since associative types # may not support mutation during iteration @@ -426,7 +426,7 @@ type Dict{K,V} <: Associative{K,V} function Dict() n = 16 - new(zeros(UInt8,n), Array(K,n), Array(V,n), 0, 0, false, 1, 0) + new(zeros(UInt8,n), Array{K}(n), Array{V}(n), 0, 0, false, 1, 0) end function Dict(kv) h = Dict{K,V}() @@ -540,8 +540,8 @@ function rehash!{K,V}(h::Dict{K,V}, newsz = length(h.keys)) end slots = zeros(UInt8,newsz) - keys = Array(K, newsz) - vals = Array(V, newsz) + keys = Array{K}(newsz) + vals = Array{V}(newsz) count0 = h.count count = 0 maxprobe = h.maxprobe diff --git a/base/docs/helpdb/Base.jl b/base/docs/helpdb/Base.jl index 40c2b91431a6c..b7288199a08aa 100644 --- a/base/docs/helpdb/Base.jl +++ b/base/docs/helpdb/Base.jl @@ -6183,7 +6183,7 @@ argument or as a series of integer arguments. Custom AbstractArray subtypes may choose which specific array type is best-suited to return for the given element type and dimensionality. If they do not specialize this method, the -default is an `Array(element_type, dims...)`. +default is an `Array{element_type}(dims...)`. For example, `similar(1:10, 1, 4)` returns an uninitialized `Array{Int,2}` since ranges are neither mutable nor support 2 dimensions: diff --git a/base/docs/utils.jl b/base/docs/utils.jl index d03dcdc1ac0a4..67d2bb860b1ed 100644 --- a/base/docs/utils.jl +++ b/base/docs/utils.jl @@ -223,7 +223,7 @@ function levenshtein(s1, s2) a, b = collect(s1), collect(s2) m = length(a) n = length(b) - d = Array(Int, m+1, n+1) + d = Array{Int}(m+1, n+1) d[1:m+1, 1] = 0:m d[1, 1:n+1] = 0:n diff --git a/base/dsp.jl b/base/dsp.jl index fdcb2aa1d6b3f..43ec69440cbe6 100644 --- a/base/dsp.jl +++ b/base/dsp.jl @@ -10,7 +10,7 @@ _zerosi(b,a,T) = zeros(promote_type(eltype(b), eltype(a), T), max(length(a), len function filt{T,S}(b::Union{AbstractVector, Number}, a::Union{AbstractVector, Number}, x::AbstractArray{T}, si::AbstractArray{S}=_zerosi(b,a,T)) - filt!(Array(promote_type(eltype(b), eltype(a), T, S), size(x)), b, a, x, si) + filt!(Array{promote_type(eltype(b), eltype(a), T, S)}(size(x)), b, a, x, si) end # in-place filtering: returns results in the out argument, which may shadow x diff --git a/base/env.jl b/base/env.jl index 48631f1ab4f67..bd25cc43311c1 100644 --- a/base/env.jl +++ b/base/env.jl @@ -95,7 +95,7 @@ function next(hash::EnvHash, block::Tuple{Ptr{UInt16},Ptr{UInt16}}) pos = block[1] blk = block[2] len = ccall(:wcslen, UInt, (Ptr{UInt16},), pos) - buf = Array(UInt16, len) + buf = Array{UInt16}(len) unsafe_copy!(pointer(buf), pos, len) env = String(utf16to8(buf)) m = match(r"^(=?[^=]+)=(.*)$"s, env) diff --git a/base/essentials.jl b/base/essentials.jl index 22802180d0e03..f64418883a0e5 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -92,7 +92,7 @@ function append_any(xs...) # used by apply() and quote # must be a separate function from append(), since apply() needs this # exact function. - out = Array(Any, 4) + out = Array{Any}(4) l = 4 i = 1 for x in xs diff --git a/base/fft/FFTW.jl b/base/fft/FFTW.jl index 27408e71e6a61..e94812ab721b9 100644 --- a/base/fft/FFTW.jl +++ b/base/fft/FFTW.jl @@ -84,7 +84,7 @@ pointer{T}(a::FakeArray{T}) = convert(Ptr{T}, C_NULL) FakeArray{T, N}(::Type{T}, sz::NTuple{N, Int}) = FakeArray{T, N}(sz, colmajorstrides(sz)) FakeArray{T}(::Type{T}, sz::Int...) = FakeArray(T, sz) -fakesimilar(flags, X, T) = flags & ESTIMATE != 0 ? FakeArray(T, size(X)) : Array(T, size(X)) +fakesimilar(flags, X, T) = flags & ESTIMATE != 0 ? FakeArray(T, size(X)) : Array{T}(size(X)) alignment_of(A::FakeArray) = Int32(0) ## Julia wrappers around FFTW functions @@ -433,7 +433,7 @@ function fix_kinds(region, kinds) if isempty(kinds) throw(ArgumentError("must supply a transform kind")) end - k = Array(Int32, length(region)) + k = Array{Int32}(length(region)) k[1:length(kinds)] = [kinds...] k[length(kinds)+1:end] = kinds[end] kinds = k @@ -566,12 +566,12 @@ end # (FIXME: is there a way to use the Julia promotion rules more cleverly here?) fftwcomplex{T<:fftwComplex}(X::StridedArray{T}) = X fftwcomplex{T<:fftwReal}(X::AbstractArray{T}) = - copy!(Array(typeof(complex(one(T))), size(X)), X) -fftwcomplex{T<:Real}(X::AbstractArray{T}) = copy!(Array(Complex128, size(X)),X) + copy!(Array{typeof(complex(one(T)))}(size(X)), X) +fftwcomplex{T<:Real}(X::AbstractArray{T}) = copy!(Array{Complex128}(size(X)),X) fftwcomplex{T<:Complex}(X::AbstractArray{T}) = - copy!(Array(Complex128, size(X)), X) + copy!(Array{Complex128}(size(X)), X) fftwfloat{T<:fftwReal}(X::StridedArray{T}) = X -fftwfloat{T<:Real}(X::AbstractArray{T}) = copy!(Array(Float64, size(X)), X) +fftwfloat{T<:Real}(X::AbstractArray{T}) = copy!(Array{Float64}(size(X)), X) fftwfloat{T<:Complex}(X::AbstractArray{T}) = fftwcomplex(X) for (f,direction) in ((:fft,FORWARD), (:bfft,BACKWARD)) @@ -597,7 +597,7 @@ for (f,direction) in ((:fft,FORWARD), (:bfft,BACKWARD)) $plan_f!(X, 1:ndims(X); kws...) function plan_inv{T<:fftwComplex,N,inplace}(p::cFFTWPlan{T,$direction,inplace,N}) - X = Array(T, p.sz) + X = Array{T}(p.sz) Y = inplace ? X : fakesimilar(p.flags, X, T) ScaledPlan(cFFTWPlan{T,$idirection,inplace,N}(X, Y, p.region, p.flags, NO_TIMELIMIT), @@ -614,7 +614,7 @@ end function *{T,K,N}(p::cFFTWPlan{T,K,false}, x::StridedArray{T,N}) assert_applicable(p, x) - y = Array(T, p.osz)::Array{T,N} + y = Array{T}(p.osz)::Array{T,N} unsafe_execute!(p, x, y) return y end @@ -634,7 +634,7 @@ for (Tr,Tc) in ((:Float32,:Complex64),(:Float64,:Complex128)) flags::Integer=ESTIMATE, timelimit::Real=NO_TIMELIMIT) osize = rfft_output_size(X, region) - Y = flags&ESTIMATE != 0 ? FakeArray($Tc,osize...) : Array($Tc,osize...) + Y = flags&ESTIMATE != 0 ? FakeArray($Tc,osize...) : Array{$Tc}(osize...) rFFTWPlan{$Tr,$FORWARD,false,N}(X, Y, region, flags, timelimit) end @@ -642,7 +642,7 @@ for (Tr,Tc) in ((:Float32,:Complex64),(:Float64,:Complex128)) flags::Integer=ESTIMATE, timelimit::Real=NO_TIMELIMIT) osize = brfft_output_size(X, d, region) - Y = flags&ESTIMATE != 0 ? FakeArray($Tr,osize...) : Array($Tr,osize...) + Y = flags&ESTIMATE != 0 ? FakeArray($Tr,osize...) : Array{$Tr}(osize...) # FFTW currently doesn't support PRESERVE_INPUT for # multidimensional out-of-place c2r transforms, so @@ -661,8 +661,8 @@ for (Tr,Tc) in ((:Float32,:Complex64),(:Float64,:Complex128)) plan_brfft(X::StridedArray{$Tr};kws...)=plan_brfft(X,1:ndims(X);kws...) function plan_inv{N}(p::rFFTWPlan{$Tr,$FORWARD,false,N}) - X = Array($Tr, p.sz) - Y = p.flags&ESTIMATE != 0 ? FakeArray($Tc,p.osz) : Array($Tc,p.osz) + X = Array{$Tr}(p.sz) + Y = p.flags&ESTIMATE != 0 ? FakeArray($Tc,p.osz) : Array{$Tc}(p.osz) ScaledPlan(rFFTWPlan{$Tc,$BACKWARD,false,N}(Y, X, p.region, length(p.region) <= 1 ? p.flags | PRESERVE_INPUT : @@ -671,8 +671,8 @@ for (Tr,Tc) in ((:Float32,:Complex64),(:Float64,:Complex128)) end function plan_inv{N}(p::rFFTWPlan{$Tc,$BACKWARD,false,N}) - X = Array($Tc, p.sz) - Y = p.flags&ESTIMATE != 0 ? FakeArray($Tr,p.osz) : Array($Tr,p.osz) + X = Arra{$Tc}(p.sz) + Y = p.flags&ESTIMATE != 0 ? FakeArray($Tr,p.osz) : Array{$Tr}(p.osz) ScaledPlan(rFFTWPlan{$Tr,$FORWARD,false,N}(Y, X, p.region, p.flags, NO_TIMELIMIT), normalization(Y, p.region)) @@ -691,7 +691,7 @@ for (Tr,Tc) in ((:Float32,:Complex64),(:Float64,:Complex128)) function *{N}(p::rFFTWPlan{$Tr,$FORWARD,false}, x::StridedArray{$Tr,N}) assert_applicable(p, x) - y = Array($Tc, p.osz)::Array{$Tc,N} + y = Array{$Tc}(p.osz)::Array{$Tc,N} unsafe_execute!(p, x, y) return y end @@ -699,12 +699,12 @@ for (Tr,Tc) in ((:Float32,:Complex64),(:Float64,:Complex128)) function *{N}(p::rFFTWPlan{$Tc,$BACKWARD,false}, x::StridedArray{$Tc,N}) if p.flags & PRESERVE_INPUT != 0 assert_applicable(p, x) - y = Array($Tr, p.osz)::Array{$Tr,N} + y = Array{$Tr}(p.osz)::Array{$Tr,N} unsafe_execute!(p, x, y) else # need to make a copy to avoid overwriting x xc = copy(x) assert_applicable(p, xc) - y = Array($Tr, p.osz)::Array{$Tr,N} + y = Array{$Tr}(p.osz)::Array{$Tr,N} unsafe_execute!(p, xc, y) end return y @@ -828,7 +828,7 @@ function logical_size(n::Integer, k::Integer) end function plan_inv{T<:fftwNumber,K,inplace,N}(p::r2rFFTWPlan{T,K,inplace,N}) - X = Array(T, p.sz) + X = Array{T}(p.sz) iK = fix_kinds(p.region, [inv_kind[k] for k in K]) Y = inplace ? X : fakesimilar(p.flags, X, T) ScaledPlan(r2rFFTWPlan{T,ANY,inplace,N}(X, Y, p.region, iK, @@ -846,7 +846,7 @@ end function *{T,K,N}(p::r2rFFTWPlan{T,K,false}, x::StridedArray{T,N}) assert_applicable(p, x) - y = Array(T, p.osz)::Array{T,N} + y = Array{T}(p.osz)::Array{T,N} unsafe_execute!(p, x, y) return y end diff --git a/base/fft/dct.jl b/base/fft/dct.jl index b41ed8747e11d..d3d955e44c2f5 100644 --- a/base/fft/dct.jl +++ b/base/fft/dct.jl @@ -73,7 +73,7 @@ Same as [`plan_idct`](:func:`plan_idct`), but operates in-place on `A`. plan_idct! function plan_inv{T,K,inplace}(p::DCTPlan{T,K,inplace}) - X = Array(T, p.plan.sz) + X = Array{T}(p.plan.sz) iK = inv_kind[K] DCTPlan{T,iK,inplace}(inplace ? plan_r2r!(X, iK, p.region, flags=p.plan.flags) : @@ -168,9 +168,9 @@ function A_mul_B!{T}(y::StridedArray{T}, p::DCTPlan{T,REDFT01}, end *{T}(p::DCTPlan{T,REDFT10,false}, x::StridedArray{T}) = - A_mul_B!(Array(T, p.plan.osz), p, x) + A_mul_B!(Array{T}(p.plan.osz), p, x) *{T}(p::DCTPlan{T,REDFT01,false}, x::StridedArray{T}) = - A_mul_B!(Array(T, p.plan.osz), p, copy(x)) # need copy to preserve input + A_mul_B!(Array{T}(p.plan.osz), p, copy(x)) # need copy to preserve input *{T,K}(p::DCTPlan{T,K,true}, x::StridedArray{T}) = A_mul_B!(x, p, x) diff --git a/base/file.jl b/base/file.jl index 3efd0c731a466..64099cd643cdb 100644 --- a/base/file.jl +++ b/base/file.jl @@ -29,7 +29,7 @@ export # get and set current directory function pwd() - b = Array(UInt8,1024) + b = Array{UInt8}(1024) len = Ref{Csize_t}(length(b)) uv_error(:getcwd, ccall(:uv_cwd, Cint, (Ptr{UInt8}, Ptr{Csize_t}), b, len)) String(b[1:len[]]) @@ -197,7 +197,7 @@ end if is_windows() function tempdir() - temppath = Array(UInt16,32767) + temppath = Array{UInt16}(32767) lentemppath = ccall(:GetTempPathW,stdcall,UInt32,(UInt32,Ptr{UInt16}),length(temppath),temppath) if lentemppath >= length(temppath) || lentemppath == 0 error("GetTempPath failed: $(Libc.FormatMessage())") @@ -209,7 +209,7 @@ tempname(uunique::UInt32=UInt32(0)) = tempname(tempdir(), uunique) const temp_prefix = cwstring("jl_") function tempname(temppath::AbstractString,uunique::UInt32) tempp = cwstring(temppath) - tname = Array(UInt16,32767) + tname = Array{UInt16}(32767) uunique = ccall(:GetTempFileNameW,stdcall,UInt32,(Ptr{UInt16},Ptr{UInt16},UInt32,Ptr{UInt16}), tempp,temp_prefix,uunique,tname) lentname = findfirst(tname,0)-1 if uunique == 0 || lentname <= 0 @@ -348,8 +348,8 @@ function walkdir(root; topdown=true, follow_symlinks=false, onerror=throw) #Need to return an empty task to skip the current root folder return Task(()->()) end - dirs = Array(eltype(content), 0) - files = Array(eltype(content), 0) + dirs = Array{eltype(content)}(0) + files = Array{eltype(content)}(0) for name in content if isdir(joinpath(root, name)) push!(dirs, name) diff --git a/base/filesystem.jl b/base/filesystem.jl index b36985dfc8d0a..17f2e35f5796f 100644 --- a/base/filesystem.jl +++ b/base/filesystem.jl @@ -173,9 +173,9 @@ function readbytes!(f::File, b::Array{UInt8}, nb=length(b)) uv_error("read",ret) return ret end -read(io::File) = read!(io, Array(UInt8, nb_available(io))) +read(io::File) = read!(io, Array{UInt8}(nb_available(io))) readavailable(io::File) = read(io) -read(io::File, nb::Integer) = read!(io, Array(UInt8, min(nb, nb_available(io)))) +read(io::File, nb::Integer) = read!(io, Array{UInt8}(min(nb, nb_available(io)))) const SEEK_SET = Int32(0) const SEEK_CUR = Int32(1) diff --git a/base/float16.jl b/base/float16.jl index 16d4067f33267..a58a36a4c7a85 100644 --- a/base/float16.jl +++ b/base/float16.jl @@ -46,8 +46,8 @@ end # "Fast Half Float Conversion" by Jeroen van der Zijp # ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf -const basetable = Array(UInt16, 512) -const shifttable = Array(UInt8, 512) +const basetable = Array{UInt16}(512) +const shifttable = Array{UInt8}(512) for i = 0:255 e = i - 127 diff --git a/base/grisu.jl b/base/grisu.jl index 04342adfe0a7d..04043bb8191da 100644 --- a/base/grisu.jl +++ b/base/grisu.jl @@ -11,7 +11,7 @@ const SHORTEST = 1 const FIXED = 2 const PRECISION = 3 -const DIGITS = Array(UInt8,309+17) +const DIGITS = Array{UInt8}(309+17) include("grisu/float.jl") include("grisu/fastshortest.jl") diff --git a/base/grisu/bignums.jl b/base/grisu/bignums.jl index 3cb0bb1f80e65..6dfb917d50460 100644 --- a/base/grisu/bignums.jl +++ b/base/grisu/bignums.jl @@ -54,7 +54,7 @@ type Bignum used_digits::Int32 exponent::Int32 function Bignum() - bigits = Array(UInt32,kBigitCapacity) + bigits = Array{UInt32}(kBigitCapacity) @inbounds for i = 1:kBigitCapacity bigits[i] = 0 end diff --git a/base/grisu/fastprecision.jl b/base/grisu/fastprecision.jl index a1f8e3eed6074..4167557f034fc 100644 --- a/base/grisu/fastprecision.jl +++ b/base/grisu/fastprecision.jl @@ -87,7 +87,7 @@ function digitgen(w,buffer,requested_digits=1000) return r, kappa, len end -function fastprecision(v,requested_digits,buffer=Array(UInt8,100)) +function fastprecision(v, requested_digits, buffer = Array{UInt8}(100)) f = normalize(Float64(v)) ten_mk_min_exp = kMinExp - (f.e + FloatSignificandSize) ten_mk_max_exp = kMaxExp - (f.e + FloatSignificandSize) diff --git a/base/grisu/fastshortest.jl b/base/grisu/fastshortest.jl index 5c0312d56ff28..519850e009abc 100644 --- a/base/grisu/fastshortest.jl +++ b/base/grisu/fastshortest.jl @@ -102,7 +102,7 @@ function digitgen(low,w,high,buffer) end end -function fastshortest(v,buffer=Array(UInt8,17)) +function fastshortest(v, buffer = Array{UInt8}(17)) f = normalize(Float64(v)) bound_minus, bound_plus = normalizedbound(v) ten_mk_min_exp = kMinExp - (f.e + FloatSignificandSize) diff --git a/base/inference.jl b/base/inference.jl index 1379d6ee2587d..935bb03b7b9d2 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -798,7 +798,7 @@ function abstract_call_gf_by_type(f::ANY, argtype::ANY, sv) p1, p2 = sig.parameters, infstate.atypes.parameters if length(p2) == ls limitdepth = false - newsig = Array(Any, ls) + newsig = Array{Any}(ls) for i = 1:ls if p1[i] <: Function && type_depth(p1[i]) > type_depth(p2[i]) && isa(p1[i],DataType) diff --git a/base/intfuncs.jl b/base/intfuncs.jl index 4ad483f41ea79..d85b98cb4a8fc 100644 --- a/base/intfuncs.jl +++ b/base/intfuncs.jl @@ -232,7 +232,7 @@ string(x::Union{Int8,Int16,Int32,Int64,Int128}) = dec(x) function bin(x::Unsigned, pad::Int, neg::Bool) i = neg + max(pad,sizeof(x)<<3-leading_zeros(x)) - a = Array(UInt8,i) + a = Array{UInt8}(i) while i > neg a[i] = '0'+(x&0x1) x >>= 1 @@ -244,7 +244,7 @@ end function oct(x::Unsigned, pad::Int, neg::Bool) i = neg + max(pad,div((sizeof(x)<<3)-leading_zeros(x)+2,3)) - a = Array(UInt8,i) + a = Array{UInt8}(i) while i > neg a[i] = '0'+(x&0x7) x >>= 3 @@ -256,7 +256,7 @@ end function dec(x::Unsigned, pad::Int, neg::Bool) i = neg + max(pad,ndigits0z(x)) - a = Array(UInt8,i) + a = Array{UInt8}(i) while i > neg a[i] = '0'+rem(x,10) x = oftype(x,div(x,10)) @@ -268,7 +268,7 @@ end function hex(x::Unsigned, pad::Int, neg::Bool) i = neg + max(pad,(sizeof(x)<<1)-(leading_zeros(x)>>2)) - a = Array(UInt8,i) + a = Array{UInt8}(i) while i > neg d = x & 0xf a[i] = '0'+d+39*(d>9) @@ -288,7 +288,7 @@ function base(b::Int, x::Unsigned, pad::Int, neg::Bool) 2 <= b <= 62 || throw(ArgumentError("base must be 2 ≤ base ≤ 62, got $b")) digits = b <= 36 ? base36digits : base62digits i = neg + max(pad,ndigits0z(x,b)) - a = Array(UInt8,i) + a = Array{UInt8}(i) while i > neg a[i] = digits[1+rem(x,b)] x = div(x,b) diff --git a/base/io.jl b/base/io.jl index 3ca9748e20e46..e186abdf9365b 100644 --- a/base/io.jl +++ b/base/io.jl @@ -222,7 +222,7 @@ read{T}(s::IO, t::Type{T}, d1::Int, dims::Int...) = read(s, t, tuple(d1,dims...) read{T}(s::IO, t::Type{T}, d1::Integer, dims::Integer...) = read(s, t, convert(Tuple{Vararg{Int}},tuple(d1,dims...))) -read{T}(s::IO, ::Type{T}, dims::Dims) = read!(s, Array(T, dims)) +read{T}(s::IO, ::Type{T}, dims::Dims) = read!(s, Array{T}(dims)) @noinline function read!(s::IO, a::Array{UInt8}) # mark noinline to ensure the array is gc-rooted somewhere (by the caller) unsafe_read(s, pointer(a), sizeof(a)) @@ -296,7 +296,7 @@ function readuntil(s::IO, t::AbstractString) warn("readuntil(IO,AbstractString) will perform poorly with a long string") end out = IOBuffer() - m = Array(Char, l) # last part of stream to match + m = Array{Char}(l) # last part of stream to match t = collect(t) i = 0 while !eof(s) @@ -346,7 +346,7 @@ end function read(s::IO, nb=typemax(Int)) # Let readbytes! grow the array progressively by default # instead of taking of risk of over-allocating - b = Array(UInt8, nb == typemax(Int) ? 1024 : nb) + b = Array{UInt8}(nb == typemax(Int) ? 1024 : nb) nr = readbytes!(s, b, nb) return resize!(b, nr) end diff --git a/base/iobuffer.jl b/base/iobuffer.jl index a24d3a41c5946..60ffbde5f6db1 100644 --- a/base/iobuffer.jl +++ b/base/iobuffer.jl @@ -27,12 +27,12 @@ IOBuffer(data::AbstractVector{UInt8}, readable::Bool=true, writable::Bool=false, AbstractIOBuffer(data, readable, writable, true, false, maxsize) IOBuffer(readable::Bool, writable::Bool) = IOBuffer(UInt8[], readable, writable) IOBuffer() = IOBuffer(true, true) -IOBuffer(maxsize::Int) = (x=IOBuffer(Array(UInt8,maxsize), true, true, maxsize); x.size=0; x) +IOBuffer(maxsize::Int) = (x=IOBuffer(Array{UInt8}(maxsize), true, true, maxsize); x.size=0; x) # PipeBuffers behave like Unix Pipes. They are typically readable and writable, they act appendable, and are not seekable. PipeBuffer(data::Vector{UInt8}=UInt8[], maxsize::Int=typemax(Int)) = AbstractIOBuffer(data,true,true,false,true,maxsize) -PipeBuffer(maxsize::Int) = (x = PipeBuffer(Array(UInt8,maxsize),maxsize); x.size=0; x) +PipeBuffer(maxsize::Int) = (x = PipeBuffer(Array{UInt8}(maxsize),maxsize); x.size=0; x) function copy(b::AbstractIOBuffer) ret = typeof(b)(b.writable ? copy(b.data) : b.data, @@ -219,17 +219,17 @@ isopen(io::AbstractIOBuffer) = io.readable || io.writable || io.seekable || nb_a function String(io::AbstractIOBuffer) io.readable || throw(ArgumentError("IOBuffer is not readable")) io.seekable || throw(ArgumentError("IOBuffer is not seekable")) - return String(copy!(Array(UInt8, io.size), 1, io.data, 1, io.size)) + return String(copy!(Array{UInt8}(io.size), 1, io.data, 1, io.size)) end function takebuf_array(io::AbstractIOBuffer) ismarked(io) && unmark(io) if io.seekable nbytes = io.size - data = copy!(Array(UInt8, nbytes), 1, io.data, 1, nbytes) + data = copy!(Array{UInt8}(nbytes), 1, io.data, 1, nbytes) else nbytes = nb_available(io) - data = read!(io, Array(UInt8, nbytes)) + data = read!(io,Array{UInt8}(nbytes)) end if io.writable io.ptr = 1 @@ -243,14 +243,14 @@ function takebuf_array(io::IOBuffer) data = io.data if io.writable maxsize = (io.maxsize == typemax(Int) ? 0 : min(length(io.data),io.maxsize)) - io.data = Array(UInt8,maxsize) + io.data = Array{UInt8}(maxsize) else data = copy(data) end resize!(data,io.size) else nbytes = nb_available(io) - a = Array(UInt8, nbytes) + a = Array{UInt8}(nbytes) data = read!(io, a) end if io.writable @@ -327,9 +327,9 @@ function readbytes!(io::AbstractIOBuffer, b::Array{UInt8}, nb::Int) read_sub(io, b, 1, nr) return nr end -read(io::AbstractIOBuffer) = read!(io, Array(UInt8, nb_available(io))) +read(io::AbstractIOBuffer) = read!(io,Array{UInt8}(nb_available(io))) readavailable(io::AbstractIOBuffer) = read(io) -read(io::AbstractIOBuffer, nb::Integer) = read!(io, Array(UInt8, min(nb, nb_available(io)))) +read(io::AbstractIOBuffer, nb::Integer) = read!(io,Array{UInt8}(min(nb, nb_available(io)))) function search(buf::IOBuffer, delim::UInt8) p = pointer(buf.data, buf.ptr) @@ -351,7 +351,7 @@ end function readuntil(io::AbstractIOBuffer, delim::UInt8) lb = 70 - A = Array(UInt8, lb) + A = Array{UInt8}(lb) n = 0 data = io.data for i = io.ptr : io.size diff --git a/base/iostream.jl b/base/iostream.jl index 155d89899a32f..bd675c345b75c 100644 --- a/base/iostream.jl +++ b/base/iostream.jl @@ -241,19 +241,19 @@ function read(s::IOStream) sz -= pos end end - b = Array(UInt8, sz<=0 ? 1024 : sz) + b = Array{UInt8}(sz<=0 ? 1024 : sz) nr = readbytes_all!(s, b, typemax(Int)) resize!(b, nr) end function read(s::IOStream, nb::Integer; all::Bool=true) - b = Array(UInt8, nb) + b = Array{UInt8}(nb) nr = readbytes!(s, b, nb, all=all) resize!(b, nr) end ## Character streams ## -const _chtmp = Array(Char, 1) +const _chtmp = Array{Char}(1) function peekchar(s::IOStream) if ccall(:ios_peekutf8, Cint, (Ptr{Void}, Ptr{Char}), s, _chtmp) < 0 return Char(-1) diff --git a/base/libc.jl b/base/libc.jl index 17c849f750e17..0af4d0463eaa3 100644 --- a/base/libc.jl +++ b/base/libc.jl @@ -153,7 +153,7 @@ library. strftime(t) = strftime("%c", t) strftime(fmt::AbstractString, t::Real) = strftime(fmt, TmStruct(t)) function strftime(fmt::AbstractString, tm::TmStruct) - timestr = Array(UInt8, 128) + timestr = Array{UInt8}(128) n = ccall(:strftime, Int, (Ptr{UInt8}, Int, Cstring, Ptr{TmStruct}), timestr, length(timestr), fmt, &tm) if n == 0 @@ -212,7 +212,7 @@ getpid() = ccall(:jl_getpid, Int32, ()) ## network functions ## function gethostname() - hn = Array(UInt8, 256) + hn = Array{UInt8}(256) err = @static if is_windows() ccall(:gethostname, stdcall, Int32, (Ptr{UInt8}, UInt32), hn, length(hn)) else @@ -274,7 +274,7 @@ if is_windows() C_NULL, e, 0, lpMsgBuf, 0, C_NULL) p = lpMsgBuf[1] len == 0 && return "" - buf = Array(UInt16, len) + buf = Array{UInt16}(len) unsafe_copy!(pointer(buf), p, len) ccall(:LocalFree,stdcall,Ptr{Void},(Ptr{Void},),p) return String(utf16to8(buf)) diff --git a/base/libgit2/reference.jl b/base/libgit2/reference.jl index a42352e60cdde..444704bef6780 100644 --- a/base/libgit2/reference.jl +++ b/base/libgit2/reference.jl @@ -204,7 +204,7 @@ function Base.map(f::Function, bi::GitBranchIter) while !done(bi, s) val = f(s[1:2]) if res === nothing - res = Array(typeof(val),0) + res = Array{typeof(val)}(0) end push!(res, val) val, s = next(bi, s) diff --git a/base/libgit2/strarray.jl b/base/libgit2/strarray.jl index 162fab21efcc8..a4fed293168db 100644 --- a/base/libgit2/strarray.jl +++ b/base/libgit2/strarray.jl @@ -17,7 +17,7 @@ end StrArrayStruct{T<:AbstractString}(strs::Vector{T}) = StrArrayStruct(strs...) function Base.convert(::Type{Vector{AbstractString}}, sa::StrArrayStruct) - arr = Array(AbstractString, sa.count) + arr = Array{AbstractString}(sa.count) for i=1:sa.count arr[i] = String(unsafe_load(sa.strings, i)) end diff --git a/base/linalg/arpack.jl b/base/linalg/arpack.jl index b396db9c6d761..6f8084deb65f8 100644 --- a/base/linalg/arpack.jl +++ b/base/linalg/arpack.jl @@ -13,16 +13,16 @@ function aupd_wrapper(T, matvecA::Function, matvecB::Function, solveSI::Function lworkl = cmplx ? ncv * (3*ncv + 5) : (sym ? ncv * (ncv + 8) : ncv * (3*ncv + 6) ) TR = cmplx ? T.types[1] : T - TOL = Array(TR, 1) + TOL = Array{TR}(1) TOL[1] = tol - v = Array(T, n, ncv) - workd = Array(T, 3*n) - workl = Array(T, lworkl) - rwork = cmplx ? Array(TR, ncv) : Array(TR, 0) + v = Array{T}(n, ncv) + workd = Array{T}(3*n) + workl = Array{T}(lworkl) + rwork = cmplx ? Array{TR}(ncv) : Array{TR}(0) if isempty(v0) - resid = Array(T, n) + resid = Array{T}(n) info = zeros(BlasInt, 1) else resid = deepcopy(v0) @@ -112,7 +112,7 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::String, workd, workl, lworkl, rwork) howmny = "A" - select = Array(BlasInt, ncv) + select = Array{BlasInt}(ncv) info = zeros(BlasInt, 1) dmap = x->abs(x) @@ -130,9 +130,9 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::String, if cmplx - d = Array(T, nev+1) + d = Array{T}(nev+1) sigmar = ones(T, 1)*sigma - workev = Array(T, 2ncv) + workev = Array{T}(2ncv) neupd(ritzvec, howmny, select, d, v, ldv, sigmar, workev, bmat, n, which, nev, TOL, resid, ncv, v, ldv, iparam, ipntr, workd, workl, lworkl, rwork, info) @@ -145,7 +145,7 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::String, elseif sym - d = Array(T, nev) + d = Array{T}(nev) sigmar = ones(T, 1)*sigma seupd(ritzvec, howmny, select, d, v, ldv, sigmar, bmat, n, which, nev, TOL, resid, ncv, v, ldv, @@ -159,20 +159,20 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::String, else - dr = Array(T, nev+1) - di = Array(T, nev+1) + dr = Array{T}(nev+1) + di = Array{T}(nev+1) fill!(dr,NaN) fill!(di,NaN) sigmar = ones(T, 1)*real(sigma) sigmai = ones(T, 1)*imag(sigma) - workev = Array(T, 3*ncv) + workev = Array{T}(3*ncv) neupd(ritzvec, howmny, select, dr, di, v, ldv, sigmar, sigmai, workev, bmat, n, which, nev, TOL, resid, ncv, v, ldv, iparam, ipntr, workd, workl, lworkl, info) if info[1] != 0 throw(ARPACKException(info[1])) end - evec = complex(Array(T, n, nev+1), Array(T, n, nev+1)) + evec = complex(Array{T}(n, nev+1), Array{T}(n, nev+1)) j = 1 while j <= nev diff --git a/base/linalg/bidiag.jl b/base/linalg/bidiag.jl index efe2f07c28ef0..2e62a742950ae 100644 --- a/base/linalg/bidiag.jl +++ b/base/linalg/bidiag.jl @@ -447,7 +447,7 @@ factorize(A::Bidiagonal) = A eigvals(M::Bidiagonal) = M.dv function eigvecs{T}(M::Bidiagonal{T}) n = length(M.dv) - Q = Array(T, n, n) + Q = Array{T}(n, n) blks = [0; find(x -> x == 0, M.ev); n] if M.isupper for idx_block = 1:length(blks) - 1, i = blks[idx_block] + 1:blks[idx_block + 1] #index of eigenvector diff --git a/base/linalg/blas.jl b/base/linalg/blas.jl index 289c26de452fd..bf54e2d96964d 100644 --- a/base/linalg/blas.jl +++ b/base/linalg/blas.jl @@ -173,7 +173,7 @@ for (fname, elty) in ((:cblas_zdotc_sub,:Complex128), # * .. Array Arguments .. # DOUBLE PRECISION DX(*),DY(*) function dotc(n::Integer, DX::Union{Ptr{$elty},DenseArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},DenseArray{$elty}}, incy::Integer) - result = Array($elty, 1) + result = Array{$elty}(1) ccall((@blasfunc($fname), libblas), Void, (BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}), n, DX, incx, DY, incy, result) @@ -191,7 +191,7 @@ for (fname, elty) in ((:cblas_zdotu_sub,:Complex128), # * .. Array Arguments .. # DOUBLE PRECISION DX(*),DY(*) function dotu(n::Integer, DX::Union{Ptr{$elty},DenseArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},DenseArray{$elty}}, incy::Integer) - result = Array($elty, 1) + result = Array{$elty}(1) ccall((@blasfunc($fname), libblas), Void, (BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}), n, DX, incx, DY, incy, result) diff --git a/base/linalg/dense.jl b/base/linalg/dense.jl index 2dc3d593f056b..4724d5695acc5 100644 --- a/base/linalg/dense.jl +++ b/base/linalg/dense.jl @@ -107,7 +107,7 @@ tril(M::Matrix, k::Integer) = tril!(copy(M), k) function gradient(F::Vector, h::Vector) n = length(F) T = typeof(one(eltype(F))/one(eltype(h))) - g = Array(T,n) + g = Array{T}(n) if n == 1 g[1] = zero(T) elseif n > 1 @@ -139,7 +139,7 @@ function diagm{T}(v::AbstractVector{T}, k::Integer=0) A end -diagm(x::Number) = (X = Array(typeof(x),1,1); X[1,1] = x; X) +diagm(x::Number) = (X = Array{typeof(x)}(1,1); X[1,1] = x; X) function trace{T}(A::Matrix{T}) n = checksquare(A) @@ -151,7 +151,7 @@ function trace{T}(A::Matrix{T}) end function kron{T,S}(a::AbstractMatrix{T}, b::AbstractMatrix{S}) - R = Array(promote_type(T,S), size(a,1)*size(b,1), size(a,2)*size(b,2)) + R = Array{promote_type(T,S)}(size(a,1)*size(b,1), size(a,2)*size(b,2)) m = 1 for j = 1:size(a,2), l = 1:size(b,2), i = 1:size(a,1) aij = a[i,j] @@ -460,7 +460,7 @@ function pinv{T}(A::StridedMatrix{T}, tol::Real) m, n = size(A) Tout = typeof(zero(T)/sqrt(one(T) + one(T))) if m == 0 || n == 0 - return Array(Tout, n, m) + return Array{Tout}(n, m) end if istril(A) if istriu(A) diff --git a/base/linalg/lapack.jl b/base/linalg/lapack.jl index e768619e81c8f..8fb7b856d3d3b 100644 --- a/base/linalg/lapack.jl +++ b/base/linalg/lapack.jl @@ -194,8 +194,8 @@ for (gebal, gebak, elty, relty) in chkstride1(A) n = checksquare(A) chkfinite(A) # balancing routines don't support NaNs and Infs - ihi = Array(BlasInt, 1) - ilo = Array(BlasInt, 1) + ihi = Array{BlasInt}(1) + ilo = Array{BlasInt}(1) scale = similar(A, $relty, n) info = Ref{BlasInt}() ccall((@blasfunc($gebal), liblapack), Void, @@ -280,7 +280,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty e = similar(A, $relty, k) tauq = similar(A, $elty, k) taup = similar(A, $elty, k) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -294,7 +294,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, d, e, tauq, taup @@ -314,7 +314,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty throw(DimensionMismatch("tau has length $(length(tau)), but needs length $(min(m,n))")) end lwork = BlasInt(-1) - work = Array($elty, 1) + work = Array{$elty}(1) info = Ref{BlasInt}() for i = 1:2 # first call returns lwork as work[1] ccall((@blasfunc($gelqf), liblapack), Void, @@ -324,7 +324,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, tau @@ -344,7 +344,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty throw(DimensionMismatch("tau has length $(length(tau)), but needs length $(min(m,n))")) end lwork = BlasInt(-1) - work = Array($elty, 1) + work = Array{$elty}(1) info = Ref{BlasInt}() for i = 1:2 # first call returns lwork as work[1] ccall((@blasfunc($geqlf), liblapack), Void, @@ -354,7 +354,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, tau @@ -379,11 +379,11 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty if lda == 0 return A, tau, jpvt end # Early exit - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) cmplx = eltype(A)<:Complex if cmplx - rwork = Array($relty, 2n) + rwork = Array{$relty}(2n) end info = Ref{BlasInt}() for i = 1:2 @@ -407,7 +407,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end return A, tau, jpvt @@ -422,7 +422,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty throw(ArgumentError("Block size $nb > $minmn too large")) end lda = max(1, stride(A,2)) - work = Array($elty, nb*n) + work = Array{$elty}(nb*n) if n > 0 info = Ref{BlasInt}() ccall((@blasfunc($geqrt), liblapack), Void, @@ -472,7 +472,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty if length(tau) != min(m,n) throw(DimensionMismatch("tau has length $(length(tau)), but needs length $(min(m,n))")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 # first call returns lwork as work[1] @@ -483,7 +483,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, tau @@ -501,7 +501,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty throw(DimensionMismatch("tau has length $(length(tau)), but needs length $(min(m,n))")) end lwork = BlasInt(-1) - work = Array($elty, 1) + work = Array{$elty}(1) info = Ref{BlasInt}() for i = 1:2 # first call returns lwork as work[1] ccall((@blasfunc($gerqf), liblapack), Void, @@ -511,7 +511,7 @@ for (gebrd, gelqf, geqlf, geqrf, geqp3, geqrt, geqrt3, gerqf, getrf, elty, relty chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, tau @@ -756,7 +756,7 @@ for (tzrzf, ormrz, elty) in end lda = max(1, m) tau = similar(A, $elty, m) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -768,7 +768,7 @@ for (tzrzf, ormrz, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, tau @@ -793,7 +793,7 @@ for (tzrzf, ormrz, elty) in l = size(A, 2) - size(A, 1) lda = max(1, stride(A,2)) ldc = max(1, stride(C,2)) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -809,7 +809,7 @@ for (tzrzf, ormrz, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end C @@ -858,7 +858,7 @@ for (gels, gesv, getrs, getri, elty) in throw(DimensionMismatch("Matrix A has dimensions ($m,$n), transposed: $btrn, but leading dimension of B is $(size(B,1))")) end info = Ref{BlasInt}() - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) for i = 1:2 ccall((@blasfunc($gels), liblapack), Void, @@ -870,12 +870,12 @@ for (gels, gesv, getrs, getri, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end k = min(m, n) F = m < n ? tril(A[1:k, 1:k]) : triu(A[1:k, 1:k]) - ssr = Array($elty, size(B,2)) + ssr = Array{$elty}(size(B,2)) for i = 1:size(B,2) x = zero($elty) for j = k+1:size(B,1) @@ -947,7 +947,7 @@ for (gels, gesv, getrs, getri, elty) in end lda = max(1,stride(A, 2)) lwork = BlasInt(-1) - work = Array($elty, 1) + work = Array{$elty}(1) info = Ref{BlasInt}() for i = 1:2 ccall((@blasfunc($getri), liblapack), Void, @@ -957,7 +957,7 @@ for (gels, gesv, getrs, getri, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A @@ -1038,11 +1038,11 @@ for (gesvx, elty) in ldaf = stride(AF,2) nrhs = size(B,2) ldb = stride(B,2) - rcond = Array($elty, 1) + rcond = Array{$elty}(1) ferr = similar(A, $elty, nrhs) berr = similar(A, $elty, nrhs) - work = Array($elty, 4n) - iwork = Array(BlasInt, n) + work = Array{$elty}(4n) + iwork = Array{BlasInt}(n) info = Ref{BlasInt}() X = similar(A, $elty, n, nrhs) ccall((@blasfunc($gesvx), liblapack), Void, @@ -1107,11 +1107,11 @@ for (gesvx, elty, relty) in ldaf = stride(AF,2) nrhs = size(B,2) ldb = stride(B,2) - rcond = Array($relty, 1) + rcond = Array{$relty}(1) ferr = similar(A, $relty, nrhs) berr = similar(A, $relty, nrhs) - work = Array($elty, 2n) - rwork = Array($relty, 2n) + work = Array{$elty}(2n) + rwork = Array{$relty}(2n) info = Ref{BlasInt}() X = similar(A, $elty, n, nrhs) ccall((@blasfunc($gesvx), liblapack), Void, @@ -1204,11 +1204,11 @@ for (gelsd, gelsy, elty) in newB = [B; zeros($elty, max(0, n - size(B, 1)), size(B, 2))] s = similar(A, $elty, min(m, n)) rcond = convert($elty, rcond) - rnk = Array(BlasInt, 1) + rnk = Array{BlasInt}(1) info = Ref{BlasInt}() - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - iwork = Array(BlasInt, 1) + iwork = Array{BlasInt}(1) for i = 1:2 ccall((@blasfunc($gelsd), liblapack), Void, (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, @@ -1220,8 +1220,8 @@ for (gelsd, gelsy, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) - iwork = Array(BlasInt, iwork[1]) + work = Array{$elty}(lwork) + iwork = Array{BlasInt}(iwork[1]) end end subsetrows(B, newB, n), rnk[1] @@ -1249,8 +1249,8 @@ for (gelsd, gelsy, elty) in ldb = max(1, m, n) jpvt = zeros(BlasInt, n) rcond = convert($elty, rcond) - rnk = Array(BlasInt, 1) - work = Array($elty, 1) + rnk = Array{BlasInt}(1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -1266,7 +1266,7 @@ for (gelsd, gelsy, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(work[1]) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end subsetrows(B, newB, n), rnk[1] @@ -1297,12 +1297,12 @@ for (gelsd, gelsy, elty, relty) in newB = [B; zeros($elty, max(0, n - size(B, 1)), size(B, 2))] s = similar(A, $relty, min(m, n)) rcond = convert($relty, rcond) - rnk = Array(BlasInt, 1) + rnk = Array{BlasInt}(1) info = Ref{BlasInt}() - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - rwork = Array($relty, 1) - iwork = Array(BlasInt, 1) + rwork = Array{$relty}(1) + iwork = Array{BlasInt}(1) for i = 1:2 ccall((@blasfunc($gelsd), liblapack), Void, (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, @@ -1314,9 +1314,9 @@ for (gelsd, gelsy, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) - rwork = Array($relty, BlasInt(rwork[1])) - iwork = Array(BlasInt, iwork[1]) + work = Array{$elty}(lwork) + rwork = Array{$relty}(BlasInt(rwork[1])) + iwork = Array{BlasInt}(iwork[1]) end end subsetrows(B, newB, n), rnk[1] @@ -1344,10 +1344,10 @@ for (gelsd, gelsy, elty, relty) in ldb = max(1, m, n) jpvt = zeros(BlasInt, n) rcond = convert($relty, rcond) - rnk = Array(BlasInt, 1) - work = Array($elty, 1) + rnk = Array{BlasInt}(1) + work = Array{$elty}(1) lwork = BlasInt(-1) - rwork = Array($relty, 2n) + rwork = Array{$relty}(2n) info = Ref{BlasInt}() for i = 1:2 ccall((@blasfunc($gelsy), liblapack), Void, @@ -1362,7 +1362,7 @@ for (gelsd, gelsy, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end subsetrows(B, newB, n), rnk[1] @@ -1421,7 +1421,7 @@ for (gglse, elty) in ((:dgglse_, :Float64), end X = zeros($elty, n) info = Ref{BlasInt}() - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) for i = 1:2 ccall((@blasfunc($gglse), liblapack), Void, @@ -1434,7 +1434,7 @@ for (gglse, elty) in ((:dgglse_, :Float64), chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end X, dot(sub(c, n - p + 1:m), sub(c, n - p + 1:m)) @@ -1482,7 +1482,7 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in WR = similar(A, $elty, n) WI = similar(A, $elty, n) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -1506,7 +1506,7 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end cmplx ? (W, VL, VR) : (WR, WI, VL, VR) @@ -1539,15 +1539,15 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in U = similar(A, $elty, (m, 0)) VT = similar(A, $elty, (n, 0)) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) S = similar(A, $relty, minmn) cmplx = eltype(A)<:Complex if cmplx - rwork = Array($relty, job == 'N' ? 7*minmn : + rwork = Array{$relty}(job == 'N' ? 7*minmn : minmn*max(5*minmn+7, 2*max(m,n)+2*minmn+1)) end - iwork = Array(BlasInt, 8*minmn) + iwork = Array{BlasInt}(8*minmn) info = Ref{BlasInt}() for i = 1:2 if cmplx @@ -1575,7 +1575,7 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in # and # https://github.com/scipy/scipy/issues/5401 lwork = round(BlasInt, nextfloat(real(work[1]))) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end if job == 'O' @@ -1610,10 +1610,10 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in S = similar(A, $relty, minmn) U = similar(A, $elty, jobu == 'A'? (m, m):(jobu == 'S'? (m, minmn) : (m, 0))) VT = similar(A, $elty, jobvt == 'A'? (n, n):(jobvt == 'S'? (minmn, n) : (n, 0))) - work = Array($elty, 1) + work = Array{$elty}(1) cmplx = eltype(A) <: Complex if cmplx - rwork = Array($relty, 5minmn) + rwork = Array{$relty}(5minmn) end lwork = BlasInt(-1) info = Ref{BlasInt}() @@ -1638,7 +1638,7 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end if jobu == 'O' @@ -1678,8 +1678,8 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in throw(DimensionMismatch("B has second dimension $(size(B,2)) but needs $n")) end p = size(B, 1) - k = Array(BlasInt, 1) - l = Array(BlasInt, 1) + k = Array{BlasInt}(1) + l = Array{BlasInt}(1) lda = max(1,stride(A, 2)) ldb = max(1,stride(B, 2)) alpha = similar(A, $relty, n) @@ -1690,12 +1690,12 @@ for (geev, gesvd, gesdd, ggsvd, elty, relty) in V = jobv == 'V' ? similar(A, $elty, ldv, p) : similar(A, $elty, 0) ldq = max(1, n) Q = jobq == 'Q' ? similar(A, $elty, ldq, n) : similar(A, $elty, 0) - work = Array($elty, max(3n, m, p) + n) + work = Array{$elty}(max(3n, m, p) + n) cmplx = eltype(A) <: Complex if cmplx - rwork = Array($relty, 2n) + rwork = Array{$relty}(2n) end - iwork = Array(BlasInt, n) + iwork = Array{BlasInt}(n) info = Ref{BlasInt}() if cmplx ccall((@blasfunc($ggsvd), liblapack), Void, @@ -1812,9 +1812,9 @@ for (f, elty) in ((:dggsvd3_, :Float64), V = jobv == 'V' ? similar(A, $elty, ldv, p) : similar(A, $elty, 0) ldq = max(1, n) Q = jobq == 'Q' ? similar(A, $elty, ldq, n) : similar(A, $elty, 0) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - iwork = Array(BlasInt, n) + iwork = Array{BlasInt}(n) info = Ref{BlasInt}() for i = 1:2 ccall((@blasfunc($f), liblapack), Void, @@ -1856,8 +1856,8 @@ for (f, elty, relty) in ((:zggsvd3_, :Complex128, :Float64), throw(DimensionMismatch("B has second dimension $(size(B,2)) but needs $n")) end p = size(B, 1) - k = Array(BlasInt, 1) - l = Array(BlasInt, 1) + k = Array{BlasInt}(1) + l = Array{BlasInt}(1) lda = max(1,stride(A, 2)) ldb = max(1,stride(B, 2)) alpha = similar(A, $relty, n) @@ -1868,10 +1868,10 @@ for (f, elty, relty) in ((:zggsvd3_, :Complex128, :Float64), V = jobv == 'V' ? similar(A, $elty, ldv, p) : similar(A, $elty, 0) ldq = max(1, n) Q = jobq == 'Q' ? similar(A, $elty, ldq, n) : similar(A, $elty, 0) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - rwork = Array($relty, 2n) - iwork = Array(BlasInt, n) + rwork = Array{$relty}(2n) + iwork = Array{BlasInt}(n) info = Ref{BlasInt}() for i = 1:2 ccall((@blasfunc($f), liblapack), Void, @@ -1892,7 +1892,7 @@ for (f, elty, relty) in ((:zggsvd3_, :Complex128, :Float64), chklapackerror(info[]) if i == 1 lwork = BlasInt(work[1]) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end if m - k[1] - l[1] >= 0 @@ -1963,13 +1963,13 @@ for (geevx, ggev, elty) in throw(ArgumentError("jobvr must be 'V' or 'N', but $jobvr was passed")) end VR = similar(A, $elty, ldvr, n) - ilo = Array(BlasInt, 1) - ihi = Array(BlasInt, 1) + ilo = Array{BlasInt}(1) + ihi = Array{BlasInt}(1) scale = similar(A, $elty, n) - abnrm = Array($elty, 1) + abnrm = Array{$elty}(1) rconde = similar(A, $elty, n) rcondv = similar(A, $elty, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) iworksize = 0 if sense == 'N' || sense == 'E' @@ -1979,7 +1979,7 @@ for (geevx, ggev, elty) in else throw(ArgumentError("sense must be 'N', 'E', 'V' or 'B', but $sense was passed")) end - iwork = Array(BlasInt, iworksize) + iwork = Array{BlasInt}(iworksize) info = Ref{BlasInt}() for i = 1:2 ccall((@blasfunc($geevx), liblapack), Void, @@ -1998,7 +1998,7 @@ for (geevx, ggev, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(work[1]) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, wr, wi, VL, VR, ilo[1], ihi[1], scale, abnrm[1], rconde, rcondv @@ -2043,7 +2043,7 @@ for (geevx, ggev, elty) in throw(ArgumentError("jobvr must be 'V' or 'N', but $jobvr was passed")) end vr = similar(A, $elty, ldvr, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -2061,7 +2061,7 @@ for (geevx, ggev, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(work[1]) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end alphar, alphai, beta, vl, vr @@ -2116,15 +2116,15 @@ for (geevx, ggev, elty, relty) in throw(ArgumentError("sense must be 'N', 'E', 'V' or 'B', but $sense was passed")) end VR = similar(A, $elty, ldvr, n) - ilo = Array(BlasInt, 1) - ihi = Array(BlasInt, 1) + ilo = Array{BlasInt}(1) + ihi = Array{BlasInt}(1) scale = similar(A, $relty, n) - abnrm = Array($relty, 1) + abnrm = Array{$relty}(1) rconde = similar(A, $relty, n) rcondv = similar(A, $relty, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - rwork = Array($relty, 2n) + rwork = Array{$relty}(2n) info = Ref{BlasInt}() for i = 1:2 ccall((@blasfunc($geevx), liblapack), Void, @@ -2143,7 +2143,7 @@ for (geevx, ggev, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(work[1]) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, w, VL, VR, ilo[1], ihi[1], scale, abnrm[1], rconde, rcondv @@ -2188,9 +2188,9 @@ for (geevx, ggev, elty, relty) in throw(ArgumentError("jobvr must be 'V' or 'N', but $jobvr was passed")) end vr = similar(A, $elty, ldvr, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - rwork = Array($relty, 8n) + rwork = Array{$relty}(8n) info = Ref{BlasInt}() for i = 1:2 ccall((@blasfunc($ggev), liblapack), Void, @@ -2207,7 +2207,7 @@ for (geevx, ggev, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(work[1]) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end alpha, beta, vl, vr @@ -2263,9 +2263,9 @@ for (laic1, elty) in if j != length(w) throw(DimensionMismatch("Vectors must have same length, but length of x is $j and length of w is $(length(w))")) end - sestpr = Array($elty, 1) - s = Array($elty, 1) - c = Array($elty, 1) + sestpr = Array{$elty}(1) + s = Array{$elty}(1) + c = Array{$elty}(1) ccall((@blasfunc($laic1), liblapack), Void, (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, @@ -2296,9 +2296,9 @@ for (laic1, elty, relty) in if j != length(w) throw(DimensionMismatch("Vectors must have same length, but length of x is $j and length of w is $(length(w))")) end - sestpr = Array($relty, 1) - s = Array($elty, 1) - c = Array($elty, 1) + sestpr = Array{$relty}(1) + s = Array{$elty}(1) + c = Array{$elty}(1) ccall((@blasfunc($laic1), liblapack), Void, (Ptr{BlasInt}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$relty}, Ptr{$elty}, Ptr{$elty}, Ptr{$relty}, Ptr{$elty}, @@ -2459,7 +2459,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in if k > m throw(DimensionMismatch("Invalid number of reflectors: k = $k should be <= m = $m")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -2470,7 +2470,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end if m < size(A,1) @@ -2492,7 +2492,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in if k > n throw(DimensionMismatch("Invalid number of reflectors: k = $k should be <= n = $n")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -2505,7 +2505,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end if n < size(A,2) @@ -2527,7 +2527,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in if k > n throw(DimensionMismatch("Invalid number of reflectors: k = $k should be <= n = $n")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -2540,7 +2540,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end if n < size(A,2) @@ -2562,7 +2562,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in if k > n throw(DimensionMismatch("Invalid number of reflectors: k = $k should be <= n = $n")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -2575,7 +2575,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end if n < size(A,2) @@ -2612,7 +2612,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in if side == 'R' && k > n throw(DimensionMismatch("Invalid number of reflectors: k = $k should be <= n = $n")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -2625,7 +2625,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end C @@ -2658,7 +2658,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in if side == 'R' && k > n throw(DimensionMismatch("Invalid number of reflectors: k = $k should be <= n = $n")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -2674,7 +2674,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end C @@ -2707,7 +2707,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in if side == 'R' && k > n throw(DimensionMismatch("Invalid number of reflectors: k = $k should be <= n = $n")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -2723,7 +2723,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end C @@ -2756,7 +2756,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in if side == 'R' && k > n throw(DimensionMismatch("Invalid number of reflectors: k = $k should be <= n = $n")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -2769,7 +2769,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end C @@ -2813,7 +2813,7 @@ for (orglq, orgqr, orgql, orgrq, ormlq, ormqr, ormql, ormrq, gemqrt, elty) in throw(DimensionMismatch("Wrong value for nb = $nb, which must be between 1 and $k")) end ldc = stride(C, 2) - work = Array($elty, wss) + work = Array{$elty}(wss) info = Ref{BlasInt}() ccall((@blasfunc($gemqrt), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, @@ -3027,8 +3027,8 @@ for (posv, potrf, potri, potrs, pstrf, elty, rtyp) in n = checksquare(A) chkuplo(uplo) piv = similar(A, BlasInt, n) - rank = Array(BlasInt, 1) - work = Array($rtyp, 2n) + rank = Array{BlasInt}(1) + work = Array{$rtyp}(2n) info = Ref{BlasInt}() ccall((@blasfunc($pstrf), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, Ptr{BlasInt}, @@ -3332,9 +3332,9 @@ for (trcon, trevc, trrfs, elty) in chkdiag(diag) n = checksquare(A) chkuplo(uplo) - rcond = Array($elty, 1) - work = Array($elty, 3n) - iwork = Array(BlasInt, n) + rcond = Array{$elty}(1) + work = Array{$elty}(3n) + iwork = Array{BlasInt}(n) info = Ref{BlasInt}() ccall((@blasfunc($trcon), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, @@ -3370,8 +3370,8 @@ for (trcon, trevc, trrfs, elty) in chkstride1(T, select) # Allocate - m = Array(BlasInt, 1) - work = Array($elty, 3n) + m = Array{BlasInt}(1) + work = Array{$elty}(3n) info = Ref{BlasInt}() ccall((@blasfunc($trevc), liblapack), Void, @@ -3426,8 +3426,8 @@ for (trcon, trevc, trrfs, elty) in if nrhs != size(X,2) throw(DimensionMismatch("Second dimensions of B, $nrhs, and X, $(size(X,2)), must match")) end - work = Array($elty, 3n) - iwork = Array(BlasInt, n) + work = Array{$elty}(3n) + iwork = Array{BlasInt}(n) info = Ref{BlasInt}() ccall((@blasfunc($trrfs), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, @@ -3460,9 +3460,9 @@ for (trcon, trevc, trrfs, elty, relty) in n = checksquare(A) chkuplo(uplo) chkdiag(diag) - rcond = Array($relty, 1) - work = Array($elty, 2n) - rwork = Array($relty, n) + rcond = Array{$relty}(1) + work = Array{$elty}(2n) + rwork = Array{$relty}(n) info = Ref{BlasInt}() ccall((@blasfunc($trcon), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, @@ -3499,9 +3499,9 @@ for (trcon, trevc, trrfs, elty, relty) in end # Allocate - m = Array(BlasInt, 1) - work = Array($elty, 2n) - rwork = Array($relty, n) + m = Array{BlasInt}(1) + work = Array{$elty}(2n) + rwork = Array{$relty}(n) info = Ref{BlasInt}() ccall((@blasfunc($trevc), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, @@ -3555,8 +3555,8 @@ for (trcon, trevc, trrfs, elty, relty) in if nrhs != size(X,2) throw(DimensionMismatch("Second dimensions of B, $nrhs, and X, $(size(X,2)), must match")) end - work = Array($elty, 2n) - rwork = Array($relty, n) + work = Array{$elty}(2n) + rwork = Array{$relty}(n) info = Ref{BlasInt}() ccall((@blasfunc($trrfs), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, @@ -3626,7 +3626,7 @@ for (stev, stebz, stegr, stein, elty) in throw(DimensionMismatch("ev has length $(length(ev)) but needs one less than dv's length, $n)")) end Zmat = similar(dv, $elty, (n, job != 'N' ? n : 0)) - work = Array($elty, max(1, 2n-2)) + work = Array{$elty}(max(1, 2n-2)) info = Ref{BlasInt}() ccall((@blasfunc($stev), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{$elty}, @@ -3646,14 +3646,14 @@ for (stev, stebz, stegr, stein, elty) in if length(ev) != n - 1 throw(DimensionMismatch("ev has length $(length(ev)) but needs one less than dv's length, $n)")) end - m = Array(BlasInt,1) - nsplit = Array(BlasInt,1) + m = Array{BlasInt}(1) + nsplit = Array{BlasInt}(1) w = similar(dv, $elty, n) tmp = 0.0 iblock = similar(dv, BlasInt,n) isplit = similar(dv, BlasInt,n) - work = Array($elty, 4*n) - iwork = Array(BlasInt,3*n) + work = Array{$elty}(4*n) + iwork = Array{BlasInt}(3*n) info = Ref{BlasInt}() ccall((@blasfunc($stebz), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, @@ -3677,15 +3677,15 @@ for (stev, stebz, stegr, stein, elty) in throw(DimensionMismatch("ev has length $(length(ev)) but needs one less than dv's length, $n)")) end eev = [ev; zero($elty)] - abstol = Array($elty, 1) - m = Array(BlasInt, 1) + abstol = Array{$elty}(1) + m = Array{BlasInt}(1) w = similar(dv, $elty, n) ldz = jobz == 'N' ? 1 : n Z = similar(dv, $elty, ldz, n) isuppz = similar(dv, BlasInt, 2n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - iwork = Array(BlasInt, 1) + iwork = Array{BlasInt}(1) liwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -3703,9 +3703,9 @@ for (stev, stebz, stegr, stein, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(work[1]) - work = Array($elty, lwork) + work = Array{$elty}(lwork) liwork = iwork[1] - iwork = Array(BlasInt, liwork) + iwork = Array{BlasInt}(liwork) end end w[1:m[1]], Z[:,1:m[1]] @@ -3742,9 +3742,9 @@ for (stev, stebz, stegr, stein, elty) in isplit[1:length(isplit_in)] = isplit_in end z = similar(dv, $elty,(n,m)) - work = Array($elty, 5*n) - iwork = Array(BlasInt,n) - ifail = Array(BlasInt,m) + work = Array{$elty}(5*n) + iwork = Array{BlasInt}(n) + ifail = Array{BlasInt}(m) info = Ref{BlasInt}() ccall((@blasfunc($stein), liblapack), Void, (Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt}, @@ -3832,7 +3832,7 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in chkstride1(A, ipiv) n = checksquare(A) chkuplo(uplo) - work = Array($elty, n) + work = Array{$elty}(n) info = Ref{BlasInt}() ccall((@blasfunc($syconv), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -3858,7 +3858,7 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in throw(DimensionMismatch("B has first dimension $(size(B,1)), but needs $n")) end ipiv = similar(A, BlasInt, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -3871,7 +3871,7 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in chknonsingular(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end B, A, ipiv @@ -3892,7 +3892,7 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in if n == 0 return A, ipiv end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -3903,7 +3903,7 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in chkargsok(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end return A, ipiv, info[] @@ -3920,7 +3920,7 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in # chkstride1(A) # n = checksquare(A) # chkuplo(uplo) -# work = Array($elty, 1) +# work = Array{$elty}(1) # lwork = BlasInt(-1) # info = Ref{BlasInt}() # for i in 1:2 @@ -3932,7 +3932,7 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in # chknonsingular(info[]) # if lwork < 0 # lwork = BlasInt(real(work[1])) -# work = Array($elty, lwork) +# work = Array{$elty}(lwork) # end # end # A @@ -3949,7 +3949,7 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in chkstride1(A, ipiv) n = checksquare(A) chkuplo(uplo) - work = Array($elty, n) + work = Array{$elty}(n) info = Ref{BlasInt}() ccall((@blasfunc($sytri), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -4008,7 +4008,7 @@ for (sysv, sytrf, sytri, sytrs, elty) in throw(DimensionMismatch("B has first dimension $(size(B,1)), but needs $n")) end ipiv = similar(A, BlasInt, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4021,7 +4021,7 @@ for (sysv, sytrf, sytri, sytrs, elty) in chknonsingular(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end B, A, ipiv @@ -4042,7 +4042,7 @@ for (sysv, sytrf, sytri, sytrs, elty) in if n == 0 return A, ipiv end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4053,7 +4053,7 @@ for (sysv, sytrf, sytri, sytrs, elty) in chkargsok(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end return A, ipiv, info[] @@ -4070,7 +4070,7 @@ for (sysv, sytrf, sytri, sytrs, elty) in chkstride1(A, ipiv) n = checksquare(A) chkuplo(uplo) - work = Array($elty, n) + work = Array{$elty}(n) info = Ref{BlasInt}() ccall((@blasfunc($sytri), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -4127,7 +4127,7 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in chkstride1(A,ipiv) n = checksquare(A) chkuplo(uplo) - work = Array($elty, n) + work = Array{$elty}(n) info = Ref{BlasInt}() ccall((@blasfunc($syconv), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -4153,7 +4153,7 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in throw(DimensionMismatch("B has first dimension $(size(B,1)), but needs $n")) end ipiv = similar(A, BlasInt, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4165,7 +4165,7 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end B, A, ipiv @@ -4184,7 +4184,7 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in n = checksquare(A) chkuplo(uplo) ipiv = similar(A, BlasInt, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i in 1:2 @@ -4195,7 +4195,7 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in chkargsok(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, ipiv, info[] @@ -4213,7 +4213,7 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in # chkstride1(A) # n = checksquare(A) # chkuplo(uplo) -# work = Array($elty, 1) +# work = Array{$elty}(1) # lwork = BlasInt(-1) # info = Ref{BlasInt}() # for i in 1:2 @@ -4224,7 +4224,7 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in # chklapackerror(info[]) # if lwork < 0 # lwork = BlasInt(real(work[1])) -# work = Array($elty, lwork) +# work = Array{$elty}(lwork) # end # end # A @@ -4243,7 +4243,7 @@ for (syconv, hesv, hetrf, hetri, hetrs, elty, relty) in chkstride1(A, ipiv) n = checksquare(A) chkuplo(uplo) - work = Array($elty, n) + work = Array{$elty}(n) info = Ref{BlasInt}() ccall((@blasfunc($hetri), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -4299,7 +4299,7 @@ for (hesv, hetrf, hetri, hetrs, elty, relty) in throw(DimensionMismatch("B has first dimension $(size(B,1)), but needs $n")) end ipiv = similar(A, BlasInt, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4311,7 +4311,7 @@ for (hesv, hetrf, hetri, hetrs, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end B, A, ipiv @@ -4330,7 +4330,7 @@ for (hesv, hetrf, hetri, hetrs, elty, relty) in n = checksquare(A) chkuplo(uplo) ipiv = similar(A, BlasInt, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i in 1:2 @@ -4341,7 +4341,7 @@ for (hesv, hetrf, hetri, hetrs, elty, relty) in chkargsok(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, ipiv, info[] @@ -4359,7 +4359,7 @@ for (hesv, hetrf, hetri, hetrs, elty, relty) in chkstride1(A,ipiv) n = checksquare(A) chkuplo(uplo) - work = Array($elty, n) + work = Array{$elty}(n) info = Ref{BlasInt}() ccall((@blasfunc($hetri), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -4416,7 +4416,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in throw(DimensionMismatch("B has first dimension $(size(B,1)), but needs $n")) end ipiv = similar(A, BlasInt, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4429,7 +4429,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in chknonsingular(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end B, A, ipiv @@ -4451,7 +4451,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in if n == 0 return A, ipiv end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4462,7 +4462,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in chkargsok(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, ipiv, info[] @@ -4480,7 +4480,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in # chkstride1(A) # n = checksquare(A) # chkuplo(uplo) -# work = Array($elty, 1) +# work = Array{$elty}(1) # lwork = BlasInt(-1) # info = Ref{BlasInt}() # for i in 1:2 @@ -4491,7 +4491,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in # chklapackerror(info[]) # if lwork < 0 # lwork = BlasInt(real(work[1])) -# work = Array($elty, lwork) +# work = Array{$elty}(lwork) # end # end # A @@ -4509,7 +4509,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in chkstride1(A, ipiv) n = checksquare(A) chkuplo(uplo) - work = Array($elty, n) + work = Array{$elty}(n) info = Ref{BlasInt}() ccall((@blasfunc($sytri), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -4567,7 +4567,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in throw(DimensionMismatch("B has first dimension $(size(B,1)), but needs $n")) end ipiv = similar(A, BlasInt, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4580,7 +4580,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in chknonsingular(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end B, A, ipiv @@ -4602,7 +4602,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in if n == 0 return A, ipiv end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4613,7 +4613,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in chkargsok(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, ipiv, info[] @@ -4631,7 +4631,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in chkstride1(A, ipiv) n = checksquare(A) chkuplo(uplo) - work = Array($elty, n) + work = Array{$elty}(n) info = Ref{BlasInt}() ccall((@blasfunc($sytri), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -4783,7 +4783,7 @@ for (syev, syevr, sygvd, elty) in chkstride1(A) n = checksquare(A) W = similar(A, $elty, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4794,7 +4794,7 @@ for (syev, syevr, sygvd, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end jobz == 'V' ? (W, A) : W @@ -4822,7 +4822,7 @@ for (syev, syevr, sygvd, elty) in throw(ArgumentError("Lower boundary, $vl, must be less than upper boundary, $vu")) end lda = stride(A,2) - m = Array(BlasInt, 1) + m = Array{BlasInt}(1) w = similar(A, $elty, n) ldz = n if jobz == 'N' @@ -4831,9 +4831,9 @@ for (syev, syevr, sygvd, elty) in Z = similar(A, $elty, ldz, n) end isuppz = similar(A, BlasInt, 2*n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - iwork = Array(BlasInt, 1) + iwork = Array{BlasInt}(1) liwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4853,9 +4853,9 @@ for (syev, syevr, sygvd, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) liwork = iwork[1] - iwork = Array(BlasInt, liwork) + iwork = Array{BlasInt}(liwork) end end w[1:m[1]], Z[:,1:(jobz == 'V' ? m[1] : 0)] @@ -4882,9 +4882,9 @@ for (syev, syevr, sygvd, elty) in lda = max(1, stride(A, 2)) ldb = max(1, stride(B, 2)) w = similar(A, $elty, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - iwork = Array(BlasInt, 1) + iwork = Array{BlasInt}(1) liwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -4900,9 +4900,9 @@ for (syev, syevr, sygvd, elty) in chkargsok(info[]) if i == 1 lwork = BlasInt(work[1]) - work = Array($elty, lwork) + work = Array{$elty}(lwork) liwork = iwork[1] - iwork = Array(BlasInt, liwork) + iwork = Array{BlasInt}(liwork) end end chkposdef(info[]) @@ -4927,9 +4927,9 @@ for (syev, syevr, sygvd, elty, relty) in chkstride1(A) n = checksquare(A) W = similar(A, $relty, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - rwork = Array($relty, max(1, 3n-2)) + rwork = Array{$relty}(max(1, 3n-2)) info = Ref{BlasInt}() for i = 1:2 ccall((@blasfunc($syev), liblapack), Void, @@ -4939,7 +4939,7 @@ for (syev, syevr, sygvd, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end jobz == 'V' ? (W, A) : W @@ -4969,7 +4969,7 @@ for (syev, syevr, sygvd, elty, relty) in throw(ArgumentError("Lower boundary, $vl, must be less than upper boundary, $vu")) end lda = max(1,stride(A,2)) - m = Array(BlasInt, 1) + m = Array{BlasInt}(1) w = similar(A, $relty, n) if jobz == 'N' ldz = 1 @@ -4979,11 +4979,11 @@ for (syev, syevr, sygvd, elty, relty) in Z = similar(A, $elty, ldz, n) end isuppz = similar(A, BlasInt, 2*n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - rwork = Array($relty, 1) + rwork = Array{$relty}(1) lrwork = BlasInt(-1) - iwork = Array(BlasInt, 1) + iwork = Array{BlasInt}(1) liwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -5003,11 +5003,11 @@ for (syev, syevr, sygvd, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) lrwork = BlasInt(rwork[1]) - rwork = Array($relty, lrwork) + rwork = Array{$relty}(lrwork) liwork = iwork[1] - iwork = Array(BlasInt, liwork) + iwork = Array{BlasInt}(liwork) end end w[1:m[1]], Z[:,1:(jobz == 'V' ? m[1] : 0)] @@ -5034,11 +5034,11 @@ for (syev, syevr, sygvd, elty, relty) in lda = max(1, stride(A, 2)) ldb = max(1, stride(B, 2)) w = similar(A, $relty, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - iwork = Array(BlasInt, 1) + iwork = Array{BlasInt}(1) liwork = BlasInt(-1) - rwork = Array($relty) + rwork = Array{$relty}() lrwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -5054,11 +5054,11 @@ for (syev, syevr, sygvd, elty, relty) in chkargsok(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) liwork = iwork[1] - iwork = Array(BlasInt, liwork) + iwork = Array{BlasInt}(liwork) lrwork = BlasInt(rwork[1]) - rwork = Array($relty, lrwork) + rwork = Array{$relty}(lrwork) end end chkposdef(info[]) @@ -5138,7 +5138,7 @@ for (bdsqr, relty, elty) in throw(DimensionMismatch("leading dimension of C, $ldc, must be at least $n")) end # Allocate - work = Array($relty, 4n) + work = Array{$relty}(4n) info = Ref{BlasInt}() ccall((@blasfunc($bdsqr), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, @@ -5207,8 +5207,8 @@ for (bdsdc, elty) in vt = similar(d, $elty, (ldvt, n)) q = similar(d, $elty, ldq) iq = similar(d, BlasInt, ldiq) - work = Array($elty, lwork) - iwork = Array(BlasInt, 8n) + work = Array{$elty}(lwork) + iwork = Array{BlasInt}(8n) info = Ref{BlasInt}() ccall((@blasfunc($bdsdc), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, @@ -5256,9 +5256,9 @@ for (gecon, elty) in chkstride1(A) n = checksquare(A) lda = max(1, stride(A, 2)) - rcond = Array($elty, 1) - work = Array($elty, 4n) - iwork = Array(BlasInt, n) + rcond = Array{$elty}(1) + work = Array{$elty}(4n) + iwork = Array{BlasInt}(n) info = Ref{BlasInt}() ccall((@blasfunc($gecon), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -5290,9 +5290,9 @@ for (gecon, elty, relty) in chkstride1(A) n = checksquare(A) lda = max(1, stride(A, 2)) - rcond = Array($relty, 1) - work = Array($elty, 2n) - rwork = Array($relty, 2n) + rcond = Array{$relty}(1) + work = Array{$elty}(2n) + rwork = Array{$relty}(2n) info = Ref{BlasInt}() ccall((@blasfunc($gecon), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty}, Ptr{BlasInt}, @@ -5333,7 +5333,7 @@ for (gehrd, elty) in n = checksquare(A) chkfinite(A) # balancing routines don't support NaNs and Infs tau = similar(A, $elty, max(0,n - 1)) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -5347,7 +5347,7 @@ for (gehrd, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, tau @@ -5383,7 +5383,7 @@ for (orghr, elty) in if n - length(tau) != 1 throw(DimensionMismatch("tau has length $(length(tau)), needs $(n - 1)")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -5397,7 +5397,7 @@ for (orghr, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A @@ -5439,7 +5439,7 @@ for (ormhr, elty) in throw(DimensionMismatch("A and C matrices are not conformable")) end - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -5455,7 +5455,7 @@ for (ormhr, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end C @@ -5478,12 +5478,12 @@ for (gees, gges, elty) in function gees!(jobvs::Char, A::StridedMatrix{$elty}) chkstride1(A) n = checksquare(A) - sdim = Array(BlasInt, 1) + sdim = Array{BlasInt}(1) wr = similar(A, $elty, n) wi = similar(A, $elty, n) ldvs = jobvs == 'V' ? n : 1 vs = similar(A, $elty, ldvs, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -5499,7 +5499,7 @@ for (gees, gges, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, vs, all(wi .== 0) ? wr : complex(wr, wi) @@ -5528,7 +5528,7 @@ for (gees, gges, elty) in vsl = similar(A, $elty, ldvsl, n) ldvsr = jobvsr == 'V' ? n : 1 vsr = similar(A, $elty, ldvsr, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() for i = 1:2 @@ -5548,7 +5548,7 @@ for (gees, gges, elty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, B, complex(alphar, alphai), beta, vsl[1:(jobvsl == 'V' ? n : 0),:], vsr[1:(jobvsr == 'V' ? n : 0),:] @@ -5576,9 +5576,9 @@ for (gees, gges, elty, relty) in w = similar(A, $elty, n) ldvs = jobvs == 'V' ? n : 1 vs = similar(A, $elty, ldvs, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - rwork = Array($relty, n) + rwork = Array{$relty}(n) info = Ref{BlasInt}() for i = 1:2 ccall((@blasfunc($gees), liblapack), Void, @@ -5593,7 +5593,7 @@ for (gees, gges, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, vs, w @@ -5622,9 +5622,9 @@ for (gees, gges, elty, relty) in vsl = similar(A, $elty, ldvsl, n) ldvsr = jobvsr == 'V' ? n : 1 vsr = similar(A, $elty, ldvsr, n) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - rwork = Array($relty, 8n) + rwork = Array{$relty}(8n) info = Ref{BlasInt}() for i = 1:2 ccall((@blasfunc($gges), liblapack), Void, @@ -5643,7 +5643,7 @@ for (gees, gges, elty, relty) in chklapackerror(info[]) if i == 1 lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end A, B, alpha, beta, vsl[1:(jobvsl == 'V' ? n : 0),:], vsr[1:(jobvsr == 'V' ? n : 0),:] @@ -5690,7 +5690,7 @@ for (trexc, trsen, tgsen, elty) in n = checksquare(T) ldt = max(1, stride(T, 2)) ldq = max(1, stride(Q, 2)) - work = Array($elty, n) + work = Array{$elty}(n) info = Ref{BlasInt}() ccall((@blasfunc($trexc), liblapack), Void, (Ptr{UInt8}, Ptr{BlasInt}, @@ -5725,9 +5725,9 @@ for (trexc, trsen, tgsen, elty) in wr = similar(T, $elty, n) wi = similar(T, $elty, n) m = sum(select) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) - iwork = Array(BlasInt, 1) + iwork = Array{BlasInt}(1) liwork = BlasInt(-1) info = Ref{BlasInt}() select = convert(Array{BlasInt}, select) @@ -5747,8 +5747,8 @@ for (trexc, trsen, tgsen, elty) in if i == 1 # only estimated optimal lwork, liwork lwork = BlasInt(real(work[1])) liwork = BlasInt(real(iwork[1])) - work = Array($elty, lwork) - iwork = Array(BlasInt, liwork) + work = Array{$elty}(lwork) + iwork = Array{BlasInt}(liwork) end end T, Q, all(wi .== 0) ? wr : complex(wr, wi) @@ -5791,9 +5791,9 @@ for (trexc, trsen, tgsen, elty) in alphar = similar(T, $elty, n) beta = similar(T, $elty, n) lwork = BlasInt(-1) - work = Array($elty, 1) + work = Array{$elty}(1) liwork = BlasInt(-1) - iwork = Array(BlasInt, 1) + iwork = Array{BlasInt}(1) info = Ref{BlasInt}() select = convert(Array{BlasInt}, select) for i = 1:2 @@ -5815,9 +5815,9 @@ for (trexc, trsen, tgsen, elty) in chklapackerror(info[]) if i == 1 # only estimated optimal lwork, liwork lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) liwork = BlasInt(real(iwork[1])) - iwork = Array(BlasInt, liwork) + iwork = Array{BlasInt}(liwork) end end S, T, complex(alphar, alphai), beta, Q, Z @@ -5872,7 +5872,7 @@ for (trexc, trsen, tgsen, elty) in ldq = max(1, stride(Q, 2)) w = similar(T, $elty, n) m = sum(select) - work = Array($elty, 1) + work = Array{$elty}(1) lwork = BlasInt(-1) info = Ref{BlasInt}() select = convert(Array{BlasInt}, select) @@ -5891,7 +5891,7 @@ for (trexc, trsen, tgsen, elty) in chklapackerror(info[]) if i == 1 # only estimated optimal lwork, liwork lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) end end T, Q, w @@ -5933,9 +5933,9 @@ for (trexc, trsen, tgsen, elty) in alpha = similar(T, $elty, n) beta = similar(T, $elty, n) lwork = BlasInt(-1) - work = Array($elty, 1) + work = Array{$elty}(1) liwork = BlasInt(-1) - iwork = Array(BlasInt, 1) + iwork = Array{BlasInt}(1) info = Ref{BlasInt}() select = convert(Array{BlasInt}, select) for i = 1:2 @@ -5957,9 +5957,9 @@ for (trexc, trsen, tgsen, elty) in chklapackerror(info[]) if i == 1 # only estimated optimal lwork, liwork lwork = BlasInt(real(work[1])) - work = Array($elty, lwork) + work = Array{$elty}(lwork) liwork = BlasInt(real(iwork[1])) - iwork = Array(BlasInt, liwork) + iwork = Array{BlasInt}(liwork) end end S, T, alpha, beta, Q, Z @@ -6016,7 +6016,7 @@ for (fn, elty, relty) in ((:dtrsyl_, :Float64, :Float64), throw(DimensionMismatch("Dimensions of A, ($m,$n), and C, ($m1,$n1), must match")) end ldc = max(1, stride(C, 2)) - scale = Array($relty, 1) + scale = Array{$relty}(1) info = Ref{BlasInt}() ccall((@blasfunc($fn), liblapack), Void, (Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}, diff --git a/base/linalg/lu.jl b/base/linalg/lu.jl index f63fab0601200..4113b106f425b 100644 --- a/base/linalg/lu.jl +++ b/base/linalg/lu.jl @@ -24,7 +24,7 @@ function generic_lufact!{T,Pivot}(A::StridedMatrix{T}, ::Type{Val{Pivot}} = Val{ m, n = size(A) minmn = min(m,n) info = 0 - ipiv = Array(BlasInt, minmn) + ipiv = Array{BlasInt}(minmn) @inbounds begin for k = 1:minmn # find index max @@ -241,7 +241,7 @@ cond(A::LU, p::Number) = norm(A[:L]*A[:U],p)*norm(inv(A),p) function lufact!{T}(A::Tridiagonal{T}, pivot::Union{Type{Val{false}}, Type{Val{true}}} = Val{true}) n = size(A, 1) info = 0 - ipiv = Array(BlasInt, n) + ipiv = Array{BlasInt}(n) dl = A.dl d = A.d du = A.du diff --git a/base/linalg/matmul.jl b/base/linalg/matmul.jl index 74fb7ca424dd2..04fb4cb36da8c 100644 --- a/base/linalg/matmul.jl +++ b/base/linalg/matmul.jl @@ -281,7 +281,7 @@ function herk_wrapper!{T<:BlasReal}(C::Union{StridedMatrix{T}, StridedMatrix{Com end # Result array does not need to be initialized as long as beta==0 - # C = Array(T, mA, mA) + # C = Array{T}(mA, mA) if stride(A, 1) == stride(C, 1) == 1 && stride(A, 2) >= size(A, 1) && stride(C, 2) >= size(C, 1) return copytri!(BLAS.herk!('U', tA, one(T), A, zero(T), C), 'U', true) @@ -428,9 +428,9 @@ function generic_matmatmul{T,S}(tA, tB, A::AbstractVecOrMat{T}, B::AbstractMatri end const tilebufsize = 10800 # Approximately 32k/3 -const Abuf = Array(UInt8, tilebufsize) -const Bbuf = Array(UInt8, tilebufsize) -const Cbuf = Array(UInt8, tilebufsize) +const Abuf = Array{UInt8}(tilebufsize) +const Bbuf = Array{UInt8}(tilebufsize) +const Cbuf = Array{UInt8}(tilebufsize) function generic_matmatmul!{T,S,R}(C::AbstractMatrix{R}, tA, tB, A::AbstractMatrix{T}, B::AbstractMatrix{S}) mA, nA = lapack_size(tA, A) diff --git a/base/linalg/qr.jl b/base/linalg/qr.jl index 1522f4a1b2561..3ccad5b12b66a 100644 --- a/base/linalg/qr.jl +++ b/base/linalg/qr.jl @@ -53,7 +53,7 @@ end function qrfactPivotedUnblocked!(A::StridedMatrix) m, n = size(A) piv = collect(UnitRange{BlasInt}(1,n)) - τ = Array(eltype(A), min(m,n)) + τ = Array{eltype(A)}(min(m,n)) for j = 1:min(m,n) # Find column with maximum norm in trailing submatrix diff --git a/base/linalg/triangular.jl b/base/linalg/triangular.jl index 5b187dedb3793..b7dd6639d7205 100644 --- a/base/linalg/triangular.jl +++ b/base/linalg/triangular.jl @@ -54,13 +54,13 @@ parent(A::AbstractTriangular) = A.data # then handle all methods that requires specific handling of upper/lower and unit diagonal function convert{Tret,T,S}(::Type{Matrix{Tret}}, A::LowerTriangular{T,S}) - B = Array(Tret, size(A, 1), size(A, 1)) + B = Array{Tret}(size(A, 1), size(A, 1)) copy!(B, A.data) tril!(B) B end function convert{Tret,T,S}(::Type{Matrix{Tret}}, A::UnitLowerTriangular{T,S}) - B = Array(Tret, size(A, 1), size(A, 1)) + B = Array{Tret}(size(A, 1), size(A, 1)) copy!(B, A.data) tril!(B) for i = 1:size(B,1) @@ -69,13 +69,13 @@ function convert{Tret,T,S}(::Type{Matrix{Tret}}, A::UnitLowerTriangular{T,S}) B end function convert{Tret,T,S}(::Type{Matrix{Tret}}, A::UpperTriangular{T,S}) - B = Array(Tret, size(A, 1), size(A, 1)) + B = Array{Tret}(size(A, 1), size(A, 1)) copy!(B, A.data) triu!(B) B end function convert{Tret,T,S}(::Type{Matrix{Tret}}, A::UnitUpperTriangular{T,S}) - B = Array(Tret, size(A, 1), size(A, 1)) + B = Array{Tret}(size(A, 1), size(A, 1)) copy!(B, A.data) triu!(B) for i = 1:size(B,1) @@ -1602,7 +1602,7 @@ function logm{T<:Union{Float64,Complex{Float64}}}(A0::UpperTriangular{T}) # Compute repeated roots d = diag(A) - dm1 = Array(T, n) + dm1 = Array{T}(n) s = 0 for i = 1:n dm1[i] = d[i] - 1. @@ -1728,7 +1728,7 @@ function logm{T<:Union{Float64,Complex{Float64}}}(A0::UpperTriangular{T}) R[i+1,i] = R[i,i+1] end x,V = eig(R) - w = Array(Float64, m) + w = Array{Float64}(m) for i = 1:m x[i] = (x[i] + 1) / 2 w[i] = V[1,i]^2 diff --git a/base/linalg/tridiag.jl b/base/linalg/tridiag.jl index b88250375fafb..3c5fa0d2ddecf 100644 --- a/base/linalg/tridiag.jl +++ b/base/linalg/tridiag.jl @@ -249,7 +249,7 @@ function inv_usmani{T}(a::Vector{T}, b::Vector{T}, c::Vector{T}) for i=n-1:-1:1 φ[i] = b[i]*φ[i+1]-a[i]*c[i]*φ[i+2] end - α = Array(T, n, n) + α = Array{T}(n, n) for i=1:n, j=1:n sign = (i+j)%2==0 ? (+) : (-) if i= 0 || throw(ArgumentError("requested size must be ≥ 0, got $len")) - len == 0 && return Array(T,ntuple(x->0,N)) + len == 0 && return Array{T}(ntuple(x->0,N)) len < typemax(Int) - PAGESIZE || throw(ArgumentError("requested size must be < $(typemax(Int)-PAGESIZE), got $len")) offset >= 0 || throw(ArgumentError("requested offset must be ≥ 0, got $offset")) diff --git a/base/mpfr.jl b/base/mpfr.jl index e00681e16e9a2..2c80b7568f0e6 100644 --- a/base/mpfr.jl +++ b/base/mpfr.jl @@ -621,7 +621,7 @@ for f in (:sin,:cos,:tan,:sec,:csc, end # log of absolute value of gamma function -const lgamma_signp = Array(Cint, 1) +const lgamma_signp = Array{Cint}(1) function lgamma(x::BigFloat) z = BigFloat() ccall((:mpfr_lgamma,:libmpfr), Cint, (Ptr{BigFloat}, Ptr{Cint}, Ptr{BigFloat}, Int32), &z, lgamma_signp, &x, ROUNDING_MODE[end]) @@ -852,13 +852,13 @@ function string(x::BigFloat) # is, excluding the most significant, ceil(log(10, 2^precision(x))) k = ceil(Int32, precision(x) * 0.3010299956639812) lng = k + Int32(8) # Add space for the sign, the most significand digit, the dot and the exponent - buf = Array(UInt8, lng + 1) + buf = Array{UInt8}(lng + 1) # format strings are guaranteed to contain no NUL, so we don't use Cstring lng = ccall((:mpfr_snprintf,:libmpfr), Int32, (Ptr{UInt8}, Culong, Ptr{UInt8}, Ptr{BigFloat}...), buf, lng + 1, "%.Re", &x) if lng < k + 5 # print at least k decimal places lng = ccall((:mpfr_sprintf,:libmpfr), Int32, (Ptr{UInt8}, Ptr{UInt8}, Ptr{BigFloat}...), buf, "%.$(k)Re", &x) elseif lng > k + 8 - buf = Array(UInt8, lng + 1) + buf = Array{UInt8}(lng + 1) lng = ccall((:mpfr_snprintf,:libmpfr), Int32, (Ptr{UInt8}, Culong, Ptr{UInt8}, Ptr{BigFloat}...), buf, lng + 1, "%.Re", &x) end return String(pointer(buf), (1 <= x < 10 || -10 < x <= -1 || x == 0) ? lng - 4 : lng) diff --git a/base/multi.jl b/base/multi.jl index a77c067c533ab..3cb3f5d8079bf 100644 --- a/base/multi.jl +++ b/base/multi.jl @@ -1564,7 +1564,7 @@ function splitrange(N::Int, np::Int) each = div(N,np) extras = rem(N,np) nchunks = each > 0 ? np : extras - chunks = Array(UnitRange{Int}, nchunks) + chunks = Array{UnitRange{Int}}(nchunks) lo = 1 for i in 1:nchunks hi = lo + each - 1 @@ -1770,4 +1770,3 @@ function getindex(r::RemoteChannel, args...) end return remotecall_fetch(getindex, r.where, r, args...) end - diff --git a/base/multidimensional.jl b/base/multidimensional.jl index e0678f18292f7..c2d831244d5ec 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -115,7 +115,7 @@ end @generated function eachindex(::LinearSlow, A::AbstractArray, B::AbstractArray...) K = max(ndims(A), map(ndims, B)...) startargs = fill(1, K) - stopargs = Array(Expr, K) + stopargs = Array{Expr}(K) for i = 1:K Bargs = [:(size(B[$j],$i)) for j = 1:length(B)] stopargs[i] = :(max(size(A,$i),$(Bargs...))) @@ -417,7 +417,7 @@ end @generated function findn{T,N}(A::AbstractArray{T,N}) quote nnzA = countnz(A) - @nexprs $N d->(I_d = Array(Int, nnzA)) + @nexprs $N d->(I_d = Array{Int}(nnzA)) k = 1 @nloops $N i A begin @inbounds if (@nref $N A i) != zero(T) @@ -703,7 +703,7 @@ end @generated function findn{N}(B::BitArray{N}) quote nnzB = countnz(B) - I = ntuple(x->Array(Int, nnzB), $N) + I = ntuple(x->Array{Int}(nnzB), $N) if nnzB > 0 count = 1 @nloops $N i B begin @@ -820,7 +820,7 @@ If `dim` is specified, returns unique regions of the array `itr` along `dim`. end # Collect index of first row for each hash - uniquerow = Array(Int, size(A, dim)) + uniquerow = Array{Int}(size(A, dim)) firstrow = Dict{Prehashed,Int}() for k = 1:size(A, dim) # fixme (iter): use `eachindex(A, dim)` after #15459 is implemented uniquerow[k] = get!(firstrow, Prehashed(hashes[k]), k) diff --git a/base/pcre.jl b/base/pcre.jl index 670f618f62bfc..f2ab25ae5c313 100644 --- a/base/pcre.jl +++ b/base/pcre.jl @@ -120,7 +120,7 @@ free_match_context(context) = ccall((:pcre2_match_context_free_8, PCRE_LIB), Void, (Ptr{Void},), context) function err_message(errno) - buffer = Array(UInt8, 256) + buffer = Array{UInt8}(256) ccall((:pcre2_get_error_message_8, PCRE_LIB), Void, (Int32, Ptr{UInt8}, Csize_t), errno, buffer, sizeof(buffer)) String(pointer(buffer)) diff --git a/base/pkg/query.jl b/base/pkg/query.jl index e529e3425bc4f..2ae2f33c06984 100644 --- a/base/pkg/query.jl +++ b/base/pkg/query.jl @@ -69,8 +69,8 @@ end typealias PackageState Union{Void,VersionNumber} function diff(have::Dict, want::Dict, avail::Dict, fixed::Dict) - change = Array(Tuple{String,Tuple{PackageState,PackageState}},0) - remove = Array(Tuple{String,Tuple{PackageState,PackageState}},0) + change = Array{Tuple{String,Tuple{PackageState,PackageState}}}(0) + remove = Array{Tuple{String,Tuple{PackageState,PackageState}}}(0) for pkg in collect(union(keys(have),keys(want))) h, w = haskey(have,pkg), haskey(want,pkg) diff --git a/base/pkg/resolve.jl b/base/pkg/resolve.jl index 4c681445d3d2f..84685330f06e7 100644 --- a/base/pkg/resolve.jl +++ b/base/pkg/resolve.jl @@ -65,7 +65,7 @@ function sanity_check(deps::Dict{String,Dict{VersionNumber,Available}}, end end - vers = Array(Tuple{String,VersionNumber,VersionNumber}, 0) + vers = Array{Tuple{String,VersionNumber,VersionNumber}}(0) for (p,d) in deps, vn in keys(d) lvns = VersionNumber[filter(vn2->(vn2>vn), keys(d))...] nvn = isempty(lvns) ? typemax(VersionNumber) : minimum(lvns) @@ -79,7 +79,7 @@ function sanity_check(deps::Dict{String,Dict{VersionNumber,Available}}, checked = falses(nv) - problematic = Array(Tuple{String,VersionNumber,String},0) + problematic = Array{Tuple{String,VersionNumber,String}}(0) i = 1 psl = 0 for (p,vn,nvn) in vers diff --git a/base/pkg/resolve/interface.jl b/base/pkg/resolve/interface.jl index e17698725c6c0..d7d038b66c748 100644 --- a/base/pkg/resolve/interface.jl +++ b/base/pkg/resolve/interface.jl @@ -52,7 +52,7 @@ type Interface pdict = (String=>Int)[ pkgs[i] => i for i = 1:np ] # generate spp and pvers - spp = Array(Int, np) + spp = Array{Int}(np) pvers = [ VersionNumber[] for i = 1:np ] @@ -82,11 +82,11 @@ type Interface end ## generate wveights: - vweight = Array(Vector{VersionWeight}, np) + vweight = Array{Vector{VersionWeight}}(np) for p0 = 1:np pvers0 = pvers[p0] spp0 = spp[p0] - vweight0 = vweight[p0] = Array(VersionWeight, spp0) + vweight0 = vweight[p0] = Array{VersionWeight}(spp0) for v0 = 1:spp0-1 vweight0[v0] = VersionWeight(pvers0[v0]) end @@ -241,7 +241,7 @@ function enforce_optimality!(sol::Vector{Int}, interface::Interface) # prepare some useful structures # pdeps[p0][v0] has all dependencies of package p0 version v0 - pdeps = [ Array(Requires, spp[p0]-1) for p0 = 1:np ] + pdeps = [ Array{Requires}(spp[p0]-1) for p0 = 1:np ] # prevdeps[p1][p0][v0] is the VersionSet of package p1 which package p0 version v0 # depends upon prevdeps = [ Dict{Int,Dict{Int,VersionSet}}() for p0 = 1:np ] diff --git a/base/pkg/resolve/maxsum.jl b/base/pkg/resolve/maxsum.jl index ac67a4fc4ee2d..298cb3296ffee 100644 --- a/base/pkg/resolve/maxsum.jl +++ b/base/pkg/resolve/maxsum.jl @@ -235,7 +235,7 @@ function getsolution(msgs::Messages) fld = msgs.fld np = length(fld) - sol = Array(Int, np) + sol = Array{Int}(np) for p0 = 1:np fld0 = fld[p0] s0 = indmax(fld0) diff --git a/base/pkg/resolve/versionweight.jl b/base/pkg/resolve/versionweight.jl index c7007331494d8..83500d949b858 100644 --- a/base/pkg/resolve/versionweight.jl +++ b/base/pkg/resolve/versionweight.jl @@ -27,7 +27,7 @@ for f in (:-, :+) l0 = min(la, lb) l1 = max(la, lb) ld = la - lb - rv = Array(T, l1) + rv = Array{T}(l1) rf = ($f)(a.rest, b.rest) @inbounds for i = 1:l0 rv[i] = ($f)(av[i], bv[i]) @@ -107,7 +107,7 @@ function VWPreBuild(ispre::Bool, desc::Tuple{Vararg{Union{Int,String}}}) isempty(desc) && return _vwprebuild_zero desc == ("",) && return VWPreBuild(ispre ? -1 : 1, HierarchicalValue(VWPreBuildItem[])) nonempty = ispre ? -1 : 0 - w = Array(VWPreBuildItem, length(desc)) + w = Array{VWPreBuildItem}(length(desc)) i = 1 @inbounds for item in desc w[i] = VWPreBuildItem(item) diff --git a/base/profile.jl b/base/profile.jl index 38f8e09297251..4ca919f45b9be 100644 --- a/base/profile.jl +++ b/base/profile.jl @@ -231,8 +231,8 @@ function count_flat{T<:Unsigned}(data::Vector{T}) end linecount[ip] = get(linecount, ip, 0)+1 end - iplist = Array(T, 0) - n = Array(Int, 0) + iplist = Array{T}(0) + n = Array{Int}(0) for (k,v) in linecount push!(iplist, k) push!(n, v) @@ -334,8 +334,8 @@ function tree_aggregate{T<:Unsigned}(data::Vector{T}) treecount[tmp] = get(treecount, tmp, 0)+1 istart = iend+1+btskip end - bt = Array(Vector{T}, 0) - counts = Array(Int, 0) + bt = Array{Vector{T}}(0) + counts = Array{Int}(0) for (k,v) in treecount if !isempty(k) push!(bt, k) @@ -354,7 +354,7 @@ function tree_format(lilist::Vector{StackFrame}, counts::Vector{Int}, level::Int ntext = cols-nindent-ndigcounts-ndigline-5 widthfile = floor(Integer,0.4ntext) widthfunc = floor(Integer,0.6ntext) - strs = Array(String, length(lilist)) + strs = Array{String}(length(lilist)) showextra = false if level > nindent nextra = level-nindent @@ -417,9 +417,9 @@ function tree{T<:Unsigned}(io::IO, bt::Vector{Vector{T}}, counts::Vector{Int}, l end # Generate counts dlen = length(d) - lilist = Array(StackFrame, dlen) - group = Array(Vector{Int}, dlen) - n = Array(Int, dlen) + lilist = Array{StackFrame}(dlen) + group = Array{Vector{Int}}(dlen) + n = Array{Int}(dlen) i = 1 for (key, v) in d lilist[i] = key @@ -441,9 +441,9 @@ function tree{T<:Unsigned}(io::IO, bt::Vector{Vector{T}}, counts::Vector{Int}, l end # Generate counts, and do the code lookup dlen = length(d) - lilist = Array(StackFrame, dlen) - group = Array(Vector{Int}, dlen) - n = Array(Int, dlen) + lilist = Array{StackFrame}(dlen) + group = Array{Vector{Int}}(dlen) + n = Array{Int}(dlen) i = 1 for (key, v) in d lilist[i] = lidict[key] @@ -536,7 +536,7 @@ truncto(str::Symbol, w::Int) = truncto(string(str), w) # Order alphabetically (file, function) and then by line number function liperm(lilist::Vector{StackFrame}) - comb = Array(String, length(lilist)) + comb = Array{String}(length(lilist)) for i = 1:length(lilist) li = lilist[i] if li != UNKNOWN diff --git a/base/quadgk.jl b/base/quadgk.jl index 02313fd9d2f34..dbd99d518493c 100644 --- a/base/quadgk.jl +++ b/base/quadgk.jl @@ -220,7 +220,7 @@ function eignewt(b,m,n) H = SymTridiagonal(zeros(m), Float64[ b[i] for i in 1:m-1 ]) lambda0 = sort(eigvals(H)) - lambda = Array(eltype(b), n) + lambda = Array{eltype(b)}(n) for i = 1:n lambda[i] = lambda0[i] for k = 1:1000 @@ -243,7 +243,7 @@ function eigvec1(b,z::Number,m=length(b)+1) # "cheat" and use the fact that our eigenvector v must have a # nonzero first entries (since it is a quadrature weight), so we # can set v[1] = 1 to solve for the rest of the components:. - v = Array(eltype(b), m) + v = Array{eltype(b)}(m) v[1] = 1 if m > 1 s = v[1] diff --git a/base/random.jl b/base/random.jl index 68db68f462868..659015a306f39 100644 --- a/base/random.jl +++ b/base/random.jl @@ -31,7 +31,7 @@ if is_windows() immutable RandomDevice <: AbstractRNG buffer::Vector{UInt128} - RandomDevice() = new(Array(UInt128, 1)) + RandomDevice() = new(Array{UInt128}(1)) end function rand{T<:Union{Bool, Base.BitInteger}}(rd::RandomDevice, ::Type{T}) @@ -67,8 +67,8 @@ type MersenneTwister <: AbstractRNG idx::Int seed::Vector{UInt32} - MersenneTwister(state::DSFMT_state, seed) = new(state, Array(Float64, MTCacheLength), MTCacheLength, seed) - MersenneTwister(seed) = srand(new(DSFMT_state(), Array(Float64, MTCacheLength)), seed) + MersenneTwister(state::DSFMT_state, seed) = new(state, Array{Float64}(MTCacheLength), MTCacheLength, seed) + MersenneTwister(seed) = srand(new(DSFMT_state(), Array{Float64}(MTCacheLength)), seed) MersenneTwister() = MersenneTwister(0) end @@ -163,7 +163,7 @@ function make_seed(n::Integer) end function make_seed(filename::AbstractString, n::Integer) - read!(filename, Array(UInt32, Int(n))) + read!(filename, Array{UInt32}(Int(n))) end ## srand() @@ -274,7 +274,7 @@ end rand(r::AbstractRNG, dims::Dims) = rand(r, Float64, dims) rand(r::AbstractRNG, dims::Integer...) = rand(r, convert(Tuple{Vararg{Int}}, dims)) -rand(r::AbstractRNG, T::Type, dims::Dims) = rand!(r, Array(T, dims)) +rand(r::AbstractRNG, T::Type, dims::Dims) = rand!(r, Array{T}(dims)) rand(r::AbstractRNG, T::Type, d1::Integer, dims::Integer...) = rand(r, T, tuple(Int(d1), convert(Tuple{Vararg{Int}}, dims)...)) # note: the above method would trigger an ambiguity warning if d1 was not separated out: # rand(r, ()) would match both this method and rand(r, dims::Dims) @@ -483,7 +483,7 @@ else limbs::Vector{Limb} # buffer to be copied into generated BigInt's mask::Limb # applied to the highest limb - RangeGeneratorBigInt(a, m, nlimbs, mask) = new(a, m, Array(Limb, nlimbs), mask) + RangeGeneratorBigInt(a, m, nlimbs, mask) = new(a, m, Array{Limb}(nlimbs), mask) end end @@ -581,7 +581,7 @@ function rand!(rng::AbstractRNG, A::AbstractArray, r::AbstractArray) return A end -rand{T}(rng::AbstractRNG, r::AbstractArray{T}, dims::Dims) = rand!(rng, Array(T, dims), r) +rand{T}(rng::AbstractRNG, r::AbstractArray{T}, dims::Dims) = rand!(rng, Array{T}(dims), r) rand(rng::AbstractRNG, r::AbstractArray, dims::Int...) = rand(rng, r, dims) ## random BitArrays (AbstractRNG) @@ -1129,10 +1129,10 @@ function randn!(rng::AbstractRNG, A::AbstractArray{Float64}) end randn!(A::AbstractArray{Float64}) = randn!(GLOBAL_RNG, A) -randn(dims::Dims) = randn!(Array(Float64, dims)) -randn(dims::Integer...) = randn!(Array(Float64, dims...)) -randn(rng::AbstractRNG, dims::Dims) = randn!(rng, Array(Float64, dims)) -randn(rng::AbstractRNG, dims::Integer...) = randn!(rng, Array(Float64, dims...)) +randn(dims::Dims) = randn!(Array{Float64}(dims)) +randn(dims::Integer...) = randn!(Array{Float64}(dims...)) +randn(rng::AbstractRNG, dims::Dims) = randn!(rng, Array{Float64}(dims)) +randn(rng::AbstractRNG, dims::Integer...) = randn!(rng, Array{Float64}(dims...)) @inline function randexp(rng::AbstractRNG=GLOBAL_RNG) @inbounds begin @@ -1162,10 +1162,10 @@ function randexp!(rng::AbstractRNG, A::Array{Float64}) end randexp!(A::Array{Float64}) = randexp!(GLOBAL_RNG, A) -randexp(dims::Dims) = randexp!(Array(Float64, dims)) -randexp(dims::Int...) = randexp!(Array(Float64, dims)) -randexp(rng::AbstractRNG, dims::Dims) = randexp!(rng, Array(Float64, dims)) -randexp(rng::AbstractRNG, dims::Int...) = randexp!(rng, Array(Float64, dims)) +randexp(dims::Dims) = randexp!(Array{Float64}(dims)) +randexp(dims::Int...) = randexp!(Array{Float64}(dims)) +randexp(rng::AbstractRNG, dims::Dims) = randexp!(rng, Array{Float64}(dims)) +randexp(rng::AbstractRNG, dims::Int...) = randexp!(rng, Array{Float64}(dims)) ## random UUID generation @@ -1248,7 +1248,7 @@ end function Base.repr(u::UUID) u = u.value - a = Array(UInt8,36) + a = Array{UInt8}(36) for i = [36:-1:25; 23:-1:20; 18:-1:15; 13:-1:10; 8:-1:1] d = u & 0xf a[i] = '0'+d+39*(d>9) @@ -1342,7 +1342,7 @@ shuffle(r::AbstractRNG, a::AbstractVector) = shuffle!(r, copy(a)) shuffle(a::AbstractVector) = shuffle(GLOBAL_RNG, a) function randperm(r::AbstractRNG, n::Integer) - a = Array(typeof(n), n) + a = Array{typeof(n)}(n) @assert n <= Int64(2)^52 if n == 0 return a @@ -1362,7 +1362,7 @@ end randperm(n::Integer) = randperm(GLOBAL_RNG, n) function randcycle(r::AbstractRNG, n::Integer) - a = Array(typeof(n), n) + a = Array{typeof(n)}(n) n == 0 && return a @assert n <= Int64(2)^52 a[1] = 1 diff --git a/base/range.jl b/base/range.jl index 1940451f61b62..80c0c073ec84b 100644 --- a/base/range.jl +++ b/base/range.jl @@ -761,7 +761,7 @@ function vcat{T}(rs::Range{T}...) for ra in rs n += length(ra) end - a = Array(T,n) + a = Array{T}(n) i = 1 for ra in rs, x in ra @inbounds a[i] = x diff --git a/base/refpointer.jl b/base/refpointer.jl index ca87c63cf05f0..4a65c67ddcf83 100644 --- a/base/refpointer.jl +++ b/base/refpointer.jl @@ -70,8 +70,8 @@ function (::Type{Ref{P}}){P<:Ptr,T}(a::Array{T}) # Ref{P<:Ptr}(a::Array) # this Array already has the right memory layout for the requested Ref return RefArray(a,1,false) # root something, so that this function is type-stable else - ptrs = Array(P, length(a)+1) - roots = Array(Any, length(a)) + ptrs = Array{P}(length(a)+1) + roots = Array{Any}(length(a)) for i = 1:length(a) root = cconvert(P, a[i]) ptrs[i] = unsafe_convert(P, root)::P diff --git a/base/serialize.jl b/base/serialize.jl index f2f971800aa07..4e9bdb3c7e663 100644 --- a/base/serialize.jl +++ b/base/serialize.jl @@ -213,7 +213,7 @@ function serialize{T,N,A<:Array}(s::SerializationState, a::SubArray{T,N,A}) end function trimmedsubarray{T,N,A<:Array}(V::SubArray{T,N,A}) - dest = Array(eltype(V), trimmedsize(V)) + dest = Array{eltype(V)}(trimmedsize(V)) copy!(dest, V) _trimmedsubarray(dest, V, (), V.indexes...) end @@ -667,7 +667,7 @@ function deserialize_array(s::SerializationState) end if isa(d1,Integer) if elty !== Bool && isbits(elty) - return read!(s.io, Array(elty, d1)) + return read!(s.io, Array{elty}(d1)) end dims = (Int(d1),) else @@ -676,7 +676,7 @@ function deserialize_array(s::SerializationState) if isbits(elty) n = prod(dims)::Int if elty === Bool && n>0 - A = Array(Bool, dims) + A = Array{Bool}(dims) i = 1 while i <= n b = read(s.io, UInt8)::UInt8 @@ -692,7 +692,7 @@ function deserialize_array(s::SerializationState) end return A end - A = Array(elty, dims) + A = Array{elty}(dims) deserialize_cycle(s, A) for i = eachindex(A) tag = Int32(read(s.io, UInt8)::UInt8) diff --git a/base/sharedarray.jl b/base/sharedarray.jl index abaa6c8b308a2..f887910b6e91a 100644 --- a/base/sharedarray.jl +++ b/base/sharedarray.jl @@ -77,7 +77,7 @@ function SharedArray(T::Type, dims::NTuple; init=false, pids=Int[]) func_mapshmem = () -> shm_mmap_array(T, dims, shm_seg_name, JL_O_RDWR) - refs = Array(Future, length(pids)) + refs = Array{Future}(length(pids)) for (i, p) in enumerate(pids) refs[i] = remotecall(func_mapshmem, p) end @@ -159,7 +159,7 @@ function SharedArray{T,N}(filename::AbstractString, ::Type{T}, dims::NTuple{N,In mode == "r" && !isfile(filename) && throw(ArgumentError("file $filename does not exist, but mode $mode cannot create it")) # Create the file if it doesn't exist, map it if it does - refs = Array(Future, length(pids)) + refs = Array{Future}(length(pids)) func_mmap = mode -> open(filename, mode) do io Mmap.mmap(io, Array{T,N}, dims, offset; shared=true) end @@ -224,7 +224,7 @@ function finalize_refs{T,N}(S::SharedArray{T,N}) empty!(S.refs) init_loc_flds(S) finalize(S.s) - S.s = Array(T, ntuple(d->0,N)) + S.s = Array{T}(ntuple(d->0,N)) end S end @@ -238,7 +238,7 @@ linearindexing{S<:SharedArray}(::Type{S}) = LinearFast() function reshape{T,N}(a::SharedArray{T}, dims::NTuple{N,Int}) (length(a) != prod(dims)) && throw(DimensionMismatch("dimensions must be consistent with array size")) - refs = Array(Future, length(a.pids)) + refs = Array{Future}(length(a.pids)) for (i, p) in enumerate(a.pids) refs[i] = remotecall(p, a.refs[i], dims) do r,d reshape(fetch(r),d) @@ -339,7 +339,7 @@ function init_loc_flds{T,N}(S::SharedArray{T,N}) S.loc_subarr_1d = sub_1dim(S, S.pidx) else S.pidx = 0 - S.loc_subarr_1d = sub(Array(T, ntuple(d->0,N)), 1:0) + S.loc_subarr_1d = sub(Array{T}(ntuple(d->0,N)), 1:0) end end @@ -506,7 +506,7 @@ function shm_mmap_array(T, dims, shm_seg_name, mode) local A = nothing if prod(dims) == 0 - return Array(T, dims) + return Array{T}(dims) end try diff --git a/base/show.jl b/base/show.jl index 01a7ca1f2ce76..520b81362bda7 100644 --- a/base/show.jl +++ b/base/show.jl @@ -1049,7 +1049,7 @@ function dump_elts(io::IO, x::Array, n::Int, indent, i0, i1) end function dump(io::IO, x::Array, n::Int, indent) - print(io, "Array($(eltype(x)),$(size(x)))") + print(io, "Array{$(eltype(x))}($(size(x)))") if eltype(x) <: Number print(io, " ") show(io, x) diff --git a/base/socket.jl b/base/socket.jl index a1bb1d70841e2..e4f2a7e251586 100644 --- a/base/socket.jl +++ b/base/socket.jl @@ -572,7 +572,7 @@ function uv_getaddrinfocb(req::Ptr{Void}, status::Cint, addrinfo::Ptr{Void}) cb(IPv4(ntoh(ccall(:jl_sockaddr_host4,UInt32,(Ptr{Void},),sockaddr)))) break #elseif ccall(:jl_sockaddr_is_ip6,Int32,(Ptr{Void},),sockaddr) == 1 - # host = Array(UInt128,1) + # host = Array{UInt128}(1) # scope_id = ccall(:jl_sockaddr_host6,UInt32,(Ptr{Void},Ptr{UInt128}),sockaddr,host) # cb(IPv6(ntoh(host[1]))) # break @@ -625,7 +625,7 @@ getaddrinfo(host::AbstractString) = getaddrinfo(String(host)) const _sizeof_uv_interface_address = ccall(:jl_uv_sizeof_interface_address,Int32,()) function getipaddr() - addr = Array(Ptr{UInt8},1) + addr = Array{Ptr{UInt8}}(1) addr[1] = C_NULL count = zeros(Int32,1) lo_present = false @@ -648,7 +648,7 @@ function getipaddr() return rv # Uncomment to enbable IPv6 #elseif ccall(:jl_sockaddr_in_is_ip6,Int32,(Ptr{Void},),sockaddr) == 1 - # host = Array(UInt128,1) + # host = Array{UInt128}(1) # ccall(:jl_sockaddr_host6,UInt32,(Ptr{Void},Ptr{UInt128}),sockaddrr,host) # return IPv6(ntoh(host[1])) end diff --git a/base/special/bessel.jl b/base/special/bessel.jl index 8bfddc08c6c17..3728244dd3f1b 100644 --- a/base/special/bessel.jl +++ b/base/special/bessel.jl @@ -7,8 +7,8 @@ end ## Airy functions let - const ai::Array{Float64,1} = Array(Float64,2) - const ae::Array{Int32,1} = Array(Int32,2) + const ai::Array{Float64,1} = Array{Float64}(2) + const ae::Array{Int32,1} = Array{Int32}(2) global _airy, _biry function _airy(z::Complex128, id::Int32, kode::Int32) ccall((:zairy_,openspecfun), Void, @@ -114,9 +114,9 @@ for jy in ("j","y"), nu in (0,1) end -const cy = Array(Float64,2) -const ae = Array(Int32,2) -const wrk = Array(Float64,2) +const cy = Array{Float64}(2) +const ae = Array{Int32}(2) +const wrk = Array{Float64}(2) function _besselh(nu::Float64, k::Int32, z::Complex128, kode::Int32) ccall((:zbesh_,openspecfun), Void, diff --git a/base/special/gamma.jl b/base/special/gamma.jl index 6cdf38412c569..e1bbe630f1e33 100644 --- a/base/special/gamma.jl +++ b/base/special/gamma.jl @@ -6,12 +6,12 @@ gamma(x::Real) = gamma(float(x)) @vectorize_1arg Number gamma function lgamma_r(x::Float64) - signp = Array(Int32, 1) + signp = Array{Int32}(1) y = ccall((:lgamma_r,libm), Float64, (Float64, Ptr{Int32}), x, signp) return y, signp[1] end function lgamma_r(x::Float32) - signp = Array(Int32, 1) + signp = Array{Int32}(1) y = ccall((:lgammaf_r,libm), Float32, (Float32, Ptr{Int32}), x, signp) return y, signp[1] end @@ -141,13 +141,13 @@ function cotderiv_q(m::Int) q₋ = cotderiv_q(m-1) d = length(q₋) - 1 # degree of q₋ if isodd(m-1) - q = Array(Float64, length(q₋)) + q = Array{Float64}(length(q₋)) q[end] = d * q₋[end] * 2/m for i = 1:length(q)-1 q[i] = ((i-1)*q₋[i] + i*q₋[i+1]) * 2/m end else # iseven(m-1) - q = Array(Float64, length(q₋) + 1) + q = Array{Float64}(length(q₋) + 1) q[1] = q₋[1] / m q[end] = (1 + 2d) * q₋[end] / m for i = 2:length(q)-1 diff --git a/base/stacktraces.jl b/base/stacktraces.jl index d0db61111ecb4..341cd4f0f8d20 100644 --- a/base/stacktraces.jl +++ b/base/stacktraces.jl @@ -94,7 +94,7 @@ inlined at that point, innermost function first. function lookup(pointer::Ptr{Void}) infos = ccall(:jl_lookup_code_address, Any, (Ptr{Void}, Cint), pointer - 1, false) isempty(infos) && return [StackFrame(empty_sym, empty_sym, -1, Nullable{LambdaInfo}(), true, false, convert(Int64, pointer))] - res = Array(StackFrame, length(infos)) + res = Array{StackFrame}(length(infos)) for i in 1:length(infos) info = infos[i] @assert(length(info) == 7) diff --git a/base/stat.jl b/base/stat.jl index ee2a286c25737..9b1b5391edf99 100644 --- a/base/stat.jl +++ b/base/stat.jl @@ -61,7 +61,7 @@ show(io::IO, st::StatStruct) = print(io, "StatStruct(mode=$(oct(filemode(st),6)) # stat & lstat functions -const stat_buf = Array(UInt8, ccall(:jl_sizeof_stat, Int32, ())) +const stat_buf = Array{UInt8}(ccall(:jl_sizeof_stat, Int32, ())) macro stat_call(sym, arg1type, arg) quote fill!(stat_buf,0) diff --git a/base/statistics.jl b/base/statistics.jl index 2556abb448bdd..593b3badbcf20 100644 --- a/base/statistics.jl +++ b/base/statistics.jl @@ -707,7 +707,7 @@ function hist!{HT}(h::AbstractArray{HT}, v::AbstractVector, edg::AbstractVector; edg, h end -hist(v::AbstractVector, edg::AbstractVector) = hist!(Array(Int, length(edg)-1), v, edg) +hist(v::AbstractVector, edg::AbstractVector) = hist!(Array{Int}(length(edg)-1), v, edg) hist(v::AbstractVector, n::Integer) = hist(v,histrange(v,n)) hist(v::AbstractVector) = hist(v,sturges(length(v))) @@ -725,7 +725,7 @@ function hist!{HT}(H::AbstractArray{HT,2}, A::AbstractMatrix, edg::AbstractVecto edg, H end -hist(A::AbstractMatrix, edg::AbstractVector) = hist!(Array(Int, length(edg)-1, size(A,2)), A, edg) +hist(A::AbstractMatrix, edg::AbstractVector) = hist!(Array{Int}(length(edg)-1, size(A,2)), A, edg) hist(A::AbstractMatrix, n::Integer) = hist(A,histrange(A,n)) hist(A::AbstractMatrix) = hist(A,sturges(size(A,1))) @@ -751,7 +751,7 @@ function hist2d!{HT}(H::AbstractArray{HT,2}, v::AbstractMatrix, end hist2d(v::AbstractMatrix, edg1::AbstractVector, edg2::AbstractVector) = - hist2d!(Array(Int, length(edg1)-1, length(edg2)-1), v, edg1, edg2) + hist2d!(Array{Int}(length(edg1)-1, length(edg2)-1), v, edg1, edg2) hist2d(v::AbstractMatrix, edg::AbstractVector) = hist2d(v, edg, edg) diff --git a/base/strings/basic.jl b/base/strings/basic.jl index 762a9f62d62d7..2231b56bb90ad 100644 --- a/base/strings/basic.jl +++ b/base/strings/basic.jl @@ -263,7 +263,7 @@ end ## string map, filter, has ## function map(f, s::AbstractString) - out = IOBuffer(Array(UInt8,endof(s)),true,true) + out = IOBuffer(Array{UInt8}(endof(s)),true,true) truncate(out,0) for c in s c2 = f(c) @@ -276,7 +276,7 @@ function map(f, s::AbstractString) end function filter(f, s::AbstractString) - out = IOBuffer(Array(UInt8,endof(s)),true,true) + out = IOBuffer(Array{UInt8}(endof(s)),true,true) truncate(out,0) for c in s if f(c) diff --git a/base/strings/io.jl b/base/strings/io.jl index f6622340c8c03..8b13e360ff47e 100644 --- a/base/strings/io.jl +++ b/base/strings/io.jl @@ -30,7 +30,7 @@ println(xs...) = println(STDOUT, xs...) ## conversion of general objects to strings ## function sprint(size::Integer, f::Function, args...; env=nothing) - s = IOBuffer(Array(UInt8,size), true, true) + s = IOBuffer(Array{UInt8}(size), true, true) truncate(s,0) if env !== nothing f(IOContext(s, env), args...) @@ -48,7 +48,7 @@ tostr_sizehint(x::Float32) = 12 function print_to_string(xs...; env=nothing) # specialized for performance reasons - s = IOBuffer(Array(UInt8,tostr_sizehint(xs[1])), true, true) + s = IOBuffer(Array{UInt8}(tostr_sizehint(xs[1])), true, true) # specialized version of truncate(s,0) s.size = 0 s.ptr = 1 @@ -270,7 +270,7 @@ function unindent(str::AbstractString, indent::Int; tabwidth=8) pos = start(str) endpos = endof(str) # Note: this loses the type of the original string - buf = IOBuffer(Array(UInt8,endpos), true, true) + buf = IOBuffer(Array{UInt8}(endpos), true, true) truncate(buf,0) cutting = true col = 0 # current column (0 based) diff --git a/base/strings/types.jl b/base/strings/types.jl index 0ef383f104bd8..f8184201a4b83 100644 --- a/base/strings/types.jl +++ b/base/strings/types.jl @@ -169,7 +169,7 @@ convert(::Type{RepString}, s::AbstractString) = RepString(s,1) function repeat(s::String, r::Integer) r < 0 && throw(ArgumentError("can't repeat a string $r times")) d = s.data; n = length(d) - out = Array(UInt8, n*r) + out = Array{UInt8}(n*r) for i=1:r copy!(out, 1+(i-1)*n, d, 1, n) end diff --git a/base/subarray.jl b/base/subarray.jl index 2505f5eabeffb..cd41df6ff50ec 100644 --- a/base/subarray.jl +++ b/base/subarray.jl @@ -339,7 +339,7 @@ end # deprecate? function parentdims(s::SubArray) nd = ndims(s) - dimindex = Array(Int, nd) + dimindex = Array{Int}(nd) sp = strides(s.parent) sv = strides(s) j = 1 diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 4683dd7157992..2c4b26204fbb4 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -128,10 +128,10 @@ function cpu_summary(io::IO=STDOUT, cpu::Array{CPUinfo}=cpu_info()) end function cpu_info() - UVcpus = Array(Ptr{UV_cpu_info_t},1) - count = Array(Int32,1) + UVcpus = Array{Ptr{UV_cpu_info_t}}(1) + count = Array{Int32}(1) Base.uv_error("uv_cpu_info",ccall(:uv_cpu_info, Int32, (Ptr{Ptr{UV_cpu_info_t}}, Ptr{Int32}), UVcpus, count)) - cpus = Array(CPUinfo,count[1]) + cpus = Array{CPUinfo}(count[1]) for i = 1:length(cpus) cpus[i] = CPUinfo(unsafe_load(UVcpus[1],i)) end @@ -140,13 +140,13 @@ function cpu_info() end function uptime() - uptime_ = Array(Float64,1) + uptime_ = Array{Float64}(1) Base.uv_error("uv_uptime",ccall(:uv_uptime, Int32, (Ptr{Float64},), uptime_)) return uptime_[1] end function loadavg() - loadavg_ = Array(Float64,3) + loadavg_ = Array{Float64}(3) ccall(:uv_loadavg, Void, (Ptr{Float64},), loadavg_) return loadavg_ end diff --git a/base/threadcall.jl b/base/threadcall.jl index 899492d957cc3..c9da92c5a49ea 100644 --- a/base/threadcall.jl +++ b/base/threadcall.jl @@ -76,7 +76,7 @@ function do_threadcall(wrapper::Function, rettype::Type, argtypes::Vector, argva end # create return buffer - ret_arr = Array(UInt8, sizeof(rettype)) + ret_arr = Array{UInt8}(sizeof(rettype)) # wait for a worker thread to be available acquire(threadcall_restrictor) diff --git a/base/tuple.jl b/base/tuple.jl index 65240d64af48e..a3ee59d1dca6e 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -90,7 +90,7 @@ map(f, t::Tuple) = (f(t[1]), map(f,tail(t))...) function map(f, t::Tuple{Any,Any,Any,Any,Any,Any,Any,Any, Any,Any,Any,Any,Any,Any,Any,Any,Vararg{Any}}) n = length(t) - A = Array(Any,n) + A = Array{Any}(n) for i=1:n A[i] = f(t[i]) end diff --git a/base/unicode/utf16.jl b/base/unicode/utf16.jl index b819c2cfb106c..51890275bc051 100644 --- a/base/unicode/utf16.jl +++ b/base/unicode/utf16.jl @@ -221,15 +221,15 @@ function convert(T::Type{UTF16String}, bytes::AbstractArray{UInt8}) data = reinterpret(UInt16, bytes) # check for byte-order mark (BOM): if data[1] == 0xfeff # native byte order - d = Array(UInt16, length(data)) + d = Array{UInt16}(length(data)) copy!(d,1, data,2, length(data)-1) elseif data[1] == 0xfffe # byte-swapped - d = Array(UInt16, length(data)) + d = Array{UInt16}(length(data)) for i = 2:length(data) d[i-1] = bswap(data[i]) end else - d = Array(UInt16, length(data) + 1) + d = Array{UInt16}(length(data) + 1) copy!(d,1, data,1, length(data)) # assume native byte order end d[end] = 0 # NULL terminate diff --git a/base/unicode/utf32.jl b/base/unicode/utf32.jl index 3d36b58fef103..53b366101a653 100644 --- a/base/unicode/utf32.jl +++ b/base/unicode/utf32.jl @@ -128,7 +128,7 @@ convert{T<:AbstractString, S<:Union{UInt32,Char,Int32}}(::Type{T}, v::AbstractVe # specialize for performance reasons: function convert{T<:Union{UInt32,Char,Int32}}(::Type{String}, data::AbstractVector{T}) - s = IOBuffer(Array(UInt8,length(data)), true, true) + s = IOBuffer(Array{UInt8}(length(data)), true, true) truncate(s,0) for x in data print(s, Char(x)) @@ -148,15 +148,15 @@ function convert(T::Type{UTF32String}, bytes::AbstractArray{UInt8}) data = reinterpret(UInt32, bytes) # check for byte-order mark (BOM): if data[1] == 0x0000feff # native byte order - d = Array(UInt32, length(data)) + d = Array{UInt32}(length(data)) copy!(d,1, data, 2, length(data)-1) elseif data[1] == 0xfffe0000 # byte-swapped - d = Array(UInt32, length(data)) + d = Array{UInt32}(length(data)) for i = 2:length(data) @inbounds d[i-1] = bswap(data[i]) end else - d = Array(UInt32, length(data) + 1) + d = Array{UInt32}(length(data) + 1) copy!(d, 1, data, 1, length(data)) # assume native byte order end d[end] = 0 # NULL terminate diff --git a/base/unicode/utf8.jl b/base/unicode/utf8.jl index 28d0a0f9f609a..c7d11aed10e14 100644 --- a/base/unicode/utf8.jl +++ b/base/unicode/utf8.jl @@ -155,7 +155,7 @@ function string(a::String...) return a[1]::String end # ^^ at least one must be UTF-8 or the ASCII-only method would get called - data = Array(UInt8,0) + data = Array{UInt8}(0) for d in a append!(data,d.data) end @@ -163,7 +163,7 @@ function string(a::String...) end function string(a::Union{String,Char}...) - s = Array(UInt8,0) + s = Array{UInt8}(0) for d in a if isa(d,Char) c = UInt32(d::Char) diff --git a/base/util.jl b/base/util.jl index 406108c97fa1b..11443bc45b66f 100644 --- a/base/util.jl +++ b/base/util.jl @@ -397,7 +397,7 @@ if is_windows() function getpass(prompt::AbstractString) print(prompt) flush(STDOUT) - p = Array(UInt8, 128) # mimic Unix getpass in ignoring more than 128-char passwords + p = Array{UInt8}(128) # mimic Unix getpass in ignoring more than 128-char passwords # (also avoids any potential memory copies arising from push!) try plen = 0 diff --git a/doc/devdocs/subarrays.rst b/doc/devdocs/subarrays.rst index 955e74a57f654..0f96cebf991af 100644 --- a/doc/devdocs/subarrays.rst +++ b/doc/devdocs/subarrays.rst @@ -126,7 +126,7 @@ parent array, whereas for ``S2`` one needs to apply them to the second and third. The simplest approach to indexing would be to do the type-analysis at runtime:: - parentindexes = Array(Any, 0) + parentindexes = Array{Any}(0) for i = 1:ndims(S.parent) ... if isa(thisindex, Int) diff --git a/doc/manual/arrays.rst b/doc/manual/arrays.rst index ee85263e9a273..c0b03cd4763c4 100644 --- a/doc/manual/arrays.rst +++ b/doc/manual/arrays.rst @@ -67,7 +67,7 @@ dimension sizes passed as a variable number of arguments. =================================================== ===================================================================== Function Description =================================================== ===================================================================== -:func:`Array(type, dims...) ` an uninitialized dense array +:func:`Array{type}(dims...) ` an uninitialized dense array :func:`cell(dims...) ` an uninitialized cell array (heterogeneous array) :func:`zeros(type, dims...) ` an array of all zeros of specified type, defaults to ``Float64`` if ``type`` not specified diff --git a/doc/manual/calling-c-and-fortran-code.rst b/doc/manual/calling-c-and-fortran-code.rst index b2ec6ed6bf2b4..b08264d2868cb 100644 --- a/doc/manual/calling-c-and-fortran-code.rst +++ b/doc/manual/calling-c-and-fortran-code.rst @@ -136,7 +136,7 @@ Here is a slightly more complex example that discovers the local machine's hostname:: function gethostname() - hostname = Array(UInt8, 128) + hostname = Array{UInt8}(128) ccall((:gethostname, "libc"), Int32, (Ptr{UInt8}, Csize_t), hostname, sizeof(hostname)) @@ -879,7 +879,7 @@ Here is a third example passing Julia arrays:: # double result_array[]) function sf_bessel_Jn_array(nmin::Integer, nmax::Integer, x::Real) if nmax` ``similar(A, eltype(A), size(A))`` Return a mutable array with the same shape and element type :func:`similar(A, ::Type{S}) ` ``similar(A, S, size(A))`` Return a mutable array with the same shape and the specified element type :func:`similar(A, dims::NTuple{Int}) ` ``similar(A, eltype(A), dims)`` Return a mutable array with the same element type and the specified dimensions -:func:`similar(A, ::Type{S}, dims::NTuple{Int}) ` ``Array(S, dims)`` Return a mutable array with the specified element type and dimensions +:func:`similar(A, ::Type{S}, dims::NTuple{Int}) ` ``Array{S}(dims)`` Return a mutable array with the specified element type and dimensions ============================================================================ ============================================ ======================================================================================= - If a type is defined as a subtype of ``AbstractArray``, it inherits a very large set of rich behaviors including iteration and multidimensional indexing built on top of single-element access. See the :ref:`arrays manual page ` and :ref:`standard library section ` for more supported methods. A key part in defining an ``AbstractArray`` subtype is :func:`Base.linearindexing`. Since indexing is such an important part of an array and often occurs in hot loops, it's important to make both indexing and indexed assignment as efficient as possible. Array data structures are typically defined in one of two ways: either it most efficiently accesses its elements using just one index (linear indexing) or it intrinsically accesses the elements with indices specified for every dimension. These two modalities are identified by Julia as ``Base.LinearFast()`` and ``Base.LinearSlow()``. Converting a linear index to multiple indexing subscripts is typically very expensive, so this provides a traits-based mechanism to enable efficient generic code for all array types. diff --git a/doc/manual/metaprogramming.rst b/doc/manual/metaprogramming.rst index 8be410842f55c..bc32d8c0a9019 100644 --- a/doc/manual/metaprogramming.rst +++ b/doc/manual/metaprogramming.rst @@ -102,7 +102,7 @@ objects: julia> dump(ex2) Expr head: Symbol call - args: Array(Any,(3,)) + args: Array{Any}((3,)) 1: Symbol + 2: Int64 1 3: Int64 1 @@ -619,7 +619,7 @@ Compare: julia> dump(:("a ($a) should equal b ($b)!")) Expr head: Symbol string - args: Array(Any,(5,)) + args: Array{Any}((5,)) 1: String "a (" 2: Symbol a 3: String ") should equal b (" diff --git a/doc/manual/performance-tips.rst b/doc/manual/performance-tips.rst index 8ed034b34f185..a101b10f2f0d1 100644 --- a/doc/manual/performance-tips.rst +++ b/doc/manual/performance-tips.rst @@ -827,7 +827,7 @@ adapted accordingly). We could conceivably do this in at least four ways function copy_cols{T}(x::Vector{T}) n = size(x, 1) - out = Array(eltype(x), n, n) + out = Array{eltype(x)}(n, n) for i=1:n out[:, i] = x end @@ -836,7 +836,7 @@ adapted accordingly). We could conceivably do this in at least four ways function copy_rows{T}(x::Vector{T}) n = size(x, 1) - out = Array(eltype(x), n, n) + out = Array{eltype(x)}(n, n) for i=1:n out[i, :] = x end @@ -845,7 +845,7 @@ adapted accordingly). We could conceivably do this in at least four ways function copy_col_row{T}(x::Vector{T}) n = size(x, 1) - out = Array(T, n, n) + out = Array{T}(n, n) for col=1:n, row=1:n out[row, col] = x[row] end @@ -854,7 +854,7 @@ adapted accordingly). We could conceivably do this in at least four ways function copy_row_col{T}(x::Vector{T}) n = size(x, 1) - out = Array(T, n, n) + out = Array{T}(n, n) for row=1:n, col=1:n out[row, col] = x[col] end @@ -920,7 +920,7 @@ with end function loopinc_prealloc() - ret = Array(Int, 3) + ret = Array{Int}(3) y = 0 for i = 1:10^7 xinc!(ret, i) @@ -1146,7 +1146,7 @@ evaluates the L2-norm of the result:: function main() n = 2000 - u = Array(Float64, n) + u = Array{Float64}(n) init!(u) du = similar(u) diff --git a/doc/manual/style-guide.rst b/doc/manual/style-guide.rst index 98dc69800a6f1..a752b37a20ba2 100644 --- a/doc/manual/style-guide.rst +++ b/doc/manual/style-guide.rst @@ -149,7 +149,7 @@ Avoid elaborate container types It is usually not much help to construct arrays like the following:: - a = Array(Union{Int,AbstractString,Tuple,Array}, n) + a = Array{Union{Int,AbstractString,Tuple,Array}}(n) In this case :func:`cell(n) ` is better. It is also more helpful to the compiler to annotate specific uses (e.g. ``a[i]::Int``) than to try to pack many diff --git a/doc/manual/variables-and-scoping.rst b/doc/manual/variables-and-scoping.rst index c7b08a8ebfff1..480e836bf9a82 100644 --- a/doc/manual/variables-and-scoping.rst +++ b/doc/manual/variables-and-scoping.rst @@ -397,7 +397,7 @@ has been introduced. Therefore it makes sense to write something like ``let x = x`` since the two ``x`` variables are distinct and have separate storage. Here is an example where the behavior of ``let`` is needed:: - Fs = Array(Any,2) + Fs = Array{Any}(2) i = 1 while i <= 2 Fs[i] = ()->i @@ -415,7 +415,7 @@ However, it is always the same variable ``i``, so the two closures behave identically. We can use ``let`` to create a new binding for ``i``:: - Fs = Array(Any,2) + Fs = Array{Any}(2) i = 1 while i <= 2 let i = i @@ -462,7 +462,7 @@ are freshly allocated for each loop iteration. This is in contrast to iterations. Therefore these constructs are similar to ``while`` loops with ``let`` blocks inside:: - Fs = Array(Any,2) + Fs = Array{Any}(2) for i = 1:2 Fs[i] = ()->i end diff --git a/doc/stdlib/arrays.rst b/doc/stdlib/arrays.rst index 45f1140a3b6f5..0250fc82b1933 100644 --- a/doc/stdlib/arrays.rst +++ b/doc/stdlib/arrays.rst @@ -235,7 +235,7 @@ Constructors Create an uninitialized mutable array with the given element type and size, based upon the given source array. The second and third arguments are both optional, defaulting to the given array's ``eltype`` and ``size``\ . The dimensions may be specified either as a single tuple argument or as a series of integer arguments. - Custom AbstractArray subtypes may choose which specific array type is best-suited to return for the given element type and dimensionality. If they do not specialize this method, the default is an ``Array(element_type, dims...)``\ . + Custom AbstractArray subtypes may choose which specific array type is best-suited to return for the given element type and dimensionality. If they do not specialize this method, the default is an ``Array{element_type}(dims...)``\ . For example, ``similar(1:10, 1, 4)`` returns an uninitialized ``Array{Int,2}`` since ranges are neither mutable nor support 2 dimensions: @@ -995,4 +995,3 @@ dense counterparts. The following functions are specific to sparse arrays. # perform sparse wizardry... end end - diff --git a/examples/lru.jl b/examples/lru.jl index cc8958ef015e8..f665132524f78 100644 --- a/examples/lru.jl +++ b/examples/lru.jl @@ -39,7 +39,7 @@ type UnboundedLRU{K,V} <: LRU{K,V} ht::Dict q::Vector{CacheItem} - UnboundedLRU() = new(Dict(), similar(Array(CacheItem,1), 0)) + UnboundedLRU() = new(Dict(), similar(Array{CacheItem}(1), 0)) end UnboundedLRU() = UnboundedLRU{Any, Any}() @@ -48,7 +48,7 @@ type BoundedLRU{K,V} <: LRU{K,V} q::Vector{CacheItem} maxsize::Int - BoundedLRU(m) = new(Dict(), similar(Array(CacheItem,1), 0), m) + BoundedLRU(m) = new(Dict(), similar(Array{CacheItem}(1), 0), m) BoundedLRU() = BoundedLRU(__MAXCACHE) end BoundedLRU(m) = BoundedLRU{Any, Any}(m) diff --git a/examples/ndgrid.jl b/examples/ndgrid.jl index 688a246b8b7ed..228c609ee7fa2 100644 --- a/examples/ndgrid.jl +++ b/examples/ndgrid.jl @@ -18,7 +18,7 @@ end function ndgrid{T}(vs::AbstractVector{T}...) n = length(vs) sz = map(length, vs) - out = ntuple(i->Array(T, sz), n) + out = ntuple(i->Array{T}(sz), n) s = 1 for i=1:n a = out[i]::Array diff --git a/examples/queens.jl b/examples/queens.jl index dba16fd5ad40f..a3d61ead1b6aa 100644 --- a/examples/queens.jl +++ b/examples/queens.jl @@ -5,7 +5,7 @@ addqueen(queens::Array{Vector{Int}}, queen::Vector{Int}) = push!(copy(queens), q hitsany(queen::Vector{Int}, queens::Array{Vector{Int}}) = any(x->hits(queen, x), queens) hits(a::Array{Int}, b::Array{Int}) = any(a .== b) || abs(a-b)[1] == abs(a-b)[2] -function solve(x, y, n, d=Array(Vector{Int}, 0)) +function solve(x, y, n, d=Array{Vector{Int}}(0)) if n == 0 return d end diff --git a/test/abstractarray.jl b/test/abstractarray.jl index 1d70b47be87f2..942e8e2464046 100644 --- a/test/abstractarray.jl +++ b/test/abstractarray.jl @@ -245,7 +245,7 @@ function test_primitives{T}(::Type{T}, shape, ::Type{TestAbstractArray}) @test_throws DimensionMismatch reshape(B, (0, 1)) # copy!(dest::AbstractArray, src::AbstractArray) - @test_throws BoundsError copy!(Array(Int, 10), [1:11...]) + @test_throws BoundsError copy!(Array{Int}(10), [1:11...]) # convert{T, N}(::Type{Array}, A::AbstractArray{T, N}) X = [1:10...] @@ -320,14 +320,14 @@ function test_cat(::Type{TestAbstractArray}) A = T24Linear([1:24...]) b_int = reshape([1:27...], 3, 3, 3) b_float = reshape(Float64[1:27...], 3, 3, 3) - b2hcat = Array(Float64, 3, 6, 3) + b2hcat = Array{Float64}(3, 6, 3) b1 = reshape([1:9...], 3, 3) b2 = reshape([10:18...], 3, 3) b3 = reshape([19:27...], 3, 3) b2hcat[:, :, 1] = hcat(b1, b1) b2hcat[:, :, 2] = hcat(b2, b2) b2hcat[:, :, 3] = hcat(b3, b3) - b3hcat = Array(Float64, 3, 9, 3) + b3hcat = Array{Float64}(3, 9, 3) b3hcat[:, :, 1] = hcat(b1, b1, b1) b3hcat[:, :, 2] = hcat(b2, b2, b2) b3hcat[:, :, 3] = hcat(b3, b3, b3) @@ -442,7 +442,7 @@ function test_map(::Type{TestAbstractArray}) end # AbstractArray map for N-arg case - A = Array(Int, 10) + A = Array{Int}(10) f(x, y, z) = x + y + z D = Float64[1:10...] diff --git a/test/arrayops.jl b/test/arrayops.jl index 99126d9f57380..0391c2b9656ee 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -59,7 +59,7 @@ a[[1 2], 1] = 0 a[:, [1 2]] = 2 @test a == 2ones(2,2) -a = Array(Float64, 2, 2, 2, 2, 2) +a = Array{Float64}(2, 2, 2, 2, 2) a[1,1,1,1,1] = 10 a[1,2,1,1,2] = 20 a[1,1,2,2,1] = 30 @@ -308,9 +308,9 @@ _array_equiv(a,b) = eltype(a) == eltype(b) && a == b @test_throws MethodError UInt8[1:3] @test_throws MethodError UInt8[1:3,] @test_throws MethodError UInt8[1:3,4:6] -a = Array(UnitRange{Int},1); a[1] = 1:3 +a = Array{UnitRange{Int}}(1); a[1] = 1:3 @test _array_equiv([1:3,], a) -a = Array(UnitRange{Int},2); a[1] = 1:3; a[2] = 4:6 +a = Array{UnitRange{Int}}(2); a[1] = 1:3; a[2] = 4:6 @test _array_equiv([1:3,4:6], a) # typed hvcat @@ -671,7 +671,7 @@ let R = repeat(A, inner = (1, 1, 2), outer = (1, 1, 1)) T = reshape([1:4; 1:4; 5:8; 5:8], 2, 2, 4) @test R == T - A = Array(Int, 2, 2, 2) + A = Array{Int}(2, 2, 2) A[:, :, 1] = [1 2; 3 4] A[:, :, 2] = [5 6; @@ -934,7 +934,7 @@ let end # fill -@test fill!(Array(Float64,1),-0.0)[1] === -0.0 +@test fill!(Array{Float64}(1),-0.0)[1] === -0.0 A = ones(3,3) S = sub(A, 2, 1:3) fill!(S, 2) @@ -943,11 +943,11 @@ fill!(S, 3) @test A == [1 1 3; 2 2 3; 1 1 1] rt = Base.return_types(fill!, Tuple{Array{Int32, 3}, UInt8}) @test length(rt) == 1 && rt[1] == Array{Int32, 3} -A = Array(Union{UInt8,Int8}, 3) +A = Array{Union{UInt8,Int8}}(3) fill!(A, UInt8(3)) @test A == [0x03, 0x03, 0x03] # Issue #9964 -A = Array(Vector{Float64}, 2) +A = Array{Vector{Float64}}(2) fill!(A, [1, 2]) @test A[1] == [1, 2] @test A[1] === A[2] @@ -1024,7 +1024,7 @@ end @test isequal(flipdim(1:10, 1), 10:-1:1) @test isequal(flipdim(1:10, 2), 1:10) @test_throws ArgumentError flipdim(1:10, -1) -@test isequal(flipdim(Array(Int,0,0),1), Array(Int,0,0)) # issue #5872 +@test isequal(flipdim(Array{Int}(0,0),1), Array{Int}(0,0)) # issue #5872 # isdiag, istril, istriu @test isdiag(3) @@ -1130,15 +1130,15 @@ end @test pr8622() == [0,3,1,0] #6828 - size of specific dimensions -a = Array(Float64, 10) +a = Array{Float64}(10) @test size(a) == (10,) @test size(a, 1) == 10 @test size(a,2,1) == (1,10) -a = Array(Float64, 2,3) +a = Array{Float64}(2,3) @test size(a) == (2,3) @test size(a,4,3,2,1) == (1,1,3,2) @test size(a,1,2) == (2,3) -a = Array(Float64, 9,8,7,6,5,4,3,2,1) +a = Array{Float64}(9,8,7,6,5,4,3,2,1) @test size(a,1,1) == (9,9) @test size(a,4) == 6 @test size(a,9,8,7,6,5,4,3,2,19,8,7,6,5,4,3,2,1) == (1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,9) diff --git a/test/bitarray.jl b/test/bitarray.jl index f0d705826016b..037b487643146 100644 --- a/test/bitarray.jl +++ b/test/bitarray.jl @@ -962,7 +962,7 @@ elts = (1:64:64*64+1) .+ (0:64) B1 = falses(maximum(elts)) B1[elts] = true B1′ = ~B1 -B2 = fill!(Array(Bool, maximum(elts)), false) +B2 = fill!(Array{Bool}(maximum(elts)), false) B2[elts] = true @test B1 == B2 @test all(B1 .== B2) diff --git a/test/core.jl b/test/core.jl index 8860ff48543c0..91e8e22ddc77d 100644 --- a/test/core.jl +++ b/test/core.jl @@ -66,8 +66,8 @@ let T = TypeVar(:T,true) Tuple{Number, Array{Number,1}}, isequal) @testintersect(Tuple{Array{T}, Array{T}}, Tuple{Array, Array{Any}}, Bottom, isnot) f47{T}(x::Vector{Vector{T}}) = 0 - @test_throws MethodError f47(Array(Vector,0)) - @test f47(Array(Vector{Int},0)) == 0 + @test_throws MethodError f47(Array{Vector}(0)) + @test f47(Array{Vector{Int}}(0)) == 0 @testintersect(Tuple{T,T}, Tuple{Union{Float64,Int64},Int64}, Tuple{Int64,Int64}) @testintersect(Tuple{T,T}, Tuple{Int64,Union{Float64,Int64}}, Tuple{Int64,Int64}) @@ -559,7 +559,7 @@ let @test !isdefined(a,1) && !isdefined(a,2) a[1] = 1 @test isdefined(a,1) && !isdefined(a,2) - a = Array(Float64,1) + a = Array{Float64}(1) @test isdefined(a,1) @test isdefined(a) @test !isdefined(a,2) @@ -582,7 +582,7 @@ let @test !isassigned(a,1) && !isassigned(a,2) a[1] = 1 @test isassigned(a,1) && !isassigned(a,2) - a = Array(Float64,1) + a = Array{Float64}(1) @test isassigned(a,1) @test isassigned(a) @test !isassigned(a,2) @@ -1068,7 +1068,7 @@ let # issue #1886 X = [1:4;] - r = Array(UnitRange{Int},1) + r = Array{UnitRange{Int}}(1) r[1] = 2:3 X[r...] *= 2 @test X == [1,4,6,4] @@ -1132,7 +1132,7 @@ immutable Foo2509; foo::Int; end # issue #2517 immutable Foo2517; end @test repr(Foo2517()) == "Foo2517()" -@test repr(Array(Foo2517,1)) == "Foo2517[Foo2517()]" +@test repr(Array{Foo2517}(1)) == "Foo2517[Foo2517()]" @test Foo2517() === Foo2517() # issue #1474 @@ -1261,13 +1261,13 @@ end # issue #3167 let function foo(x) - ret=Array(typeof(x[1]), length(x)) + ret=Array{typeof(x[1])}(length(x)) for j = 1:length(x) ret[j] = x[j] end return ret end - x = Array(Union{Dict{Int64,AbstractString},Array{Int64,3},Number,AbstractString,Void}, 3) + x = Array{Union{Dict{Int64,AbstractString},Array{Int64,3},Number,AbstractString,Void}}(3) x[1] = 1.0 x[2] = 2.0 x[3] = 3.0 @@ -1535,7 +1535,7 @@ end @test invalid_tupleref()==true # issue #5150 -f5150(T) = Array(Rational{T},1) +f5150(T) = Array{Rational{T}}(1) @test typeof(f5150(Int)) === Array{Rational{Int},1} @@ -1686,7 +1686,7 @@ type Polygon5884{T<:Real} end function test5884() - star = Array(Polygon5884,(3,)) + star = Array{Polygon5884}((3,)) star[1] = Polygon5884([Complex(1.0,1.0)]) p1 = star[1].points[1] @test p1 == Complex(1.0,1.0) @@ -1886,7 +1886,7 @@ end obj = ObjMember(DateRange6387{Int64}()) function v6387{T}(r::Range{T}) - a = Array(T,1) + a = Array{T}(1) a[1] = Core.Intrinsics.box(Date6387{Int64}, Core.Intrinsics.unbox(Int64,Int64(1))) a end @@ -1899,8 +1899,8 @@ end day_in(obj) # issue #6784 -@test ndims(Array(Array{Float64},3,5)) == 2 -@test ndims(Array(Array,3,5)) == 2 +@test ndims(Array{Array{Float64}}(3,5)) == 2 +@test ndims(Array{Array}(3,5)) == 2 # issue #6793 function segfault6793(;gamma=1) @@ -2147,7 +2147,7 @@ end # issue #9475 module I9475 - arr = Array(Any, 1) + arr = Array{Any}(1) @eval @eval $arr[1] = 1 end @@ -3213,7 +3213,7 @@ end # issue #12394 type Empty12394 end -let x = Array(Empty12394,1), y = [Empty12394()] +let x = Array{Empty12394}(1), y = [Empty12394()] @test_throws UndefRefError x==y @test_throws UndefRefError y==x end @@ -3358,7 +3358,7 @@ end #13433, read!(::IO, a::Vector{UInt8}) should return a type IO13433 <: IO end Base.read(::IO13433, ::Type{UInt8}) = 0x01 -@test read!(IO13433(), Array(UInt8, 4)) == [0x01, 0x01, 0x01, 0x01] +@test read!(IO13433(), Array{UInt8}(4)) == [0x01, 0x01, 0x01, 0x01] # issue #13647, comparing boxed isbits immutables immutable X13647 @@ -3408,7 +3408,7 @@ end # issue #8487 @test [x for x in 1:3] == [x for x ∈ 1:3] == [x for x = 1:3] -let A = Array(Int, 4,3) +let A = Array{Int}(4,3) for i ∈ 1:size(A,1), j ∈ 1:size(A,2) A[i,j] = 17*i + 51*j end @@ -3687,7 +3687,7 @@ end # issue #15180 function f15180{T}(x::T) - X = Array(T, 1) + X = Array{T}(1) X[1] = x @noinline ef{J}(::J) = (J,X[1]) # Use T ef{J}(::J, ::Int) = (T,J) diff --git a/test/datafmt.jl b/test/datafmt.jl index fe32b81f6408e..b801828e670ad 100644 --- a/test/datafmt.jl +++ b/test/datafmt.jl @@ -233,7 +233,7 @@ end for data in ["A B C", "A B C\n"] data,hdr = readdlm(IOBuffer(data), header=true) @test hdr == AbstractString["A" "B" "C"] - @test data == Array(Float64, 0, 3) + @test data == Array{Float64}(0, 3) end # fix #13179 parsing unicode lines with default delmiters @@ -262,4 +262,3 @@ for writefunc in ((io,x) -> writemime(io, "text/csv", x), @test vec(readcsv(io)) == x end end - diff --git a/test/dates/ranges.jl b/test/dates/ranges.jl index 3b5b3ff14bbf2..b21d6111b3102 100644 --- a/test/dates/ranges.jl +++ b/test/dates/ranges.jl @@ -272,7 +272,7 @@ end @test_throws MethodError dr + 1 a = Dates.DateTime(2013,1,1) b = Dates.DateTime(2013,2,1) -@test map!(x->x+Dates.Day(1),Array(Dates.DateTime,32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] +@test map!(x->x+Dates.Day(1),Array{Dates.DateTime}(32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] @test map(x->x+Dates.Day(1),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] @test map(x->a in x,drs[1:4]) == [true,true,false,true] @@ -350,7 +350,7 @@ end @test_throws MethodError dr + 1 a = Dates.Date(2013,1,1) b = Dates.Date(2013,2,1) -@test map!(x->x+Dates.Day(1),Array(Dates.Date,32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] +@test map!(x->x+Dates.Day(1),Array{Dates.Date}(32),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] @test map(x->x+Dates.Day(1),dr) == [(a+Dates.Day(1)):(b+Dates.Day(1));] @test map(x->a in x,drs[1:4]) == [true,true,false,true] diff --git a/test/fft.jl b/test/fft.jl index 22f5a731108f9..a15f0ab474262 100644 --- a/test/fft.jl +++ b/test/fft.jl @@ -32,7 +32,7 @@ b[3:6,9:12] = m4 sm4 = slice(b,3:6,9:12) m3d = map(Float32,copy(reshape(1:5*3*2, 5, 3, 2))) -true_fftd3_m3d = Array(Float32, 5, 3, 2) +true_fftd3_m3d = Array{Float32}(5, 3, 2) true_fftd3_m3d[:,:,1] = 17:2:45 true_fftd3_m3d[:,:,2] = -15 diff --git a/test/file.jl b/test/file.jl index 28d753560d617..f2f42213bd568 100644 --- a/test/file.jl +++ b/test/file.jl @@ -881,7 +881,7 @@ end ################### function test_LibcFILE(FILEp) - buf = Array(UInt8, 8) + buf = Array{UInt8}(8) str = ccall(:fread, Csize_t, (Ptr{Void}, Csize_t, Csize_t, Ptr{Void}), buf, 1, 8, FILEp) @test String(buf) == "Hello, w" @test position(FILEp) == 8 diff --git a/test/functional.jl b/test/functional.jl index db22d2fd89403..22770d455c91f 100644 --- a/test/functional.jl +++ b/test/functional.jl @@ -21,7 +21,7 @@ end # map over Bottom[] should return Bottom[] # issue #6719 -@test isequal(typeof(map(x -> x, Array(Union{},0))), Array{Union{},1}) +@test isequal(typeof(map(x -> x, Array{Union{}}(0))), Array{Union{},1}) # maps of tuples (formerly in test/core.jl) -- tuple.jl @test map((x,y)->x+y,(1,2,3),(4,5,6)) == (5,7,9) diff --git a/test/grisu.jl b/test/grisu.jl index 02bcb5bb7fe38..77674f05931f3 100644 --- a/test/grisu.jl +++ b/test/grisu.jl @@ -14,7 +14,7 @@ function trimrep(buffer) end const bufsize = 500 -buffer = Array(UInt8,bufsize); +buffer = Array{UInt8}(bufsize); fill!(buffer,0); bignums = [Grisu.Bignums.Bignum(),Grisu.Bignums.Bignum(),Grisu.Bignums.Bignum(),Grisu.Bignums.Bignum()] diff --git a/test/iobuffer.jl b/test/iobuffer.jl index 6c5a06965d346..1f6d3c62d249b 100644 --- a/test/iobuffer.jl +++ b/test/iobuffer.jl @@ -14,7 +14,7 @@ let io = IOBuffer() @test eof(io) seek(io, 0) @test read(io,UInt8) == convert(UInt8, 'a') -a = Array(UInt8, 2) +a = Array{UInt8}(2) @test read!(io, a) == a @test a == UInt8['b','c'] @test String(io) == "abc" @@ -128,7 +128,7 @@ end # issue 5453 let io=IOBuffer("abcdef") -a = Array(UInt8,1024) +a = Array{UInt8}(1024) @test_throws EOFError read!(io,a) @test eof(io) end diff --git a/test/linalg/generic.jl b/test/linalg/generic.jl index 2baa42b7aed46..84b06128b4324 100644 --- a/test/linalg/generic.jl +++ b/test/linalg/generic.jl @@ -131,7 +131,7 @@ let aa = reshape([1.:6;], (2,3)) @test scale!(similar(a), [1.; 2.], a) == a.*[1; 2] @test scale!(similar(a), [1; 2], a) == a.*[1; 2] @test_throws DimensionMismatch scale!(similar(a), ones(3), a) - @test_throws DimensionMismatch scale!(Array(Float64, 3, 2), a, ones(3)) + @test_throws DimensionMismatch scale!(Array{Float64}(3, 2), a, ones(3)) if atype == "Array" @test scale!(similar(a), a, [1.; 2.; 3.]) == a.*[1 2 3] diff --git a/test/linalg/matmul.jl b/test/linalg/matmul.jl index ec7070d7d6e4c..803d44b1ff654 100644 --- a/test/linalg/matmul.jl +++ b/test/linalg/matmul.jl @@ -12,10 +12,10 @@ using Base.Test @test ones(0,0)*ones(0,4) == zeros(0,4) @test ones(3,0)*ones(0,0) == zeros(3,0) @test ones(0,0)*ones(0,0) == zeros(0,0) -@test Array(Float64, 5, 0) |> t -> t't == zeros(0,0) -@test Array(Float64, 5, 0) |> t -> t*t' == zeros(5,5) -@test Array(Complex128, 5, 0) |> t -> t't == zeros(0,0) -@test Array(Complex128, 5, 0) |> t -> t*t' == zeros(5,5) +@test Array{Float64}(5, 0) |> t -> t't == zeros(0,0) +@test Array{Float64}(5, 0) |> t -> t*t' == zeros(5,5) +@test Array{Complex128}(5, 0) |> t -> t't == zeros(0,0) +@test Array{Complex128}(5, 0) |> t -> t*t' == zeros(5,5) # 2x2 let @@ -97,7 +97,7 @@ let end AA = rand(1:20, 5, 5) .- 10 BB = rand(1:20, 5, 5) .- 10 - CC = Array(Int, size(AA, 1), size(BB, 2)) + CC = Array{Int}(size(AA, 1), size(BB, 2)) for Atype = ["Array", "SubArray"], Btype = ["Array", "SubArray"], Ctype = ["Array", "SubArray"] A = Atype == "Array" ? AA : sub(AA, 1:5, 1:5) B = Btype == "Array" ? BB : sub(BB, 1:5, 1:5) @@ -116,7 +116,7 @@ let @test_throws DimensionMismatch Base.LinAlg.Ac_mul_Bt!(C,ones(Int,4,4),B) end vv = [1,2] - CC = Array(Int, 2, 2) + CC = Array{Int}(2, 2) for vtype = ["Array", "SubArray"], Ctype = ["Array", "SubArray"] v = vtype == "Array" ? vv : sub(vv, 1:2) C = Ctype == "Array" ? CC : sub(CC, 1:2, 1:2) @@ -135,14 +135,14 @@ let @test_throws DimensionMismatch Base.LinAlg.generic_matvecmul!(B,'N',A,zeros(6)) end vv = [1,2,3] - CC = Array(Int, 3, 3) + CC = Array{Int}(3, 3) for vtype = ["Array", "SubArray"], Ctype = ["Array", "SubArray"] v = vtype == "Array" ? vv : sub(vv, 1:3) C = Ctype == "Array" ? CC : sub(CC, 1:3, 1:3) @test A_mul_Bt!(C, v, v) == v*v' end vvf = map(Float64,vv) - CC = Array(Float64, 3, 3) + CC = Array{Float64}(3, 3) for vtype = ["Array", "SubArray"], Ctype = ["Array", "SubArray"] vf = vtype == "Array" ? vvf : sub(vvf, 1:3) C = Ctype == "Array" ? CC : sub(CC, 1:3, 1:3) @@ -276,12 +276,12 @@ end # Issue 11978 let - A = Array(Matrix{Float64}, 2, 2) + A = Array{Matrix{Float64}}(2, 2) A[1,1] = eye(3) A[1,2] = eye(3,2) A[2,1] = eye(2,3) A[2,2] = eye(2) - b = Array(Vector{Float64}, 2) + b = Array{Vector{Float64}}(2) b[1] = ones(3) b[2] = ones(2) @test A*b == Vector{Float64}[[2,2,1], [2,2]] diff --git a/test/linalg/pinv.jl b/test/linalg/pinv.jl index bb82798723be3..77d9d29749036 100644 --- a/test/linalg/pinv.jl +++ b/test/linalg/pinv.jl @@ -9,7 +9,7 @@ debug = false using Base.Test function hilb(T::Type, n::Integer) - a=Array(T,n,n) + a=Array{T}(n,n) for i=1:n for j=1:n a[j,i]=one(T)/(i+j-one(T)) @@ -20,7 +20,7 @@ end hilb(n::Integer) = hilb(Float64,n) function hilb(T::Type, m::Integer, n::Integer) - a=Array(T,m,n) + a=Array{T}(m,n) for i=1:n for j=1:m a[j,i]=one(T)/(i+j-one(T)) @@ -67,7 +67,7 @@ tridiag(m::Integer, n::Integer) = tridiag(Float64, m::Integer, n::Integer) function randn_float64(m::Integer, n::Integer) a=randn(m,n) - b=Array(Float64,m,n) + b=Array{Float64}(m,n) for i=1:n for j=1:m b[j,i]=convert(Float64,a[j,i]); @@ -78,7 +78,7 @@ end function randn_float32(m::Integer, n::Integer) a=randn(m,n) - b=Array(Float32,m,n) + b=Array{Float32}(m,n) for i=1:n for j=1:m b[j,i]=convert(Float32,a[j,i]); @@ -325,4 +325,3 @@ for eltya in (Float32, Float64) @test_approx_eq a.diag[1] 0.0 @test_approx_eq a.diag[2] 0.0 end - diff --git a/test/mmap.jl b/test/mmap.jl index b378427890926..432f6cf210306 100644 --- a/test/mmap.jl +++ b/test/mmap.jl @@ -9,12 +9,12 @@ gc(); gc() gc(); gc() @test Mmap.mmap(file, Array{UInt8,3}, (1,1,11)) == reshape(t,(1,1,11)) gc(); gc() -@test Mmap.mmap(file, Array{UInt8,3}, (11,0,1)) == Array(UInt8,(0,0,0)) +@test Mmap.mmap(file, Array{UInt8,3}, (11,0,1)) == Array{UInt8}((0,0,0)) @test Mmap.mmap(file, Vector{UInt8}, (11,)) == t gc(); gc() @test Mmap.mmap(file, Array{UInt8,2}, (1,11)) == t' gc(); gc() -@test Mmap.mmap(file, Array{UInt8,2}, (0,12)) == Array(UInt8,(0,0)) +@test Mmap.mmap(file, Array{UInt8,2}, (0,12)) == Array{UInt8}((0,0)) m = Mmap.mmap(file, Array{UInt8,3}, (1,2,1)) @test m == reshape("He".data,(1,2,1)) finalize(m); m=nothing; gc() @@ -46,8 +46,8 @@ close(s) gc(); gc() s = open(f->f,file,"w") -@test Mmap.mmap(file) == Array(UInt8, 0) # requested len=0 on empty file -@test Mmap.mmap(file,Vector{UInt8},0) == Array(UInt8, 0) +@test Mmap.mmap(file) == Array{UInt8}(0) # requested len=0 on empty file +@test Mmap.mmap(file,Vector{UInt8},0) == Array{UInt8}(0) m = Mmap.mmap(file,Vector{UInt8},12) m[:] = "Hello World\n".data Mmap.sync!(m) diff --git a/test/mod2pi.jl b/test/mod2pi.jl index e240bc0b47648..f73aecdb4ee69 100644 --- a/test/mod2pi.jl +++ b/test/mod2pi.jl @@ -155,7 +155,7 @@ function testModPi() numTestCases = size(testCases,1) modFns = [mod2pi] xDivisors = [2pi] - errsNew, errsOld = Array(Float64,0), Array(Float64,0) + errsNew, errsOld = Array{Float64}(0), Array{Float64}(0) for rowIdx in 1:numTestCases xExact = testCases[rowIdx,1] for colIdx in 1:1 diff --git a/test/netload/memtest.jl b/test/netload/memtest.jl index 38bab1e072623..fda4b973e2f39 100644 --- a/test/netload/memtest.jl +++ b/test/netload/memtest.jl @@ -22,7 +22,7 @@ immutable RUsage end function get_vmsize() - ru = Array(RUsage, 1) + ru = Array{RUsage}(1) ccall(:getrusage, Cint, (Cint, Ptr{Void}), 0, ru) return ru[1].ru_maxrss end diff --git a/test/parallel_exec.jl b/test/parallel_exec.jl index 0c804a9239f35..1a6c1d80639d9 100644 --- a/test/parallel_exec.jl +++ b/test/parallel_exec.jl @@ -255,7 +255,7 @@ end d = Base.shmem_rand(1:100, dims) a = convert(Array, d) -partsums = Array(Int, length(procs(d))) +partsums = Array{Int}(length(procs(d))) @sync begin for (i, p) in enumerate(procs(d)) @async partsums[i] = remotecall_fetch(p, d) do D @@ -354,7 +354,7 @@ write(fn3, ones(UInt8, 4)) S = SharedArray(fn3, UInt8, sz, 4, mode="a+", init=D->D[localindexes(D)]=0x02) len = prod(sz)+4 @test filesize(fn3) == len -filedata = Array(UInt8, len) +filedata = Array{UInt8}(len) read!(fn3, filedata) @test all(filedata[1:4] .== 0x01) @test all(filedata[5:end] .== 0x02) diff --git a/test/perf/cat/perf.jl b/test/perf/cat/perf.jl index c039158c2423d..33c2bc43d0491 100644 --- a/test/perf/cat/perf.jl +++ b/test/perf/cat/perf.jl @@ -14,7 +14,7 @@ function cat2d_perf2(n, iter) a = rand(n,n) b = rand(n,n) for i=1:iter - c = Array(Float64,2n,2n) + c = Array{Float64}(2n,2n) c[ 1:n, 1:n] = a c[ 1:n, n+1:end] = b c[n+1:end,1:n] = b @@ -35,7 +35,7 @@ function hcat_perf2(n, iter) a = rand(n,n) b = rand(n,n) for i=1:iter - c = Array(Float64, n, 4n) + c = Array{Float64}(n, 4n) c[:, 1: n] = a c[:, n+1: 2n] = b c[:, 2n+1: 3n] = b @@ -55,7 +55,7 @@ function vcat_perf2(n, iter) a = rand(n,n) b = rand(n,n) for i=1:iter - c = Array(Float64, 4n, n) + c = Array{Float64}(4n, n) c[ 1: n, :] = a c[ n+1:2n, :] = b c[2n+1:3n, :] = b @@ -75,7 +75,7 @@ function catnd_perf2(n, iter) a = rand(1,n,n,1) b = rand(1,n,n) for i = 1:iter - c = Array(Float64, 1, n, 4n, 1) + c = Array{Float64}(1, n, 4n, 1) c[1,:, 1: n,1] = a c[1,:, n+1:2n,1] = b c[1,:,2n+1:3n,1] = b @@ -93,4 +93,3 @@ testdata = [(cat2d_perf, "hvcat", "horizontal/vertical matrix concatenat (catnd_perf, "catnd", "N-dimensional matrix concatenation", problemsizes), (catnd_perf2, "catnd_setind", "N-dimensional matrix concatenation using setindex", problemsizes)] include("../perfgeneric.jl") - diff --git a/test/perf/kernel/perf.jl b/test/perf/kernel/perf.jl index 9977ac1383fcf..928ca1ef6f0b8 100644 --- a/test/perf/kernel/perf.jl +++ b/test/perf/kernel/perf.jl @@ -25,7 +25,7 @@ gc() # issue #1211 include("ziggurat.jl") -a = Array(Float64, 1000000) +a = Array{Float64}(1000000) @timeit randn_zig!(a) "randn_zig" "Ziggurat gaussian number generator" # issue #950 diff --git a/test/perf/perfutil.jl b/test/perf/perfutil.jl index c10650bc1c06d..da9a627e76d3b 100644 --- a/test/perf/perfutil.jl +++ b/test/perf/perfutil.jl @@ -99,7 +99,7 @@ end function maxrss(name) # FIXME: call uv_getrusage instead here @static if is_linux() - rus = Array(Int64, div(144,8)) + rus = Array{Int64}(div(144,8)) fill!(rus, 0x0) res = ccall(:getrusage, Int32, (Int32, Ptr{Void}), 0, rus) if res == 0 diff --git a/test/perf/shootout/fannkuch.jl b/test/perf/shootout/fannkuch.jl index 58da84581d23e..9db19200bdad5 100644 --- a/test/perf/shootout/fannkuch.jl +++ b/test/perf/shootout/fannkuch.jl @@ -8,7 +8,7 @@ # Based on the Javascript program # function fannkuch(n) - p = Array(Int32,n) + p = Array{Int32}(n) for i = 1:n p[i] = i end diff --git a/test/perf/shootout/fasta.jl b/test/perf/shootout/fasta.jl index 702f0853269ba..13bbec2c22875 100644 --- a/test/perf/shootout/fasta.jl +++ b/test/perf/shootout/fasta.jl @@ -42,7 +42,7 @@ function choose_char(cs) end function random_fasta(symb, pr, n) cs = cumsum(pr) - line = Array(UInt8, line_width) + line = Array{UInt8}(line_width) k = n while k > 0 m = min(k, line_width) diff --git a/test/perf/shootout/k_nucleotide.jl b/test/perf/shootout/k_nucleotide.jl index e81a3e44e2401..97f39624ff99d 100644 --- a/test/perf/shootout/k_nucleotide.jl +++ b/test/perf/shootout/k_nucleotide.jl @@ -40,7 +40,7 @@ function isless(x::KNuc, y::KNuc) end function sorted_array(m::Dict{AbstractString, Int}) - kn = Array(KNuc, length(m)) + kn = Array{KNuc}(length(m)) i = 1 for elem in m kn[i] = KNuc(elem...) diff --git a/test/perf/shootout/meteor_contest.jl b/test/perf/shootout/meteor_contest.jl index e7a22f8b4707c..ab9a235a28f68 100644 --- a/test/perf/shootout/meteor_contest.jl +++ b/test/perf/shootout/meteor_contest.jl @@ -44,7 +44,7 @@ const pieces = ( const solutions = Any[] const masks = zeros(UInt64, 10) -const masksAtCell = Array(Any, width*height, height) +const masksAtCell = Array{Any}(width*height, height) valid(x, y) = (0 <= x < width) && (0 <= y < height) legal(mask::UInt64, board::UInt64) = (mask & board) == 0 diff --git a/test/perf/sort/perf.jl b/test/perf/sort/perf.jl index e729dafde7787..81ab363141c8b 100644 --- a/test/perf/sort/perf.jl +++ b/test/perf/sort/perf.jl @@ -19,7 +19,7 @@ if codespeed for size in [2^6,2^16] for s in sorts if s == InsertionSort && size != 2^6; continue; end - data = Array(T, size) + data = Array{T}(size) gc() ## Random @@ -29,7 +29,7 @@ if codespeed name = "$(typename)_$(size)_$(string(s)[1:end-5])_append" desc = "$(string(s)) run on $(size) $(typename) elements pre-sorted 10 random elements appended" - @timeit_init(sort!(data, alg=s), begin data[end-9:end]=randfn!(Array(T,10)) end, name, "") + @timeit_init(sort!(data, alg=s), begin data[end-9:end]=randfn!(Array{T}(10)) end, name, "") end end end @@ -44,7 +44,7 @@ else if s == RadixSort && T == AbstractString continue end #Radix sort not implemented if s == InsertionSort && logsize >=14 continue end #Too slow println(s, s==RadixSort, s, typename, typename==AbstractString, logsize) - data = Array(T, size) + data = Array{T}(size) gc() ## Random @@ -73,7 +73,7 @@ else ## Sorted with 10 unsorted values appended name = "$(typename)_$(logsize)_$(string(s)[1:end-5])_append" - @timeit_init(sort!(data, alg=s), begin data[end-9:end]=randfn!(Array(T,10)) end, name, "") + @timeit_init(sort!(data, alg=s), begin data[end-9:end]=randfn!(Array{T}(10)) end, name, "") ## Random data with 4 unique values name = "$(typename)_$(logsize)_$(string(s)[1:end-5])_4unique" diff --git a/test/perf/threads/laplace3d/laplace3d.jl b/test/perf/threads/laplace3d/laplace3d.jl index f6dc15d838f84..c27956b25205d 100644 --- a/test/perf/threads/laplace3d/laplace3d.jl +++ b/test/perf/threads/laplace3d/laplace3d.jl @@ -87,8 +87,8 @@ end ## initialize and run function laplace3d(nx=290, ny=290, nz=290; iters=1000, verify=false) - u1 = Array(Float32, nx, ny, nz) - u3 = Array(Float32, nx, ny, nz) + u1 = Array{Float32}(nx, ny, nz) + u3 = Array{Float32}(nx, ny, nz) @nloops 3 k u1 begin if @nany 3 d->(k_d == 1 || k_d == size(u1, d)) (@nref 3 u3 k) = (@nref 3 u1 k) = 1.0 @@ -106,8 +106,8 @@ function laplace3d(nx=290, ny=290, nz=290; iters=1000, verify=false) u3 = foo end if verify - u1_orig = Array(Float32, nx, ny, nz) - u3_orig = Array(Float32, nx, ny, nz) + u1_orig = Array{Float32}(nx, ny, nz) + u3_orig = Array{Float32}(nx, ny, nz) @nloops 3 k u1_orig begin if @nany 3 d->(k_d == 1 || k_d == size(u1_orig, d)) (@nref 3 u3_orig k) = (@nref 3 u1_orig k) = 1.0 @@ -133,4 +133,3 @@ end @time laplace3d() #ccall(:jl_threading_profile, Void, ()) - diff --git a/test/perf/threads/lbm3d/lbm3d.jl b/test/perf/threads/lbm3d/lbm3d.jl index f1464a13f3b40..7639cdd2719de 100644 --- a/test/perf/threads/lbm3d/lbm3d.jl +++ b/test/perf/threads/lbm3d/lbm3d.jl @@ -46,7 +46,7 @@ function relax!(F, UX, UY, UZ, nx, ny, nz, deltaU, t1D, t2D, t3D, sSQU, chunkid, for l = 1:size(F,4) density = density + F[i,j,k,l] end - fs = Array(Float64, 6) + fs = Array{Float64}(6) for l = 1:6 fs[l] = 0.0 for m = 1:5 @@ -139,7 +139,7 @@ function lbm3d(n) CI = [0:matsize:matsize*19;]' - BOUND = Array(Float64,nx,ny,nz) + BOUND = Array{Float64}(nx,ny,nz) for i=1:nx, j=1:ny, k=1:nz BOUND[i,j,k] = ((i-5)^2 + (j-6)^2 + (k-7)^2) < 6 @@ -153,14 +153,14 @@ function lbm3d(n) TO_REFLECT = [ON+CI[2] ON+CI[3] ON+CI[4] ON+CI[5] ON+CI[6] ON+CI[7] ON+CI[8] ON+CI[9] ON+CI[10] ON+CI[11] ON+CI[12] ON+CI[13] ON+CI[14] ON+CI[15] ON+CI[16] ON+CI[17] ON+CI[18] ON+CI[19]] REFLECTED = [ON+CI[3] ON+CI[2] ON+CI[5] ON+CI[4] ON+CI[7] ON+CI[6] ON+CI[11] ON+CI[10] ON+CI[9] ON+CI[8] ON+CI[15] ON+CI[14] ON+CI[13] ON+CI[12] ON+CI[19] ON+CI[18] ON+CI[17] ON+CI[16]] - UX = Array(Float64,nx,ny,nz) - UY = Array(Float64,nx,ny,nz) - UZ = Array(Float64,nx,ny,nz) - U = Array(Float64,12,nchunk) - t1D = Array(Float64,nx,ny,nz) - t2D = Array(Float64,nx,ny,nz) - t3D = Array(Float64,nx,ny,nz) - sSQU = Array(Float64,nx,ny,nz) + UX = Array{Float64}(nx,ny,nz) + UY = Array{Float64}(nx,ny,nz) + UZ = Array{Float64}(nx,ny,nz) + U = Array{Float64}(12,nchunk) + t1D = Array{Float64}(nx,ny,nz) + t2D = Array{Float64}(nx,ny,nz) + t3D = Array{Float64}(nx,ny,nz) + sSQU = Array{Float64}(nx,ny,nz) avu = 1 prevavu = 1 @@ -220,4 +220,3 @@ end @time lbm3d(36) #ccall(:jl_threading_profile, Void, ()) - diff --git a/test/perf/threads/stockcorr/pstockcorr.jl b/test/perf/threads/stockcorr/pstockcorr.jl index cbf3790d6ef54..076feb7cc58b2 100644 --- a/test/perf/threads/stockcorr/pstockcorr.jl +++ b/test/perf/threads/stockcorr/pstockcorr.jl @@ -83,8 +83,8 @@ function pstockcorr(n) # Optimization: pre-allocate these for performance # NOTE: the new GC will hopefully fix this, but currently GC time # kills performance if we don't do in-place computations - Wiener = Array(Float64, T-1, 2) - CorrWiener = Array(Float64, T-1, 2) + Wiener = Array{Float64}(T-1, 2) + CorrWiener = Array{Float64}(T-1, 2) # Runtime requirement: need per-thread RNG since it stores state rngs = [MersenneTwister(777+x) for x in 1:nthreads()] @@ -108,4 +108,3 @@ end @time pstockcorr(1000000) #ccall(:jl_threading_profile, Void, ()) - diff --git a/test/pollfd.jl b/test/pollfd.jl index a151b42dd663a..7a44a99d83567 100644 --- a/test/pollfd.jl +++ b/test/pollfd.jl @@ -14,10 +14,10 @@ intvls = [2, .2, .1, .005] pipe_fds = cell(n) for i in 1:n @static if is_windows() - pipe_fds[i] = Array(Libc.WindowsRawSocket, 2) + pipe_fds[i] = Array{Libc.WindowsRawSocket}(2) 0 == ccall(:wsasocketpair, Cint, (Cint, Cuint, Cint, Ptr{Libc.WindowsRawSocket}), 1, 1, 6, pipe_fds[i]) || error(Libc.FormatMessage()) else - pipe_fds[i] = Array(RawFD, 2) + pipe_fds[i] = Array{RawFD}(2) @test 0 == ccall(:pipe, Cint, (Ptr{RawFD},), pipe_fds[i]) end end @@ -36,7 +36,7 @@ function pfd_tst_reads(idx, intvl) # Disabled since this assertion fails randomly, notably on build VMs (issue #12824) # @test t_elapsed <= (intvl + 1) - dout = Array(UInt8, 1) + dout = Array{UInt8}(1) @static if is_windows() 1 == ccall(:recv, stdcall, Cint, (Ptr{Void}, Ptr{UInt8}, Cint, Cint), pipe_fds[idx][1], dout, 1, 0) || error(Libc.FormatMessage()) else diff --git a/test/random.jl b/test/random.jl index 3c5ce09e1e556..5dd1c2aa4ba60 100644 --- a/test/random.jl +++ b/test/random.jl @@ -41,14 +41,14 @@ A = zeros(UInt128, 2, 2) let mt = MersenneTwister() srand(mt) @test rand(mt, 0:3:1000) in 0:3:1000 - @test issubset(rand!(mt, Array(Int, 100), 0:3:1000), 0:3:1000) + @test issubset(rand!(mt, Array{Int}(100), 0:3:1000), 0:3:1000) coll = Any[2, UInt128(128), big(619), "string"] @test rand(mt, coll) in coll @test issubset(rand(mt, coll, 2, 3), coll) # check API with default RNG: rand(0:3:1000) - rand!(Array(Int, 100), 0:3:1000) + rand!(Array{Int}(100), 0:3:1000) rand(coll) rand(coll, 2, 3) end @@ -119,13 +119,13 @@ emantissa = Int64(2)^52 ziggurat_exp_r = parse(BigFloat,"7.69711747013104971404462804811408952334296818528283253278834867283241051210533") exp_section_area = (ziggurat_exp_r + 1)*exp(-ziggurat_exp_r) -ki = Array(UInt64, ziggurat_table_size) -wi = Array(Float64, ziggurat_table_size) -fi = Array(Float64, ziggurat_table_size) +ki = Array{UInt64}(ziggurat_table_size) +wi = Array{Float64}(ziggurat_table_size) +fi = Array{Float64}(ziggurat_table_size) # Tables for exponential variates -ke = Array(UInt64, ziggurat_table_size) -we = Array(Float64, ziggurat_table_size) -fe = Array(Float64, ziggurat_table_size) +ke = Array{UInt64}(ziggurat_table_size) +we = Array{Float64}(ziggurat_table_size) +fe = Array{Float64}(ziggurat_table_size) function randmtzig_fill_ziggurat_tables() # Operates on the global arrays wib = big(wi) fib = big(fi) @@ -234,7 +234,7 @@ end # test code paths of rand! let mt = MersenneTwister(0) - A128 = Array(UInt128, 0) + A128 = Array{UInt128}(0) @test length(rand!(mt, A128)) == 0 for (i,n) in enumerate([1, 3, 5, 6, 10, 11, 30]) resize!(A128, n) @@ -251,8 +251,8 @@ let mt = MersenneTwister(0) srand(mt,0) for (i,T) in enumerate([Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, Float16, Float32]) - A = Array(T, 16) - B = Array(T, 31) + A = Array{T}(16) + B = Array{T}(31) rand!(mt, A) rand!(mt, B) @test A[end] == Any[21,0x7b,17385,0x3086,-1574090021,0xadcb4460,6797283068698303107,0x4e91c9c4d4f5f759, @@ -263,7 +263,7 @@ let mt = MersenneTwister(0) end srand(mt,0) - AF64 = Array(Float64, Base.Random.dsfmt_get_min_array_size()-1) + AF64 = Array{Float64}(Base.Random.dsfmt_get_min_array_size()-1) @test rand!(mt, AF64)[end] == 0.957735065345398 @test rand!(mt, AF64)[end] == 0.6492481059865669 resize!(AF64, 2*length(mt.vals)) @@ -272,10 +272,10 @@ end # Issue #9037 let mt = MersenneTwister() - a = Array(Float64, 0) + a = Array{Float64}(0) resize!(a, 1000) # could be 8-byte aligned - b = Array(Float64, 1000) # should be 16-byte aligned - c8 = Array(UInt64, 1001) + b = Array{Float64}(1000) # should be 16-byte aligned + c8 = Array{UInt64}(1001) pc8 = pointer(c8) if Int(pc8) % 16 == 0 # Make sure pc8 is not 16-byte aligned since that's what we want to test. @@ -306,8 +306,8 @@ for rng in ([], [MersenneTwister()], [RandomDevice()]) f(rng..., 2, 3) ::Array{Float64, 2} end for f! in [randn!, randexp!] - f!(rng..., Array(Float64, 5)) ::Vector{Float64} - f!(rng..., Array(Float64, 2, 3)) ::Array{Float64, 2} + f!(rng..., Array{Float64}(5)) ::Vector{Float64} + f!(rng..., Array{Float64}(2, 3)) ::Array{Float64, 2} end bitrand(rng..., 5) ::BitArray{1} @@ -324,7 +324,7 @@ for rng in ([], [MersenneTwister()], [RandomDevice()]) @test 0.0 <= a < 1.0 end end - for A in (Array(T, 5), Array(T, 2, 3)) + for A in (Array{T}(5), Array{T}(2, 3)) X = T == Bool ? T[0,1] : T[0,1,2] rand!(rng..., A) ::typeof(A) rand!(rng..., A, X) ::typeof(A) diff --git a/test/serialize.jl b/test/serialize.jl index 0e2f4b062079d..c1dd18e5a575a 100644 --- a/test/serialize.jl +++ b/test/serialize.jl @@ -204,7 +204,7 @@ create_serialization_stream() do s # small 1d array arr4 = reshape([true, false, false, false, true, false, false, false, true], 3, 3) serialize(s, arr4) # boolean array - arr5 = Array(TA1, 3) + arr5 = Array{TA1}(3) arr5[2] = TA1(0x01) serialize(s, arr5) diff --git a/test/simdloop.jl b/test/simdloop.jl index 771383aedf419..4ea2f82ba8355 100644 --- a/test/simdloop.jl +++ b/test/simdloop.jl @@ -103,27 +103,27 @@ end crng = CartesianRange(CartesianIndex{4}(2,0,1,3), CartesianIndex{4}(4,1,1,5)) -indexes = simd_cartesian_range!(Array(eltype(crng), 0), crng) +indexes = simd_cartesian_range!(Array{eltype(crng)}(0), crng) @test indexes == vec(collect(crng)) crng = CartesianRange(CartesianIndex{2}(-1,1), CartesianIndex{2}(1,3)) -indexes = simd_cartesian_range!(Array(eltype(crng), 0), crng) +indexes = simd_cartesian_range!(Array{eltype(crng)}(0), crng) @test indexes == vec(collect(crng)) crng = CartesianRange(CartesianIndex{2}(-1,1), CartesianIndex{2}(-1,3)) -indexes = simd_cartesian_range!(Array(eltype(crng), 0), crng) +indexes = simd_cartesian_range!(Array{eltype(crng)}(0), crng) @test indexes == vec(collect(crng)) crng = CartesianRange(CartesianIndex{1}(2), CartesianIndex{1}(4)) -indexes = simd_cartesian_range!(Array(eltype(crng), 0), crng) +indexes = simd_cartesian_range!(Array{eltype(crng)}(0), crng) @test indexes == collect(crng) crng = CartesianRange(CartesianIndex{0}(), CartesianIndex{0}()) -indexes = simd_cartesian_range!(Array(eltype(crng), 0), crng) +indexes = simd_cartesian_range!(Array{eltype(crng)}(0), crng) @test indexes == vec(collect(crng)) # @simd with array as "range" diff --git a/test/sparsedir/sparse.jl b/test/sparsedir/sparse.jl index 9ed4ff2a882b8..cbfc014619bb0 100644 --- a/test/sparsedir/sparse.jl +++ b/test/sparsedir/sparse.jl @@ -333,10 +333,10 @@ end @test var(sparse(Int[])) === NaN for f in (sum, prod, minimum, maximum, var) - @test isequal(f(spzeros(0, 1), 1), f(Array(Int, 0, 1), 1)) - @test isequal(f(spzeros(0, 1), 2), f(Array(Int, 0, 1), 2)) - @test isequal(f(spzeros(0, 1), (1, 2)), f(Array(Int, 0, 1), (1, 2))) - @test isequal(f(spzeros(0, 1), 3), f(Array(Int, 0, 1), 3)) + @test isequal(f(spzeros(0, 1), 1), f(Array{Int}(0, 1), 1)) + @test isequal(f(spzeros(0, 1), 2), f(Array{Int}(0, 1), 2)) + @test isequal(f(spzeros(0, 1), (1, 2)), f(Array{Int}(0, 1), (1, 2))) + @test isequal(f(spzeros(0, 1), 3), f(Array{Int}(0, 1), 3)) end # spdiagm @@ -704,7 +704,7 @@ let S = spzeros(10,8), A = full(S) @test indmin(S) == indmin(A) == 1 end -let A = Array(Int,0,0), S = sparse(A) +let A = Array{Int}(0,0), S = sparse(A) iA = try indmax(A) end iS = try indmax(S) end @test iA === iS === nothing diff --git a/test/sparsedir/sparsevector.jl b/test/sparsedir/sparsevector.jl index 48fdf459c28ce..9db76dddae6ee 100644 --- a/test/sparsedir/sparsevector.jl +++ b/test/sparsedir/sparsevector.jl @@ -365,7 +365,7 @@ end ### Concatenation let m = 80, n = 100 - A = Array(SparseVector{Float64,Int}, n) + A = Array{SparseVector{Float64,Int}}(n) tnnz = 0 for i = 1:length(A) A[i] = sprand(m, 0.3) diff --git a/test/staged.jl b/test/staged.jl index 3caa679dd619b..0a635ee1a1ba4 100644 --- a/test/staged.jl +++ b/test/staged.jl @@ -74,7 +74,7 @@ B = slice(A, 1:3, 2, 1:3); end Ip = I.parameters NP = length(Ip) - indexexprs = Array(Expr, NP) + indexexprs = Array{Expr}(NP) j = 1 for i = 1:NP if Ip[i] == Int diff --git a/test/subarray.jl b/test/subarray.jl index 26204738c0300..9df96e9ccce8b 100644 --- a/test/subarray.jl +++ b/test/subarray.jl @@ -38,7 +38,7 @@ _Agen(A, i1, i2, i3) = [A[j1,j2,j3] for j1 in i1, j2 in i2, j3 in i3] _Agen(A, i1, i2, i3, i4) = [A[j1,j2,j3,j4] for j1 in i1, j2 in i2, j3 in i3, j4 in i4] function replace_colon(A::AbstractArray, I) - Iout = Array(Any, length(I)) + Iout = Array{Any}(length(I)) for d = 1:length(I)-1 Iout[d] = isa(I[d], Colon) ? (1:size(A,d)) : I[d] end @@ -51,7 +51,7 @@ end # it's good to copy the contents to an Array. This version protects against # `similar` ever changing its meaning. function copy_to_array(A::AbstractArray) - Ac = Array(eltype(A), size(A)) + Ac = Array{eltype(A)}(size(A)) copy!(Ac, A) end diff --git a/test/threads.jl b/test/threads.jl index a2083a13224d1..d2130690c5a70 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -47,8 +47,8 @@ function test_threaded_atomic_minmax{T}(m::T,n::T) mid = m + (n-m)>>1 x = Atomic{T}(mid) y = Atomic{T}(mid) - oldx = Array(T,n-m+1) - oldy = Array(T,n-m+1) + oldx = Array{T}(n-m+1) + oldy = Array{T}(n-m+1) @threads for i = m:n oldx[i-m+1] = atomic_min!(x, T(i)) oldy[i-m+1] = atomic_max!(y, T(i)) diff --git a/test/unicode/utf32.jl b/test/unicode/utf32.jl index dba0c4922a48f..875c22330749d 100644 --- a/test/unicode/utf32.jl +++ b/test/unicode/utf32.jl @@ -8,7 +8,7 @@ u32 = utf32(u8) @test length(u32) == 5 @test String(u32) == u8 @test collect(u8) == collect(u32) -@test u8 == utf32(u32.data[1:end-1]) == utf32(copy!(Array(UInt8, 20), 1, reinterpret(UInt8, u32.data), 1, 20)) +@test u8 == utf32(u32.data[1:end-1]) == utf32(copy!(Array{UInt8}(20), 1, reinterpret(UInt8, u32.data), 1, 20)) @test u8 == utf32(pointer(u32)) == utf32(convert(Ptr{Int32}, pointer(u32))) @test_throws UnicodeError utf32(UInt8[1,2,3])