From 41de7be9f629b7f5e9bf474883762da64400820a Mon Sep 17 00:00:00 2001 From: Jarrett Revels Date: Sat, 14 Jan 2017 15:12:46 -0500 Subject: [PATCH] Array(T, dims...) to Array{T}(dims...) (ref JuliaLang/julia#19989) (#59) --- src/array/cat.jl | 8 ++++---- src/broadcast/BroadcastBenchmarks.jl | 2 +- src/misc/MiscellaneousBenchmarks.jl | 4 ++-- src/nullable/NullableBenchmarks.jl | 6 +++--- src/parallel/Laplace3D.jl | 8 ++++---- src/parallel/LatticeBoltzmann.jl | 20 ++++++++++---------- src/parallel/ThreadedStockCorr.jl | 6 +++--- src/problem/Ziggurat.jl | 2 +- src/shootout/fannkuch.jl | 2 +- src/shootout/fasta.jl | 2 +- src/shootout/k_nucleotide.jl | 2 +- src/shootout/meteor_contest.jl | 2 +- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/array/cat.jl b/src/array/cat.jl index cdfb00b6..e80dc56e 100644 --- a/src/array/cat.jl +++ b/src/array/cat.jl @@ -5,7 +5,7 @@ perf_hvcat(A, B) = [A B; B A] function perf_hvcat_setind(A, B) @assert issquare(A) && size(A) == size(B) n = size(A, 1) - C = Array(Float64, 2n, 2n) + C = Matrix{Float64}(2n, 2n) C[1:n, 1:n] = A C[1:n, (n+1):end] = B C[(n+1):end, 1:n] = B @@ -17,7 +17,7 @@ perf_hcat(A, B) = [A B B A] function perf_hcat_setind(A, B) @assert issquare(A) && size(A) == size(B) n = size(A, 1) - C = Array(Float64, n, 4n) + C = Matrix{Float64}(n, 4n) C[:, 1:n] = A C[:, (n+1):2n] = B C[:, (2n+1):3n] = B @@ -30,7 +30,7 @@ perf_vcat(A, B) = [A; B; B; A] function perf_vcat_setind(A, B) @assert issquare(A) && size(A) == size(B) n = size(A, 1) - C = Array(Float64, 4n, n) + C = Matrix{Float64}(4n, n) C[1:n, :] = A C[(n+1):2n, :] = B C[(2n+1):3n, :] = B @@ -47,7 +47,7 @@ end function perf_catnd_setind(n) A = samerand(1, n, n, 1) B = samerand(1, n, n) - 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 diff --git a/src/broadcast/BroadcastBenchmarks.jl b/src/broadcast/BroadcastBenchmarks.jl index 653ff9be..249840a0 100644 --- a/src/broadcast/BroadcastBenchmarks.jl +++ b/src/broadcast/BroadcastBenchmarks.jl @@ -22,7 +22,7 @@ x = randvec(10^3) y = randvec(10^3)' z = randvec(10^6) X = randmat(10^3) -R = Array(Float64, length(x),length(y)) +R = Matrix{Float64}(length(x), length(y)) r = similar(z) g["Float64", size(r), 1] = @benchmarkable perf_bcast!($r, $z) diff --git a/src/misc/MiscellaneousBenchmarks.jl b/src/misc/MiscellaneousBenchmarks.jl index 92e38933..150294f6 100644 --- a/src/misc/MiscellaneousBenchmarks.jl +++ b/src/misc/MiscellaneousBenchmarks.jl @@ -85,8 +85,8 @@ end g = addgroup!(SUITE, "parse", ["DateTime"]) datestr = map(string,range(DateTime("2016-02-19T12:34:56"),Dates.Millisecond(123),200)) g["DateTime"] = @benchmarkable perf_parse($(similar(datestr, DateTime)), $datestr) -g["Int"] = @benchmarkable perf_parse($(Array(Int,1000)), $(map(string, 1:1000))) -g["Float64"] = @benchmarkable perf_parse($(Array(Float64,1000)), $(map(string, 1:1000))) +g["Int"] = @benchmarkable perf_parse($(Vector{Int}(1000)), $(map(string, 1:1000))) +g["Float64"] = @benchmarkable perf_parse($(Vector{Float64}(1000)), $(map(string, 1:1000))) ########################################################################### diff --git a/src/nullable/NullableBenchmarks.jl b/src/nullable/NullableBenchmarks.jl index e59f7d17..6f8b2672 100644 --- a/src/nullable/NullableBenchmarks.jl +++ b/src/nullable/NullableBenchmarks.jl @@ -92,8 +92,8 @@ for T in (Bool, Int8, Int64, Float32, Float64, BigInt, BigFloat, Complex{Float64 end # 10% of missing values - X = NullableArray(Array{T}(samerand(S, VEC_LENGTH)), Array(samerand(VEC_LENGTH) .> .9)) - Y = NullableArray(Array{T}(samerand(S, VEC_LENGTH)), Array(samerand(VEC_LENGTH) .> .9)) + X = NullableArray(Vector{T}(samerand(S, VEC_LENGTH)), Vector{Bool}(samerand(VEC_LENGTH) .> .9)) + Y = NullableArray(Vector{T}(samerand(S, VEC_LENGTH)), Vector{Bool}(samerand(VEC_LENGTH) .> .9)) for (A, X, Y) in (("NullableArray", X, Y), ("Array", collect(X), collect(Y))) g["perf_sum", A, string(T)] = @benchmarkable perf_sum($X) @@ -129,7 +129,7 @@ end # Ensure no short-circuit happens X = NullableArray(fill(true, VEC_LENGTH), fill(true, VEC_LENGTH)) # 10% of missing values -Y = NullableArray(fill(false, VEC_LENGTH), Array(samerand(VEC_LENGTH) .> .1)) +Y = NullableArray(fill(false, VEC_LENGTH), Vector{Bool}(samerand(VEC_LENGTH) .> .1)) g["perf_all", "NullableArray"] = @benchmarkable perf_all($X) g["perf_any", "NullableArray"] = @benchmarkable perf_any($Y) diff --git a/src/parallel/Laplace3D.jl b/src/parallel/Laplace3D.jl index abd28f02..9ee346fd 100644 --- a/src/parallel/Laplace3D.jl +++ b/src/parallel/Laplace3D.jl @@ -62,8 +62,8 @@ function l3d_threadfor(u1, u3, nx, ny, nz) end function perf_laplace3d(nx=290, ny=290, nz=290; verify=false) - u1 = Array(Float32, nx, ny, nz) - u3 = Array(Float32, nx, ny, nz) + u1 = Array{Float32,3}(nx, ny, nz) + u3 = Array{Float32,3}(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 @@ -73,8 +73,8 @@ function perf_laplace3d(nx=290, ny=290, nz=290; verify=false) end l3d_threadfor(u1, u3, nx, ny, nz) if verify - u1_orig = Array(Float32, nx, ny, nz) - u3_orig = Array(Float32, nx, ny, nz) + u1_orig = Array{Float32,3}(nx, ny, nz) + u3_orig = Array{Float32,3}(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 diff --git a/src/parallel/LatticeBoltzmann.jl b/src/parallel/LatticeBoltzmann.jl index b50d9aaa..11d755b8 100644 --- a/src/parallel/LatticeBoltzmann.jl +++ b/src/parallel/LatticeBoltzmann.jl @@ -42,7 +42,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 = Vector{Float64}(6) for l = 1:6 fs[l] = 0.0 for m = 1:5 @@ -135,7 +135,7 @@ function perf_lattice_boltzmann(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 @@ -149,14 +149,14 @@ function perf_lattice_boltzmann(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 = Matrix{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 diff --git a/src/parallel/ThreadedStockCorr.jl b/src/parallel/ThreadedStockCorr.jl index 5f0986e9..53ae31bc 100644 --- a/src/parallel/ThreadedStockCorr.jl +++ b/src/parallel/ThreadedStockCorr.jl @@ -40,8 +40,8 @@ function perf_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 = Matrix{Float64}(T-1, 2) + CorrWiener = Matrix{Float64}(T-1, 2) # Runtime requirement: need per-thread RNG since it stores state rngs = [MersenneTwister(777+x) for x in 1:nthreads()] @@ -58,4 +58,4 @@ function perf_pstockcorr(n) return (SimulPriceA, SimulPriceB) end -end # module \ No newline at end of file +end # module diff --git a/src/problem/Ziggurat.jl b/src/problem/Ziggurat.jl index 613e77a4..912ca19b 100644 --- a/src/problem/Ziggurat.jl +++ b/src/problem/Ziggurat.jl @@ -143,7 +143,7 @@ end randn_zig(sigma::Number) = sigma*randn_zig() function perf_ziggurat(n) - A = Array(Float64, n) + A = Vector{Float64}(n) for i=1:length(A) A[i] = randn_zig() end diff --git a/src/shootout/fannkuch.jl b/src/shootout/fannkuch.jl index 119c7b22..98bab704 100644 --- a/src/shootout/fannkuch.jl +++ b/src/shootout/fannkuch.jl @@ -5,7 +5,7 @@ # Based on the Javascript program function perf_fannkuch(n) - p = Array(Int32,n) + p = Vector{Int32}(n) for i = 1:n p[i] = i end diff --git a/src/shootout/fasta.jl b/src/shootout/fasta.jl index 04e76eed..dbc5434c 100644 --- a/src/shootout/fasta.jl +++ b/src/shootout/fasta.jl @@ -43,7 +43,7 @@ end function random_fasta(symb, pr, n) cs = cumsum(pr) - line = Array(UInt8, line_width) + line = Vector{UInt8}(line_width) k = n while k > 0 m = min(k, line_width) diff --git a/src/shootout/k_nucleotide.jl b/src/shootout/k_nucleotide.jl index 5fd7e29b..e68440be 100644 --- a/src/shootout/k_nucleotide.jl +++ b/src/shootout/k_nucleotide.jl @@ -38,7 +38,7 @@ function isless(x::KNuc, y::KNuc) end function sorted_array(m::Dict{AbstractString, Int}) - kn = Array(KNuc, length(m)) + kn = Vector{KNuc}(length(m)) i = 1 for elem in m kn[i] = KNuc(elem...) diff --git a/src/shootout/meteor_contest.jl b/src/shootout/meteor_contest.jl index 11288237..b9633bfa 100644 --- a/src/shootout/meteor_contest.jl +++ b/src/shootout/meteor_contest.jl @@ -42,7 +42,7 @@ const pieces = ( const solutions = Any[] const masks = zeros(UInt64, 10) -const masksAtCell = Array(Any, width*height, height) +const masksAtCell = Matrix{Any}(width*height, height) valid(x, y) = (0 <= x < width) && (0 <= y < height) legal(mask::UInt64, board::UInt64) = (mask & board) == 0