Skip to content

Commit

Permalink
Array(T, dims...) to Array{T}(dims...) (ref JuliaLang/julia#19989)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrevels committed Jan 14, 2017
1 parent 5592f4b commit 7c0f31d
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions src/array/cat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/broadcast/BroadcastBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/misc/MiscellaneousBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

###########################################################################

Expand Down
6 changes: 3 additions & 3 deletions src/nullable/NullableBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/parallel/Laplace3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/parallel/LatticeBoltzmann.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/parallel/ThreadedStockCorr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand All @@ -58,4 +58,4 @@ function perf_pstockcorr(n)
return (SimulPriceA, SimulPriceB)
end

end # module
end # module
2 changes: 1 addition & 1 deletion src/problem/Ziggurat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/shootout/fannkuch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/shootout/fasta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/shootout/k_nucleotide.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
2 changes: 1 addition & 1 deletion src/shootout/meteor_contest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7c0f31d

Please sign in to comment.