Skip to content

Commit

Permalink
Additional changes from Array(T, dim) to Array{T}(dim).
Browse files Browse the repository at this point in the history
  • Loading branch information
pkofod committed May 25, 2016
1 parent 106f483 commit 68d6eb8
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 27 deletions.
22 changes: 11 additions & 11 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/grisu/bignums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/iostream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function read(s::IOStream, nb::Integer; all::Bool=true)
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)
Expand Down
2 changes: 1 addition & 1 deletion base/libgit2/reference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions base/linalg/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand Down
12 changes: 6 additions & 6 deletions base/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
iwork = Array{BlasInt}(3*n)
info = Ref{BlasInt}()
ccall((@blasfunc($stebz), liblapack), Void,
(Ptr{UInt8}, Ptr{UInt8}, Ptr{BlasInt}, Ptr{$elty},
Expand Down Expand Up @@ -3743,8 +3743,8 @@ for (stev, stebz, stegr, stein, elty) in
end
z = similar(dv, $elty,(n,m))
work = Array{$elty}(5*n)
iwork = Array(BlasInt,n)
ifail = Array(BlasInt,m)
iwork = Array{BlasInt}(n)
ifail = Array{BlasInt}(m)
info = Ref{BlasInt}()
ccall((@blasfunc($stein), liblapack), Void,
(Ptr{BlasInt}, Ptr{$elty}, Ptr{$elty}, Ptr{BlasInt},
Expand Down Expand Up @@ -5038,7 +5038,7 @@ for (syev, syevr, sygvd, elty, relty) in
lwork = 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
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion base/subarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 68d6eb8

Please sign in to comment.