Skip to content

Commit

Permalink
Merge pull request #24647 from JuliaLang/rf/complex128
Browse files Browse the repository at this point in the history
rename Complex{32,64,128} to ComplexF{16,32,64}
  • Loading branch information
StefanKarpinski authored Dec 13, 2017
2 parents 18e6dc1 + 4424e54 commit 24fce75
Show file tree
Hide file tree
Showing 64 changed files with 396 additions and 387 deletions.
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,10 @@ Deprecated or removed
in favor of `isassigned` and `normalize_string` in favor of `normalize`, all three
in the new `Unicode` standard library module ([#25021]).

* The aliases `Complex32`, `Complex64` and `Complex128` have been deprecated in favor of `ComplexF16`,
`ComplexF32` and `ComplexF64` respectively (#24647).


Command-line option changes
---------------------------

Expand Down Expand Up @@ -1724,4 +1728,4 @@ Command-line option changes
[#24413]: https://github.com/JuliaLang/julia/issues/24413
[#24653]: https://github.com/JuliaLang/julia/issues/24653
[#24869]: https://github.com/JuliaLang/julia/issues/24869
[#25021]: https://github.com/JuliaLang/julia/issues/25021
[#25021]: https://github.com/JuliaLang/julia/issues/25021
2 changes: 1 addition & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ julia> ones(1,2)
1×2 Array{Float64,2}:
1.0 1.0
julia> ones(Complex128, 2, 3)
julia> ones(ComplexF64, 2, 3)
2×3 Array{Complex{Float64},2}:
1.0+0.0im 1.0+0.0im 1.0+0.0im
1.0+0.0im 1.0+0.0im 1.0+0.0im
Expand Down
16 changes: 8 additions & 8 deletions base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Complex number type with real and imaginary part of type `T`.
`Complex32`, `Complex64` and `Complex128` are aliases for
`ComplexF16`, `ComplexF32` and `ComplexF64` are aliases for
`Complex{Float16}`, `Complex{Float32}` and `Complex{Float64}` respectively.
"""
struct Complex{T<:Real} <: Number
Expand All @@ -28,9 +28,9 @@ julia> im * im
"""
const im = Complex(false, true)

const Complex128 = Complex{Float64}
const Complex64 = Complex{Float32}
const Complex32 = Complex{Float16}
const ComplexF64 = Complex{Float64}
const ComplexF32 = Complex{Float32}
const ComplexF16 = Complex{Float16}

convert(::Type{Complex{T}}, x::Real) where {T<:Real} = Complex{T}(x,0)
convert(::Type{Complex{T}}, z::Complex) where {T<:Real} = Complex{T}(real(z),imag(z))
Expand Down Expand Up @@ -353,7 +353,7 @@ inv(z::Complex{<:Union{Float16,Float32}}) =
# a + i*b
# p + i*q = ---------
# c + i*d
function /(z::Complex128, w::Complex128)
function /(z::ComplexF64, w::ComplexF64)
a, b = reim(z); c, d = reim(w)
half = 0.5
two = 2.0
Expand All @@ -369,7 +369,7 @@ function /(z::Complex128, w::Complex128)
ab <= un*two/ϵ && (a=a*bs; b=b*bs; s=s/bs ) # scale up a,b
cd <= un*two/ϵ && (c=c*bs; d=d*bs; s=s*bs ) # scale up c,d
abs(d)<=abs(c) ? ((p,q)=robust_cdiv1(a,b,c,d) ) : ((p,q)=robust_cdiv1(b,a,d,c); q=-q)
return Complex128(p*s,q*s) # undo scaling
return ComplexF64(p*s,q*s) # undo scaling
end
function robust_cdiv1(a::Float64, b::Float64, c::Float64, d::Float64)
r = d/c
Expand All @@ -387,7 +387,7 @@ function robust_cdiv2(a::Float64, b::Float64, c::Float64, d::Float64, r::Float64
end
end

function inv(w::Complex128)
function inv(w::ComplexF64)
c, d = reim(w)
half = 0.5
two = 2.0
Expand All @@ -411,7 +411,7 @@ function inv(w::Complex128)
p = r * t
q = -t
end
return Complex128(p*s,q*s) # undo scaling
return ComplexF64(p*s,q*s) # undo scaling
end

function ssqs(x::T, y::T) where T<:AbstractFloat
Expand Down
5 changes: 5 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,11 @@ end
@deprecate_moved lcfirst "Unicode" true true
@deprecate_moved ucfirst "Unicode" true true

# PR #24647
@deprecate_binding Complex32 ComplexF16
@deprecate_binding Complex64 ComplexF32
@deprecate_binding Complex128 ComplexF64

# END 0.7 deprecations

# BEGIN 1.0 deprecations
Expand Down
2 changes: 1 addition & 1 deletion base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ Size, in bytes, of the canonical binary representation of the given DataType `T`
julia> sizeof(Float32)
4
julia> sizeof(Complex128)
julia> sizeof(ComplexF64)
16
```
Expand Down
6 changes: 3 additions & 3 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export
Cmd,
Colon,
Complex,
Complex128,
Complex64,
Complex32,
ComplexF64,
ComplexF32,
ComplexF16,
ConjArray,
ConjVector,
ConjMatrix,
Expand Down
2 changes: 1 addition & 1 deletion base/fastmath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ issubnormal_fast(x) = false

# complex numbers

ComplexTypes = Union{Complex64, Complex128}
ComplexTypes = Union{ComplexF32, ComplexF64}

@fastmath begin
abs_fast(x::ComplexTypes) = hypot(real(x), imag(x))
Expand Down
4 changes: 2 additions & 2 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2626,7 +2626,7 @@ function abstract_call(@nospecialize(f), fargs::Union{Tuple{},Vector{Any}}, argt
length(argtypes) == 3 && (argtypes[3] Int32 || argtypes[3] Int64)

a1 = argtypes[2]
basenumtype = Union{corenumtype, Main.Base.Complex64, Main.Base.Complex128, Main.Base.Rational}
basenumtype = Union{corenumtype, Main.Base.ComplexF32, Main.Base.ComplexF64, Main.Base.Rational}
if a1 basenumtype
ftimes = Main.Base.:*
ta1 = widenconst(a1)
Expand Down Expand Up @@ -5320,7 +5320,7 @@ function inline_call(e::Expr, sv::OptimizationState, stmts::Vector{Any}, boundsc
triple = (a2 === Int32(3) || a2 === Int64(3))
if square || triple
a1 = e.args[2]
basenumtype = Union{corenumtype, Main.Base.Complex64, Main.Base.Complex128, Main.Base.Rational}
basenumtype = Union{corenumtype, Main.Base.ComplexF32, Main.Base.ComplexF64, Main.Base.Rational}
if isa(a1, basenumtype) || ((isa(a1, Symbol) || isa(a1, Slot) || isa(a1, SSAValue)) &&
exprtype(a1, sv.src, sv.mod) ⊑ basenumtype)
if square
Expand Down
Loading

0 comments on commit 24fce75

Please sign in to comment.