Skip to content

Commit 41de7be

Browse files
authored
Array(T, dims...) to Array{T}(dims...) (ref JuliaLang/julia#19989) (#59)
1 parent 5592f4b commit 41de7be

12 files changed

+32
-32
lines changed

src/array/cat.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ perf_hvcat(A, B) = [A B; B A]
55
function perf_hvcat_setind(A, B)
66
@assert issquare(A) && size(A) == size(B)
77
n = size(A, 1)
8-
C = Array(Float64, 2n, 2n)
8+
C = Matrix{Float64}(2n, 2n)
99
C[1:n, 1:n] = A
1010
C[1:n, (n+1):end] = B
1111
C[(n+1):end, 1:n] = B
@@ -17,7 +17,7 @@ perf_hcat(A, B) = [A B B A]
1717
function perf_hcat_setind(A, B)
1818
@assert issquare(A) && size(A) == size(B)
1919
n = size(A, 1)
20-
C = Array(Float64, n, 4n)
20+
C = Matrix{Float64}(n, 4n)
2121
C[:, 1:n] = A
2222
C[:, (n+1):2n] = B
2323
C[:, (2n+1):3n] = B
@@ -30,7 +30,7 @@ perf_vcat(A, B) = [A; B; B; A]
3030
function perf_vcat_setind(A, B)
3131
@assert issquare(A) && size(A) == size(B)
3232
n = size(A, 1)
33-
C = Array(Float64, 4n, n)
33+
C = Matrix{Float64}(4n, n)
3434
C[1:n, :] = A
3535
C[(n+1):2n, :] = B
3636
C[(2n+1):3n, :] = B
@@ -47,7 +47,7 @@ end
4747
function perf_catnd_setind(n)
4848
A = samerand(1, n, n, 1)
4949
B = samerand(1, n, n)
50-
C = Array(Float64, 1, n, 4n, 1)
50+
C = Array{Float64}(1, n, 4n, 1)
5151
C[1, :, 1:n, 1] = A
5252
C[1, :, (n+1):2n, 1] = B
5353
C[1, :, (2n+1):3n, 1] = B

src/broadcast/BroadcastBenchmarks.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ x = randvec(10^3)
2222
y = randvec(10^3)'
2323
z = randvec(10^6)
2424
X = randmat(10^3)
25-
R = Array(Float64, length(x),length(y))
25+
R = Matrix{Float64}(length(x), length(y))
2626
r = similar(z)
2727

2828
g["Float64", size(r), 1] = @benchmarkable perf_bcast!($r, $z)

src/misc/MiscellaneousBenchmarks.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ end
8585
g = addgroup!(SUITE, "parse", ["DateTime"])
8686
datestr = map(string,range(DateTime("2016-02-19T12:34:56"),Dates.Millisecond(123),200))
8787
g["DateTime"] = @benchmarkable perf_parse($(similar(datestr, DateTime)), $datestr)
88-
g["Int"] = @benchmarkable perf_parse($(Array(Int,1000)), $(map(string, 1:1000)))
89-
g["Float64"] = @benchmarkable perf_parse($(Array(Float64,1000)), $(map(string, 1:1000)))
88+
g["Int"] = @benchmarkable perf_parse($(Vector{Int}(1000)), $(map(string, 1:1000)))
89+
g["Float64"] = @benchmarkable perf_parse($(Vector{Float64}(1000)), $(map(string, 1:1000)))
9090

9191
###########################################################################
9292

src/nullable/NullableBenchmarks.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ for T in (Bool, Int8, Int64, Float32, Float64, BigInt, BigFloat, Complex{Float64
9292
end
9393

9494
# 10% of missing values
95-
X = NullableArray(Array{T}(samerand(S, VEC_LENGTH)), Array(samerand(VEC_LENGTH) .> .9))
96-
Y = NullableArray(Array{T}(samerand(S, VEC_LENGTH)), Array(samerand(VEC_LENGTH) .> .9))
95+
X = NullableArray(Vector{T}(samerand(S, VEC_LENGTH)), Vector{Bool}(samerand(VEC_LENGTH) .> .9))
96+
Y = NullableArray(Vector{T}(samerand(S, VEC_LENGTH)), Vector{Bool}(samerand(VEC_LENGTH) .> .9))
9797

9898
for (A, X, Y) in (("NullableArray", X, Y), ("Array", collect(X), collect(Y)))
9999
g["perf_sum", A, string(T)] = @benchmarkable perf_sum($X)
@@ -129,7 +129,7 @@ end
129129
# Ensure no short-circuit happens
130130
X = NullableArray(fill(true, VEC_LENGTH), fill(true, VEC_LENGTH))
131131
# 10% of missing values
132-
Y = NullableArray(fill(false, VEC_LENGTH), Array(samerand(VEC_LENGTH) .> .1))
132+
Y = NullableArray(fill(false, VEC_LENGTH), Vector{Bool}(samerand(VEC_LENGTH) .> .1))
133133

134134
g["perf_all", "NullableArray"] = @benchmarkable perf_all($X)
135135
g["perf_any", "NullableArray"] = @benchmarkable perf_any($Y)

src/parallel/Laplace3D.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ function l3d_threadfor(u1, u3, nx, ny, nz)
6262
end
6363

6464
function perf_laplace3d(nx=290, ny=290, nz=290; verify=false)
65-
u1 = Array(Float32, nx, ny, nz)
66-
u3 = Array(Float32, nx, ny, nz)
65+
u1 = Array{Float32,3}(nx, ny, nz)
66+
u3 = Array{Float32,3}(nx, ny, nz)
6767
@nloops 3 k u1 begin
6868
if @nany 3 d->(k_d == 1 || k_d == size(u1, d))
6969
(@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)
7373
end
7474
l3d_threadfor(u1, u3, nx, ny, nz)
7575
if verify
76-
u1_orig = Array(Float32, nx, ny, nz)
77-
u3_orig = Array(Float32, nx, ny, nz)
76+
u1_orig = Array{Float32,3}(nx, ny, nz)
77+
u3_orig = Array{Float32,3}(nx, ny, nz)
7878
@nloops 3 k u1_orig begin
7979
if @nany 3 d->(k_d == 1 || k_d == size(u1_orig, d))
8080
(@nref 3 u3_orig k) = (@nref 3 u1_orig k) = 1.0

src/parallel/LatticeBoltzmann.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function relax!(F, UX, UY, UZ, nx, ny, nz, deltaU, t1D, t2D, t3D, sSQU, chunkid,
4242
for l = 1:size(F,4)
4343
density = density + F[i,j,k,l]
4444
end
45-
fs = Array(Float64, 6)
45+
fs = Vector{Float64}(6)
4646
for l = 1:6
4747
fs[l] = 0.0
4848
for m = 1:5
@@ -135,7 +135,7 @@ function perf_lattice_boltzmann(n)
135135

136136
CI = [0:matsize:matsize*19;]'
137137

138-
BOUND = Array(Float64,nx,ny,nz)
138+
BOUND = Array{Float64}(nx, ny, nz)
139139

140140
for i=1:nx, j=1:ny, k=1:nz
141141
BOUND[i,j,k] = ((i-5)^2 + (j-6)^2 + (k-7)^2) < 6
@@ -149,14 +149,14 @@ function perf_lattice_boltzmann(n)
149149
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]]
150150
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]]
151151

152-
UX = Array(Float64,nx,ny,nz)
153-
UY = Array(Float64,nx,ny,nz)
154-
UZ = Array(Float64,nx,ny,nz)
155-
U = Array(Float64,12,nchunk)
156-
t1D = Array(Float64,nx,ny,nz)
157-
t2D = Array(Float64,nx,ny,nz)
158-
t3D = Array(Float64,nx,ny,nz)
159-
sSQU = Array(Float64,nx,ny,nz)
152+
UX = Array{Float64}(nx, ny, nz)
153+
UY = Array{Float64}(nx, ny, nz)
154+
UZ = Array{Float64}(nx, ny, nz)
155+
U = Matrix{Float64}(12, nchunk)
156+
t1D = Array{Float64}(nx, ny, nz)
157+
t2D = Array{Float64}(nx, ny, nz)
158+
t3D = Array{Float64}(nx, ny, nz)
159+
sSQU = Array{Float64}(nx, ny, nz)
160160

161161
avu = 1
162162
prevavu = 1

src/parallel/ThreadedStockCorr.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ function perf_pstockcorr(n)
4040
# Optimization: pre-allocate these for performance
4141
# NOTE: the new GC will hopefully fix this, but currently GC time
4242
# kills performance if we don't do in-place computations
43-
Wiener = Array(Float64, T-1, 2)
44-
CorrWiener = Array(Float64, T-1, 2)
43+
Wiener = Matrix{Float64}(T-1, 2)
44+
CorrWiener = Matrix{Float64}(T-1, 2)
4545

4646
# Runtime requirement: need per-thread RNG since it stores state
4747
rngs = [MersenneTwister(777+x) for x in 1:nthreads()]
@@ -58,4 +58,4 @@ function perf_pstockcorr(n)
5858
return (SimulPriceA, SimulPriceB)
5959
end
6060

61-
end # module
61+
end # module

src/problem/Ziggurat.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ end
143143
randn_zig(sigma::Number) = sigma*randn_zig()
144144

145145
function perf_ziggurat(n)
146-
A = Array(Float64, n)
146+
A = Vector{Float64}(n)
147147
for i=1:length(A)
148148
A[i] = randn_zig()
149149
end

src/shootout/fannkuch.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Based on the Javascript program
66

77
function perf_fannkuch(n)
8-
p = Array(Int32,n)
8+
p = Vector{Int32}(n)
99
for i = 1:n
1010
p[i] = i
1111
end

src/shootout/fasta.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ end
4343

4444
function random_fasta(symb, pr, n)
4545
cs = cumsum(pr)
46-
line = Array(UInt8, line_width)
46+
line = Vector{UInt8}(line_width)
4747
k = n
4848
while k > 0
4949
m = min(k, line_width)

src/shootout/k_nucleotide.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function isless(x::KNuc, y::KNuc)
3838
end
3939

4040
function sorted_array(m::Dict{AbstractString, Int})
41-
kn = Array(KNuc, length(m))
41+
kn = Vector{KNuc}(length(m))
4242
i = 1
4343
for elem in m
4444
kn[i] = KNuc(elem...)

src/shootout/meteor_contest.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const pieces = (
4242

4343
const solutions = Any[]
4444
const masks = zeros(UInt64, 10)
45-
const masksAtCell = Array(Any, width*height, height)
45+
const masksAtCell = Matrix{Any}(width*height, height)
4646

4747
valid(x, y) = (0 <= x < width) && (0 <= y < height)
4848
legal(mask::UInt64, board::UInt64) = (mask & board) == 0

0 commit comments

Comments
 (0)