Skip to content

Commit

Permalink
deprecate Complex{32,64,128}
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Nov 18, 2017
1 parent 8085047 commit d057b8e
Show file tree
Hide file tree
Showing 64 changed files with 265 additions and 260 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ Deprecated or removed
* `a:b` is deprecated for constructing a `StepRange` when `a` and `b` have physical units
(Dates and Times). Use `a:s:b`, where `s = Dates.Day(1)` or `s = Dates.Second(1)`.

* The aliases `Complex32`, `Complex64` and `Complex128` have been deprecated in favor of `Complex{Float16}`,
`Complex{Float32}` and `Complex{Float64}` respectively (#24647).


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

Expand Down
2 changes: 1 addition & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ For convenience `dims` may also be passed in variadic form.
# Examples
```jldoctest
julia> ones(Complex128, 2, 3)
julia> ones(Complex{Float64}, 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
15 changes: 4 additions & 11 deletions base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
Complex{T<:Real} <: Number
Complex number type with real and imaginary part of type `T`.
`Complex32`, `Complex64` and `Complex128` are aliases for
`Complex{Float16}`, `Complex{Float32}` and `Complex{Float64}` respectively.
"""
struct Complex{T<:Real} <: Number
re::T
Expand All @@ -28,10 +25,6 @@ julia> im * im
"""
const im = Complex(false, true)

const Complex128 = Complex{Float64}
const Complex64 = Complex{Float32}
const Complex32 = 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))
convert(::Type{T}, z::Complex) where {T<:Real} =
Expand Down Expand Up @@ -353,7 +346,7 @@ inv(z::Complex{<:Union{Float16,Float32}}) =
# a + i*b
# p + i*q = ---------
# c + i*d
function /(z::Complex128, w::Complex128)
function /(z::Complex{Float64}, w::Complex{Float64})
a, b = reim(z); c, d = reim(w)
half = 0.5
two = 2.0
Expand All @@ -369,7 +362,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 Complex{Float64}(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 +380,7 @@ function robust_cdiv2(a::Float64, b::Float64, c::Float64, d::Float64, r::Float64
end
end

function inv(w::Complex128)
function inv(w::Complex{Float64})
c, d = reim(w)
half = 0.5
two = 2.0
Expand All @@ -411,7 +404,7 @@ function inv(w::Complex128)
p = r * t
q = -t
end
return Complex128(p*s,q*s) # undo scaling
return Complex{Float64}(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 @@ -2097,6 +2097,11 @@ end
@deprecate chol!(x::Number, uplo) chol(x) false
end

# #24647
@deprecate_binding Complex32 Complex{Float16}
@deprecate_binding Complex64 Complex{Float32}
@deprecate_binding Complex128 Complex{Float64}

# 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 @@ -351,7 +351,7 @@ Size, in bytes, of the canonical binary representation of the given DataType `T`
julia> sizeof(Float32)
4
julia> sizeof(Complex128)
julia> sizeof(Complex{Float64})
16
```
Expand Down
3 changes: 0 additions & 3 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ export
Cmd,
Colon,
Complex,
Complex128,
Complex64,
Complex32,
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{Complex{Float32}, Complex{Float64}}

@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 @@ -2460,7 +2460,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.Complex{Float32}, Main.Base.Complex{Float64}, Main.Base.Rational}
if a1 basenumtype
ftimes = Main.Base.:*
ta1 = widenconst(a1)
Expand Down Expand Up @@ -5249,7 +5249,7 @@ function inlining_pass(e::Expr, sv::OptimizationState, stmts::Vector{Any}, ins,
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.Complex{Float32}, Main.Base.Complex{Float64}, 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
4 changes: 2 additions & 2 deletions base/linalg/arpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ for (T, saupd_name, seupd_name, naupd_name, neupd_name) in
end

for (T, TR, naupd_name, neupd_name) in
((:Complex128, :Float64, :znaupd_, :zneupd_),
(:Complex64, :Float32, :cnaupd_, :cneupd_))
((Complex{Float64}, :Float64, :znaupd_, :zneupd_),
(Complex{Float32}, :Float32, :cnaupd_, :cneupd_))
@eval begin
function naupd(ido, bmat, n, evtype, nev, TOL::Ref{$TR}, resid::Vector{$T}, ncv, v::Matrix{$T}, ldv,
iparam, ipntr, workd::Vector{$T}, workl::Vector{$T}, lworkl,
Expand Down
7 changes: 5 additions & 2 deletions base/linalg/blas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ const liblapack = Base.liblapack_name

import ..LinAlg: BlasReal, BlasComplex, BlasFloat, BlasInt, DimensionMismatch, checksquare, axpy!

const Complex64 = Complex{Float32}
const Complex128 = Complex{Float64}

# utility routines
function vendor()
lib = Libdl.dlopen_e(Base.libblas_name)
Expand Down Expand Up @@ -169,8 +172,8 @@ function blascopy! end

for (fname, elty) in ((:dcopy_,:Float64),
(:scopy_,:Float32),
(:zcopy_,:Complex128),
(:ccopy_,:Complex64))
(:zcopy_,Complex{Float64}),
(:ccopy_,Complex{Float32}))
@eval begin
# SUBROUTINE DCOPY(N,DX,INCX,DY,INCY)
function blascopy!(n::Integer, DX::Union{Ptr{$elty},StridedArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},StridedArray{$elty}}, incy::Integer)
Expand Down
3 changes: 3 additions & 0 deletions base/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import ..LinAlg: BlasFloat, Char, BlasInt, LAPACKException,

using Base: iszero

const Complex64 = Complex{Float32}
const Complex128 = Complex{Float64}

#Generic LAPACK error handlers
"""
Handle only negative LAPACK error codes
Expand Down
4 changes: 2 additions & 2 deletions base/linalg/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ export
# Constants
I

const BlasFloat = Union{Float64,Float32,Complex128,Complex64}
const BlasFloat = Union{Float64,Float32,Complex{Float64},Complex{Float32}}
const BlasReal = Union{Float64,Float32}
const BlasComplex = Union{Complex128,Complex64}
const BlasComplex = Union{Complex{Float64},Complex{Float32},}

if USE_BLAS64
const BlasInt = Int64
Expand Down
2 changes: 1 addition & 1 deletion base/linalg/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ The returned object `F` stores the factorization in a packed format:
- if `pivot == Val(true)` then `F` is a [`QRPivoted`](@ref) object,
- otherwise if the element type of `A` is a BLAS type ([`Float32`](@ref), [`Float64`](@ref),
`Complex64` or `Complex128`), then `F` is a [`QRCompactWY`](@ref) object,
`Complex{Float32}` or `Complex{Float64}`), then `F` is a [`QRCompactWY`](@ref) object,
- otherwise `F` is a [`QR`](@ref) object.
Expand Down
2 changes: 1 addition & 1 deletion base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ for func in (:sin,:cos,:tan,:asin,:acos,:atan,:sinh,:cosh,:tanh,:asinh,:acosh,
:atanh,:exp,:exp2,:exp10,:log,:log2,:log10,:sqrt,:lgamma,:log1p)
@eval begin
$func(a::Float16) = Float16($func(Float32(a)))
$func(a::Complex32) = Complex32($func(Complex64(a)))
$func(a::Complex{Float16}) = Complex{Float16}($func(Complex{Float32}(a)))
end
end

Expand Down
4 changes: 2 additions & 2 deletions base/random/normal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ from the circularly symmetric complex normal distribution.
```jldoctest
julia> rng = MersenneTwister(1234);
julia> randn(rng, Complex128)
julia> randn(rng, Complex{Float64})
0.6133070881429037 - 0.6376291670853887im
julia> randn(rng, Complex64, (2, 3))
julia> randn(rng, Complex{Float32}, (2, 3))
2×3 Array{Complex{Float32},2}:
-0.349649-0.638457im 0.376756-0.192146im -0.396334-0.0136413im
0.611224+1.56403im 0.355204-0.365563im 0.0905552+1.31012im
Expand Down
12 changes: 6 additions & 6 deletions base/sparse/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ function sdmult!(A::Sparse{Tv}, transpose::Bool,
end
@isok ccall((@cholmod_name("sdmult", SuiteSparse_long),:libcholmod), Cint,
(Ptr{C_Sparse{Tv}}, Cint,
Ref{Complex128}, Ref{Complex128},
Ref{Complex{Float64}}, Ref{Complex{Float64}},
Ptr{C_Dense{Tv}}, Ptr{C_Dense{Tv}}, Ptr{UInt8}),
A, transpose, α, β, X, Y, common_struct)
Y
Expand Down Expand Up @@ -754,7 +754,7 @@ function factorize_p!(A::Sparse{Tv}, β::Real, F::Factor{Tv}, cmmn::Vector{UInt8
# note that β is passed as a complex number (double beta[2]),
# but the CHOLMOD manual says that only beta[0] (real part) is used
@isok ccall((@cholmod_name("factorize_p", SuiteSparse_long),:libcholmod), Cint,
(Ptr{C_Sparse{Tv}}, Ref{Complex128}, Ptr{SuiteSparse_long}, Csize_t,
(Ptr{C_Sparse{Tv}}, Ref{Complex{Float64}}, Ptr{SuiteSparse_long}, Csize_t,
Ptr{C_Factor{Tv}}, Ptr{UInt8}),
A, β, C_NULL, 0, F, cmmn)
F
Expand Down Expand Up @@ -1373,7 +1373,7 @@ See also [`cholfact`](@ref).
!!! note
This method uses the CHOLMOD library from SuiteSparse, which only supports
doubles or complex doubles. Input matrices not of those element types will
be converted to `SparseMatrixCSC{Float64}` or `SparseMatrixCSC{Complex128}`
be converted to `SparseMatrixCSC{Float64}` or `SparseMatrixCSC{Complex{Float64}}`
as appropriate.
"""
cholfact!(F::Factor, A::Union{SparseMatrixCSC{T},
Expand Down Expand Up @@ -1426,7 +1426,7 @@ it should be a permutation of `1:size(A,1)` giving the ordering to use
!!! note
This method uses the CHOLMOD library from SuiteSparse, which only supports
doubles or complex doubles. Input matrices not of those element types will
be converted to `SparseMatrixCSC{Float64}` or `SparseMatrixCSC{Complex128}`
be converted to `SparseMatrixCSC{Float64}` or `SparseMatrixCSC{Complex{Float64}}`
as appropriate.
Many other functions from CHOLMOD are wrapped but not exported from the
Expand Down Expand Up @@ -1467,7 +1467,7 @@ See also [`ldltfact`](@ref).
!!! note
This method uses the CHOLMOD library from SuiteSparse, which only supports
doubles or complex doubles. Input matrices not of those element types will
be converted to `SparseMatrixCSC{Float64}` or `SparseMatrixCSC{Complex128}`
be converted to `SparseMatrixCSC{Float64}` or `SparseMatrixCSC{Complex{Float64}}`
as appropriate.
"""
ldltfact!(F::Factor, A::Union{SparseMatrixCSC{T},
Expand Down Expand Up @@ -1526,7 +1526,7 @@ it should be a permutation of `1:size(A,1)` giving the ordering to use
!!! note
This method uses the CHOLMOD library from SuiteSparse, which only supports
doubles or complex doubles. Input matrices not of those element types will
be converted to `SparseMatrixCSC{Float64}` or `SparseMatrixCSC{Complex128}`
be converted to `SparseMatrixCSC{Float64}` or `SparseMatrixCSC{Complex{Float64}}`
as appropriate.
Many other functions from CHOLMOD are wrapped but not exported from the
Expand Down
10 changes: 5 additions & 5 deletions base/sparse/cholmod_h.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const DOUBLE = Int32(0) # all numerical values are double
const SINGLE = Int32(1) # all numerical values are float
dtyp(::Type{Float32}) = SINGLE
dtyp(::Type{Float64}) = DOUBLE
dtyp(::Type{Complex64}) = SINGLE
dtyp(::Type{Complex128}) = DOUBLE
dtyp(::Type{Complex{Float32}}) = SINGLE
dtyp(::Type{Complex{Float64}}) = DOUBLE

## xtype defines the kind of numerical values used:
const PATTERN = Int32(0) # pattern only, no numerical values
Expand All @@ -26,8 +26,8 @@ const COMPLEX = Int32(2) # a complex matrix (ANSI C99 compatible)
const ZOMPLEX = Int32(3) # a complex matrix (MATLAB compatible)
xtyp(::Type{Float32}) = REAL
xtyp(::Type{Float64}) = REAL
xtyp(::Type{Complex64}) = COMPLEX
xtyp(::Type{Complex128}) = COMPLEX
xtyp(::Type{Complex{Float32}}) = COMPLEX
xtyp(::Type{Complex{Float64}}) = COMPLEX

## Scaling modes, selected by the scale input parameter:
const SCALAR = Int32(0) # A = s*A
Expand Down Expand Up @@ -67,7 +67,7 @@ else
const ITypes = Union{Int32, Int64}
end

const VTypes = Union{Complex128, Float64}
const VTypes = Union{Complex{Float64}, Float64}
const VRealTypes = Union{Float64}

struct CHOLMODException <: Exception
Expand Down
16 changes: 9 additions & 7 deletions base/sparse/umfpack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct MatrixIllConditionedException <: Exception
msg::AbstractString
end

const Complex128 = Complex{Float64}

function umferror(status::Integer)
if status==UMFPACK_OK
return
Expand Down Expand Up @@ -66,7 +68,7 @@ else
const UMFITypes = Union{Int32, Int64}
end

const UMFVTypes = Union{Float64,Complex128}
const UMFVTypes = Union{Float64,Complex{Float64}}

## UMFPACK

Expand Down Expand Up @@ -107,7 +109,7 @@ end
Compute the LU factorization of a sparse matrix `A`.
For sparse `A` with real or complex element type, the return type of `F` is
`UmfpackLU{Tv, Ti}`, with `Tv` = [`Float64`](@ref) or `Complex128` respectively and
`UmfpackLU{Tv, Ti}`, with `Tv` = [`Float64`](@ref) or `Complex{Float64}` respectively and
`Ti` is an integer type ([`Int32`](@ref) or [`Int64`](@ref)).
The individual components of the factorization `F` can be accessed by indexing:
Expand All @@ -134,8 +136,8 @@ The relation between `F` and `A` is
!!! note
`lufact(A::SparseMatrixCSC)` uses the UMFPACK library that is part of
SuiteSparse. As this library only supports sparse matrices with [`Float64`](@ref) or
`Complex128` elements, `lufact` converts `A` into a copy that is of type
`SparseMatrixCSC{Float64}` or `SparseMatrixCSC{Complex128}` as appropriate.
`Complex{Float64}` elements, `lufact` converts `A` into a copy that is of type
`SparseMatrixCSC{Float64}` or `SparseMatrixCSC{Complex{Float64}}` as appropriate.
"""
function lufact(S::SparseMatrixCSC{<:UMFVTypes,<:UMFITypes})
zerobased = S.colptr[1] == 0
Expand All @@ -148,11 +150,11 @@ function lufact(S::SparseMatrixCSC{<:UMFVTypes,<:UMFITypes})
end
lufact(A::SparseMatrixCSC{<:Union{Float16,Float32},Ti}) where {Ti<:UMFITypes} =
lufact(convert(SparseMatrixCSC{Float64,Ti}, A))
lufact(A::SparseMatrixCSC{<:Union{Complex32,Complex64},Ti}) where {Ti<:UMFITypes} =
lufact(convert(SparseMatrixCSC{Complex128,Ti}, A))
lufact(A::SparseMatrixCSC{<:Union{Complex{Float16},Complex{Float32}},Ti}) where {Ti<:UMFITypes} =
lufact(convert(SparseMatrixCSC{Complex{Float64},Ti}, A))
lufact(A::Union{SparseMatrixCSC{T},SparseMatrixCSC{Complex{T}}}) where {T<:AbstractFloat} =
throw(ArgumentError(string("matrix type ", typeof(A), "not supported. ",
"Try lufact(convert(SparseMatrixCSC{Float64/Complex128,Int}, A)) for ",
"Try lufact(convert(SparseMatrixCSC{Float64/Complex{Float64},Int}, A)) for ",
"sparse floating point LU using UMFPACK or lufact(Array(A)) for generic ",
"dense LU.")))
lufact(A::SparseMatrixCSC) = lufact(float(A))
Expand Down
10 changes: 5 additions & 5 deletions doc/src/manual/calling-c-and-fortran-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ First, a review of some relevant Julia type terminology:
| | | "TypeVar" :: The `T` in the type parameter declaration is referred to as a TypeVar (short for type variable). |
| `primitive type` | `Int`, `Float64` | "Primitive Type" :: A type with no fields, but a size. It is stored and defined by-value. |
| `struct` | `Pair{Int, Int}` | "Struct" :: A type with all fields defined to be constant. It is defined by-value, and may be stored with a type-tag. |
| | `Complex128` (`isbits`) | "Is-Bits" :: A `primitive type`, or a `struct` type where all fields are other `isbits` types. It is defined by-value, and is stored without a type-tag. |
| | `Complex{Float64}` (`isbits`) | "Is-Bits" :: A `primitive type`, or a `struct` type where all fields are other `isbits` types. It is defined by-value, and is stored without a type-tag. |
| `struct ...; end` | `nothing` | "Singleton" :: a Leaf Type or Struct with no fields. |
| `(...)` or `tuple(...)` | `(1, 2, 3)` | "Tuple" :: an immutable data-structure similar to an anonymous struct type, or a constant array. Represented as either an array or a struct. |

Expand All @@ -292,11 +292,11 @@ same:

Exactly corresponds to the `double` type in C (or `REAL*8` in Fortran).

* `Complex64`
* `Complex{Float32}`

Exactly corresponds to the `complex float` type in C (or `COMPLEX*8` in Fortran).

* `Complex128`
* `Complex{Float64}`

Exactly corresponds to the `complex double` type in C (or `COMPLEX*16` in Fortran).

Expand Down Expand Up @@ -350,8 +350,8 @@ an `Int` in Julia).
| `uintmax_t` |   | `Cuintmax_t` | `UInt64` |
| `float` | `REAL*4i` | `Cfloat` | `Float32` |
| `double` | `REAL*8` | `Cdouble` | `Float64` |
| `complex float` | `COMPLEX*8` | `Complex64` | `Complex{Float32}` |
| `complex double` | `COMPLEX*16` | `Complex128` | `Complex{Float64}` |
| `complex float` | `COMPLEX*8` | `Complex{Float32}` | `Complex{Float32}` |
| `complex double` | `COMPLEX*16` | `Complex{Float64}` | `Complex{Float64}` |
| `ptrdiff_t` |   | `Cptrdiff_t` | `Int` |
| `ssize_t` |   | `Cssize_t` | `Int` |
| `size_t` |   | `Csize_t` | `UInt` |
Expand Down
Loading

0 comments on commit d057b8e

Please sign in to comment.