Skip to content

Commit ee7769a

Browse files
committed
Deprecate manually vectorized real methods in favor of compact broadcast syntax.
1 parent 155147e commit ee7769a

26 files changed

+60
-42
lines changed

base/abstractarraymath.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ squeeze(A::AbstractArray, dim::Integer) = squeeze(A, (Int(dim),))
8585
conj{T<:Real}(x::AbstractArray{T}) = x
8686
conj!{T<:Real}(x::AbstractArray{T}) = x
8787

88-
real{T<:Real}(x::AbstractArray{T}) = x
88+
broadcast{T<:Real}(::typeof(real), x::AbstractArray{T}) = x
8989
imag{T<:Real}(x::AbstractArray{T}) = zero(x)
9090

9191
+{T<:Number}(x::AbstractArray{T}) = x

base/arraymath.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ end
3030

3131
(-)(A::AbstractArray{Bool}) = reshape([ -A[i] for i in eachindex(A) ], size(A))
3232

33-
real(A::AbstractArray) = reshape([ real(x) for x in A ], size(A))
3433
imag(A::AbstractArray) = reshape([ imag(x) for x in A ], size(A))
3534

3635
function !(A::AbstractArray{Bool})

base/broadcast.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module Broadcast
55
using Base.Cartesian
66
using Base: promote_eltype_op, @get!, _msk_end, unsafe_bitgetindex, linearindices, tail, OneTo, to_shape
77
import Base: .+, .-, .*, ./, .\, .//, .==, .<, .!=, .<=, , .%, .<<, .>>, .^
8-
export broadcast, broadcast!, bitbroadcast, dotview
8+
import Base: broadcast
9+
export broadcast!, bitbroadcast, dotview
910
export broadcast_getindex, broadcast_setindex!
1011

1112
## Broadcasting utilities ##

base/deprecated.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,4 +1000,7 @@ macro vectorize_2arg(S,f)
10001000
end
10011001
export @vectorize_1arg, @vectorize_2arg
10021002

1003+
# Deprecate manually vectorized real methods in favor of compact broadcast syntax
1004+
@deprecate real(A::AbstractArray) real.(A)
1005+
10031006
# End deprecations scheduled for 0.6

base/dsp.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function conv2{T}(u::StridedVector{T}, v::StridedVector{T}, A::StridedMatrix{T})
161161
v = fft([v;zeros(T,n-length(v))])
162162
C = ifft(fft(B) .* (u * v.'))
163163
if T <: Real
164-
return real(C)
164+
return real.(C)
165165
end
166166
return C
167167
end
@@ -180,7 +180,7 @@ function conv2{T}(A::StridedMatrix{T}, B::StridedMatrix{T})
180180
p = plan_fft(At)
181181
C = ifft((p*At).*(p*Bt))
182182
if T <: Real
183-
return real(C)
183+
return real.(C)
184184
end
185185
return C
186186
end

base/linalg/arpack.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function eupd_wrapper(T, n::Integer, sym::Bool, cmplx::Bool, bmat::String,
120120
elseif which == "LR" || which == "LA" || which == "BE"
121121
dmap = real
122122
elseif which == "SR" || which == "SA"
123-
dmap = x->-real(x)
123+
dmap = x->-real.(x)
124124
elseif which == "LI"
125125
dmap = imag
126126
elseif which == "SI"

base/linalg/bidiag.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ function size(M::Bidiagonal, d::Integer)
189189
end
190190

191191
#Elementary operations
192-
for func in (:conj, :copy, :round, :trunc, :floor, :ceil, :real, :imag, :abs)
192+
broadcast(::typeof(real), M::Bidiagonal) = Bidiagonal(real.(M.dv), real.(M.ev), M.isupper)
193+
for func in (:conj, :copy, :round, :trunc, :floor, :ceil, :imag, :abs)
193194
@eval ($func)(M::Bidiagonal) = Bidiagonal(($func)(M.dv), ($func)(M.ev), M.isupper)
194195
end
195196
for func in (:round, :trunc, :floor, :ceil)

base/linalg/dense.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ function logm(A::StridedMatrix)
406406
end
407407

408408
if isreal(A) && ~np_real_eigs
409-
return real(retmat)
409+
return real.(retmat)
410410
else
411411
return retmat
412412
end

base/linalg/diagonal.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ end
7171
parent(D::Diagonal) = D.diag
7272

7373
ishermitian{T<:Real}(D::Diagonal{T}) = true
74-
ishermitian(D::Diagonal) = all(D.diag .== real(D.diag))
74+
ishermitian(D::Diagonal) = all(D.diag .== real.(D.diag))
7575
issymmetric(D::Diagonal) = true
7676
isposdef(D::Diagonal) = all(D.diag .> 0)
7777

7878
factorize(D::Diagonal) = D
7979

8080
abs(D::Diagonal) = Diagonal(abs(D.diag))
81-
real(D::Diagonal) = Diagonal(real(D.diag))
81+
broadcast(::typeof(real), D::Diagonal) = Diagonal(real.(D.diag))
8282
imag(D::Diagonal) = Diagonal(imag(D.diag))
8383

8484
istriu(D::Diagonal) = true

base/linalg/svd.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SVD{T,Tr}(U::AbstractArray{T}, S::Vector{Tr}, Vt::AbstractArray{T}) = SVD{T,Tr,t
1212
function svdfact!{T<:BlasFloat}(A::StridedMatrix{T}; thin::Bool=true)
1313
m,n = size(A)
1414
if m == 0 || n == 0
15-
u,s,vt = (eye(T, m, thin ? n : m), real(zeros(T,0)), eye(T,n,n))
15+
u,s,vt = (eye(T, m, thin ? n : m), real.(zeros(T,0)), eye(T,n,n)) # shuold real.(zeros(T,0)) be zeros(real(T),0)?
1616
else
1717
u,s,vt = LAPACK.gesdd!(thin ? 'S' : 'A', A)
1818
end

0 commit comments

Comments
 (0)