Skip to content

Commit 6f1e0c6

Browse files
committed
Deprecate manually vectorized big methods in favor of compact broadcast syntax.
1 parent 44d7677 commit 6f1e0c6

15 files changed

+48
-28
lines changed

base/complex.jl

-3
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,6 @@ function complex{T}(A::AbstractArray{T})
864864
convert(AbstractArray{typeof(complex(zero(T)))}, A)
865865
end
866866

867-
big{T<:Integer,N}(A::AbstractArray{Complex{T},N}) = convert(AbstractArray{Complex{BigInt},N}, A)
868-
big{T<:AbstractFloat,N}(A::AbstractArray{Complex{T},N}) = convert(AbstractArray{Complex{BigFloat},N}, A)
869-
870867
## promotion to complex ##
871868

872869
_default_type(T::Type{Complex}) = Complex{Int}

base/deprecated.jl

+16
Original file line numberDiff line numberDiff line change
@@ -1168,4 +1168,20 @@ for (dep, f, op) in [(:sumabs!, :sum!, :abs),
11681168
end
11691169
end
11701170

1171+
# Deprecate manually vectorized `big` methods in favor of compact broadcast syntax
1172+
@deprecate big(r::UnitRange) big.(r)
1173+
@deprecate big(r::StepRange) big.(r)
1174+
@deprecate big(r::FloatRange) big.(r)
1175+
@deprecate big(r::LinSpace) big.(r)
1176+
@deprecate big{T<:Integer,N}(x::AbstractArray{T,N}) big.(x)
1177+
@deprecate big{T<:AbstractFloat,N}(x::AbstractArray{T,N}) big.(x)
1178+
@deprecate big(A::LowerTriangular) big.(A)
1179+
@deprecate big(A::UpperTriangular) big.(A)
1180+
@deprecate big(A::Base.LinAlg.UnitLowerTriangular) big.(A)
1181+
@deprecate big(A::Base.LinAlg.UnitUpperTriangular) big.(A)
1182+
@deprecate big(B::Bidiagonal) big.(B)
1183+
@deprecate big{T<:Integer,N}(A::AbstractArray{Complex{T},N}) big.(A)
1184+
@deprecate big{T<:AbstractFloat,N}(A::AbstractArray{Complex{T},N}) big.(A)
1185+
@deprecate big{T<:Integer,N}(x::AbstractArray{Complex{Rational{T}},N}) big.(A)
1186+
11711187
# End deprecations scheduled for 0.6

base/float.jl

+11-3
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ function float{T}(A::AbstractArray{T})
735735
convert(AbstractArray{typeof(float(zero(T)))}, A)
736736
end
737737

738-
for fn in (:float,:big)
738+
for fn in (:float,)
739739
@eval begin
740740
$fn(r::StepRange) = $fn(r.start):$fn(r.step):$fn(last(r))
741741
$fn(r::UnitRange) = $fn(r.start):$fn(last(r))
@@ -748,5 +748,13 @@ for fn in (:float,:big)
748748
end
749749
end
750750

751-
big{T<:AbstractFloat,N}(x::AbstractArray{T,N}) = convert(AbstractArray{BigFloat,N}, x)
752-
big{T<:Integer,N}(x::AbstractArray{T,N}) = convert(AbstractArray{BigInt,N}, x)
751+
# big, broadcast over arrays
752+
# TODO: do the definitions below primarily pertaining to integers belong in float.jl?
753+
function big end # no prior definitions of big in sysimg.jl, necessitating this
754+
broadcast(::typeof(big), r::UnitRange) = big(r.start):big(last(r))
755+
broadcast(::typeof(big), r::StepRange) = big(r.start):big(r.step):big(last(r))
756+
broadcast(::typeof(big), r::FloatRange) = FloatRange(big(r.start), big(r.step), r.len, big(r.divisor))
757+
function broadcast(::typeof(big), r::LinSpace)
758+
big(r.len) == r.len || throw(ArgumentError(string(r, ": too long for ", big)))
759+
LinSpace(big(r.start), big(r.stop), big(r.len), big(r.divisor))
760+
end

base/linalg/bidiag.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ convert{Tnew,Told}(::Type{Bidiagonal{Tnew}}, A::Bidiagonal{Told}) = Bidiagonal(c
211211
# When asked to convert Bidiagonal{Told} to AbstractMatrix{Tnew}, preserve structure by converting to Bidiagonal{Tnew} <: AbstractMatrix{Tnew}
212212
convert{Tnew,Told}(::Type{AbstractMatrix{Tnew}}, A::Bidiagonal{Told}) = convert(Bidiagonal{Tnew}, A)
213213

214-
big(B::Bidiagonal) = Bidiagonal(big(B.dv), big(B.ev), B.isupper)
214+
broadcast(::typeof(big), B::Bidiagonal) = Bidiagonal(big.(B.dv), big.(B.ev), B.isupper)
215215

216216
similar{T}(B::Bidiagonal, ::Type{T}) = Bidiagonal{T}(similar(B.dv, T), similar(B.ev, T), B.isupper)
217217

base/linalg/triangular.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ for t in (:LowerTriangular, :UnitLowerTriangular, :UpperTriangular,
3232

3333
copy(A::$t) = $t(copy(A.data))
3434

35-
big(A::$t) = $t(big(A.data))
35+
broadcast(::typeof(big), A::$t) = $t(big.(A.data))
3636

3737
real{T<:Real}(A::$t{T}) = A
3838
real{T<:Complex}(A::$t{T}) = (B = real(A.data); $t(B))

base/rational.jl

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ convert(::Type{Rational}, x::Float64) = convert(Rational{Int64}, x)
8080
convert(::Type{Rational}, x::Float32) = convert(Rational{Int}, x)
8181

8282
big{T<:Integer}(z::Complex{Rational{T}}) = Complex{Rational{BigInt}}(z)
83-
big{T<:Integer,N}(x::AbstractArray{Complex{Rational{T}},N}) = convert(AbstractArray{Complex{Rational{BigInt}},N}, x)
8483

8584
promote_rule{T<:Integer,S<:Integer}(::Type{Rational{T}}, ::Type{S}) = Rational{promote_type(T,S)}
8685
promote_rule{T<:Integer,S<:Integer}(::Type{Rational{T}}, ::Type{Rational{S}}) = Rational{promote_type(T,S)}

test/bigint.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,10 @@ ndigits_mismatch(n) = ndigits(n) != ndigits(BigInt(n))
275275
@test !any(ndigits_mismatch, 8192:9999)
276276

277277
# The following should not crash (#16579)
278-
ndigits(rand(big(-999:999)), rand(63:typemax(Int)))
279-
ndigits(rand(big(-999:999)), big(2)^rand(2:999))
278+
ndigits(rand(big.(-999:999)), rand(63:typemax(Int)))
279+
ndigits(rand(big.(-999:999)), big(2)^rand(2:999))
280280

281-
for i in big([-20:-1;1:20])
281+
for i in big.([-20:-1;1:20])
282282
for b in -10:1
283283
@test_throws DomainError ndigits(i, b)
284284
end

test/linalg/arnoldi.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ end
236236
eigs(rand(1:10, 10, 10))
237237
eigs(rand(1:10, 10, 10), rand(1:10, 10, 10) |> t -> t't)
238238
svds(rand(1:10, 10, 8))
239-
@test_throws MethodError eigs(big(rand(1:10, 10, 10)))
240-
@test_throws MethodError eigs(big(rand(1:10, 10, 10)), rand(1:10, 10, 10))
241-
@test_throws MethodError svds(big(rand(1:10, 10, 8)))
239+
@test_throws MethodError eigs(big.(rand(1:10, 10, 10)))
240+
@test_throws MethodError eigs(big.(rand(1:10, 10, 10)), rand(1:10, 10, 10))
241+
@test_throws MethodError svds(big.(rand(1:10, 10, 8)))
242242
end
243243

244244
# Symmetric generalized with singular B

test/linalg/bidiag.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ srand(1)
6363
@test size(T) == (n, n)
6464
@test Array(T) == diagm(dv) + diagm(ev, isupper?1:-1)
6565
@test Bidiagonal(Array(T), isupper) == T
66-
@test big(T) == T
66+
@test big.(T) == T
6767
@test Array(abs.(T)) == abs.(diagm(dv)) + abs.(diagm(ev, isupper?1:-1))
6868
@test Array(real(T)) == real(diagm(dv)) + real(diagm(ev, isupper?1:-1))
6969
@test Array(imag(T)) == imag(diagm(dv)) + imag(diagm(ev, isupper?1:-1))

test/linalg/generic.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ end
235235
@test !issymmetric(NaN)
236236

237237
@test rank([1.0 0.0; 0.0 0.9],0.95) == 1
238-
@test qr(big([0 1; 0 0]))[2] == [0 1; 0 0]
238+
@test qr(big.([0 1; 0 0]))[2] == [0 1; 0 0]
239239

240240
@test norm([2.4e-322, 4.4e-323]) 2.47e-322
241241
@test norm([2.4e-322, 4.4e-323], 3) 2.4e-322

test/linalg/qr.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ end
148148
@test_throws ErrorException ctranspose(qrfact(randn(3,3)))
149149
@test_throws ErrorException transpose(qrfact(randn(3,3), Val{false}))
150150
@test_throws ErrorException ctranspose(qrfact(randn(3,3), Val{false}))
151-
@test_throws ErrorException transpose(qrfact(big(randn(3,3))))
152-
@test_throws ErrorException ctranspose(qrfact(big(randn(3,3))))
151+
@test_throws ErrorException transpose(qrfact(big.(randn(3,3))))
152+
@test_throws ErrorException ctranspose(qrfact(big.(randn(3,3))))
153153

154154
# Issue 7304
155155
let

test/linalg/triangular.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int)
417417
x = Atri \ b
418418
γ = n*ε/(1 - n*ε)
419419
if eltya != BigFloat
420-
bigA = big(Atri)
420+
bigA = big.(Atri)
421421
= ones(n, 2)
422422
for i = 1:size(b, 2)
423423
@test norm(x̂[:,i] - x[:,i], Inf)/norm(x̂[:,i], Inf) <= condskeel(bigA, x̂[:,i])*γ/(1 - condskeel(bigA)*γ)
@@ -446,7 +446,7 @@ for eltya in (Float32, Float64, Complex64, Complex128, BigFloat, Int)
446446
x = Atri \ b
447447
γ = n*ε/(1 - n*ε)
448448
if eltya != BigFloat
449-
bigA = big(Atri)
449+
bigA = big.(Atri)
450450
= ones(n, 2)
451451
for i = 1:size(b, 2)
452452
@test norm(x̂[:,i] - x[:,i], Inf)/norm(x̂[:,i], Inf) <= condskeel(bigA, x̂[:,i])*γ/(1 - condskeel(bigA)*γ)

test/numbers.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -2624,8 +2624,8 @@ end
26242624
for (d,B) in ((4//2+1im,Rational{BigInt}),(3.0+1im,BigFloat),(2+1im,BigInt))
26252625
@test typeof(big(d)) == Complex{B}
26262626
@test big(d) == d
2627-
@test typeof(big([d])) == Vector{Complex{B}}
2628-
@test big([d]) == [d]
2627+
@test typeof(big.([d])) == Vector{Complex{B}}
2628+
@test big.([d]) == [d]
26292629
end
26302630

26312631
# issue #12536

test/random.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ ke = Array{UInt64}(ziggurat_table_size)
133133
we = Array{Float64}(ziggurat_table_size)
134134
fe = Array{Float64}(ziggurat_table_size)
135135
function randmtzig_fill_ziggurat_tables() # Operates on the global arrays
136-
wib = big(wi)
137-
fib = big(fi)
138-
web = big(we)
139-
feb = big(fe)
136+
wib = big.(wi)
137+
fib = big.(fi)
138+
web = big.(we)
139+
feb = big.(fe)
140140
# Ziggurat tables for the normal distribution
141141
x1 = ziggurat_nor_r
142142
wib[256] = x1/nmantissa

test/ranges.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ test_linspace_identity(linspace(1f0, 1f0, 1), linspace(-1f0, -1f0, 1))
663663
for _r in (1:2:100, 1:100, 1f0:2f0:100f0, 1.0:2.0:100.0,
664664
linspace(1, 100, 10), linspace(1f0, 100f0, 10))
665665
float_r = float(_r)
666-
big_r = big(_r)
666+
big_r = big.(_r)
667667
@test typeof(big_r).name === typeof(_r).name
668668
if eltype(_r) <: AbstractFloat
669669
@test isa(float_r, typeof(_r))

0 commit comments

Comments
 (0)