44 Complex{T<:Real} <: Number
55
66Complex number type with real and imaginary part of type `T`.
7-
8- `Complex32`, `Complex64` and `Complex128` are aliases for
9- `Complex{Float16}`, `Complex{Float32}` and `Complex{Float64}` respectively.
107"""
118struct Complex{T<: Real } <: Number
129 re:: T
@@ -28,10 +25,6 @@ julia> im * im
2825"""
2926const im = Complex (false , true )
3027
31- const Complex128 = Complex{Float64}
32- const Complex64 = Complex{Float32}
33- const Complex32 = Complex{Float16}
34-
3528convert (:: Type{Complex{T}} , x:: Real ) where {T<: Real } = Complex {T} (x,0 )
3629convert (:: Type{Complex{T}} , z:: Complex ) where {T<: Real } = Complex {T} (real (z),imag (z))
3730convert (:: Type{T} , z:: Complex ) where {T<: Real } =
@@ -353,7 +346,7 @@ inv(z::Complex{<:Union{Float16,Float32}}) =
353346# a + i*b
354347# p + i*q = ---------
355348# c + i*d
356- function / (z:: Complex128 , w:: Complex128 )
349+ function / (z:: Complex{Float64} , w:: Complex{Float64} )
357350 a, b = reim (z); c, d = reim (w)
358351 half = 0.5
359352 two = 2.0
@@ -369,7 +362,7 @@ function /(z::Complex128, w::Complex128)
369362 ab <= un* two/ ϵ && (a= a* bs; b= b* bs; s= s/ bs ) # scale up a,b
370363 cd <= un* two/ ϵ && (c= c* bs; d= d* bs; s= s* bs ) # scale up c,d
371364 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
365+ return Complex {Float64} (p* s,q* s) # undo scaling
373366end
374367function robust_cdiv1 (a:: Float64 , b:: Float64 , c:: Float64 , d:: Float64 )
375368 r = d/ c
@@ -387,7 +380,7 @@ function robust_cdiv2(a::Float64, b::Float64, c::Float64, d::Float64, r::Float64
387380 end
388381end
389382
390- function inv (w:: Complex128 )
383+ function inv (w:: Complex{Float64} )
391384 c, d = reim (w)
392385 half = 0.5
393386 two = 2.0
@@ -411,7 +404,7 @@ function inv(w::Complex128)
411404 p = r * t
412405 q = - t
413406 end
414- return Complex128 (p* s,q* s) # undo scaling
407+ return Complex {Float64} (p* s,q* s) # undo scaling
415408end
416409
417410function ssqs (x:: T , y:: T ) where T<: AbstractFloat
0 commit comments