Skip to content

Commit 24fce75

Browse files
Merge pull request #24647 from JuliaLang/rf/complex128
rename Complex{32,64,128} to ComplexF{16,32,64}
2 parents 18e6dc1 + 4424e54 commit 24fce75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+396
-387
lines changed

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,10 @@ Deprecated or removed
751751
in favor of `isassigned` and `normalize_string` in favor of `normalize`, all three
752752
in the new `Unicode` standard library module ([#25021]).
753753

754+
* The aliases `Complex32`, `Complex64` and `Complex128` have been deprecated in favor of `ComplexF16`,
755+
`ComplexF32` and `ComplexF64` respectively (#24647).
756+
757+
754758
Command-line option changes
755759
---------------------------
756760

@@ -1724,4 +1728,4 @@ Command-line option changes
17241728
[#24413]: https://github.com/JuliaLang/julia/issues/24413
17251729
[#24653]: https://github.com/JuliaLang/julia/issues/24653
17261730
[#24869]: https://github.com/JuliaLang/julia/issues/24869
1727-
[#25021]: https://github.com/JuliaLang/julia/issues/25021
1731+
[#25021]: https://github.com/JuliaLang/julia/issues/25021

base/array.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ julia> ones(1,2)
365365
1×2 Array{Float64,2}:
366366
1.0 1.0
367367
368-
julia> ones(Complex128, 2, 3)
368+
julia> ones(ComplexF64, 2, 3)
369369
2×3 Array{Complex{Float64},2}:
370370
1.0+0.0im 1.0+0.0im 1.0+0.0im
371371
1.0+0.0im 1.0+0.0im 1.0+0.0im

base/complex.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Complex number type with real and imaginary part of type `T`.
77
8-
`Complex32`, `Complex64` and `Complex128` are aliases for
8+
`ComplexF16`, `ComplexF32` and `ComplexF64` are aliases for
99
`Complex{Float16}`, `Complex{Float32}` and `Complex{Float64}` respectively.
1010
"""
1111
struct Complex{T<:Real} <: Number
@@ -28,9 +28,9 @@ julia> im * im
2828
"""
2929
const im = Complex(false, true)
3030

31-
const Complex128 = Complex{Float64}
32-
const Complex64 = Complex{Float32}
33-
const Complex32 = Complex{Float16}
31+
const ComplexF64 = Complex{Float64}
32+
const ComplexF32 = Complex{Float32}
33+
const ComplexF16 = Complex{Float16}
3434

3535
convert(::Type{Complex{T}}, x::Real) where {T<:Real} = Complex{T}(x,0)
3636
convert(::Type{Complex{T}}, z::Complex) where {T<:Real} = Complex{T}(real(z),imag(z))
@@ -353,7 +353,7 @@ inv(z::Complex{<:Union{Float16,Float32}}) =
353353
# a + i*b
354354
# p + i*q = ---------
355355
# c + i*d
356-
function /(z::Complex128, w::Complex128)
356+
function /(z::ComplexF64, w::ComplexF64)
357357
a, b = reim(z); c, d = reim(w)
358358
half = 0.5
359359
two = 2.0
@@ -369,7 +369,7 @@ function /(z::Complex128, w::Complex128)
369369
ab <= un*two/ϵ && (a=a*bs; b=b*bs; s=s/bs ) # scale up a,b
370370
cd <= un*two/ϵ && (c=c*bs; d=d*bs; s=s*bs ) # scale up c,d
371371
abs(d)<=abs(c) ? ((p,q)=robust_cdiv1(a,b,c,d) ) : ((p,q)=robust_cdiv1(b,a,d,c); q=-q)
372-
return Complex128(p*s,q*s) # undo scaling
372+
return ComplexF64(p*s,q*s) # undo scaling
373373
end
374374
function robust_cdiv1(a::Float64, b::Float64, c::Float64, d::Float64)
375375
r = d/c
@@ -387,7 +387,7 @@ function robust_cdiv2(a::Float64, b::Float64, c::Float64, d::Float64, r::Float64
387387
end
388388
end
389389

390-
function inv(w::Complex128)
390+
function inv(w::ComplexF64)
391391
c, d = reim(w)
392392
half = 0.5
393393
two = 2.0
@@ -411,7 +411,7 @@ function inv(w::Complex128)
411411
p = r * t
412412
q = -t
413413
end
414-
return Complex128(p*s,q*s) # undo scaling
414+
return ComplexF64(p*s,q*s) # undo scaling
415415
end
416416

417417
function ssqs(x::T, y::T) where T<:AbstractFloat

base/deprecated.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,11 @@ end
29872987
@deprecate_moved lcfirst "Unicode" true true
29882988
@deprecate_moved ucfirst "Unicode" true true
29892989

2990+
# PR #24647
2991+
@deprecate_binding Complex32 ComplexF16
2992+
@deprecate_binding Complex64 ComplexF32
2993+
@deprecate_binding Complex128 ComplexF64
2994+
29902995
# END 0.7 deprecations
29912996

29922997
# BEGIN 1.0 deprecations

base/essentials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ Size, in bytes, of the canonical binary representation of the given DataType `T`
364364
julia> sizeof(Float32)
365365
4
366366
367-
julia> sizeof(Complex128)
367+
julia> sizeof(ComplexF64)
368368
16
369369
```
370370

base/exports.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ export
4444
Cmd,
4545
Colon,
4646
Complex,
47-
Complex128,
48-
Complex64,
49-
Complex32,
47+
ComplexF64,
48+
ComplexF32,
49+
ComplexF16,
5050
ConjArray,
5151
ConjVector,
5252
ConjMatrix,

base/fastmath.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ issubnormal_fast(x) = false
187187

188188
# complex numbers
189189

190-
ComplexTypes = Union{Complex64, Complex128}
190+
ComplexTypes = Union{ComplexF32, ComplexF64}
191191

192192
@fastmath begin
193193
abs_fast(x::ComplexTypes) = hypot(real(x), imag(x))

base/inference.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,7 +2626,7 @@ function abstract_call(@nospecialize(f), fargs::Union{Tuple{},Vector{Any}}, argt
26262626
length(argtypes) == 3 && (argtypes[3] Int32 || argtypes[3] Int64)
26272627

26282628
a1 = argtypes[2]
2629-
basenumtype = Union{corenumtype, Main.Base.Complex64, Main.Base.Complex128, Main.Base.Rational}
2629+
basenumtype = Union{corenumtype, Main.Base.ComplexF32, Main.Base.ComplexF64, Main.Base.Rational}
26302630
if a1 basenumtype
26312631
ftimes = Main.Base.:*
26322632
ta1 = widenconst(a1)
@@ -5320,7 +5320,7 @@ function inline_call(e::Expr, sv::OptimizationState, stmts::Vector{Any}, boundsc
53205320
triple = (a2 === Int32(3) || a2 === Int64(3))
53215321
if square || triple
53225322
a1 = e.args[2]
5323-
basenumtype = Union{corenumtype, Main.Base.Complex64, Main.Base.Complex128, Main.Base.Rational}
5323+
basenumtype = Union{corenumtype, Main.Base.ComplexF32, Main.Base.ComplexF64, Main.Base.Rational}
53245324
if isa(a1, basenumtype) || ((isa(a1, Symbol) || isa(a1, Slot) || isa(a1, SSAValue)) &&
53255325
exprtype(a1, sv.src, sv.mod) ⊑ basenumtype)
53265326
if square

0 commit comments

Comments
 (0)