Skip to content

Commit

Permalink
rename: FloatingPoint => AbstractFloat
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Jul 30, 2015
1 parent 48a2f1c commit 99fa597
Show file tree
Hide file tree
Showing 61 changed files with 272 additions and 272 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ Deprecated or removed
end
```

* indexing with Reals that are not subtypes of Integers (Rationals, FloatingPoint, etc.) has been deprecated ([#10458]).
* indexing with Reals that are not subtypes of Integers (Rationals, AbstractFloat, etc.) has been deprecated ([#10458]).

* `push!(A)` has been deprecated, use `append!` instead of splatting arguments to `push!` ([#10400]).

Expand Down
4 changes: 2 additions & 2 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ map(::Type{Unsigned}, a::Array) = map!(Unsigned, similar(a,typeof(Unsigned(one(e

map{T<:Real}(::Type{T}, r::StepRange) = T(r.start):T(r.step):T(last(r))
map{T<:Real}(::Type{T}, r::UnitRange) = T(r.start):T(last(r))
map{T<:FloatingPoint}(::Type{T}, r::FloatRange) = FloatRange(T(r.start), T(r.step), r.len, T(r.divisor))
function map{T<:FloatingPoint}(::Type{T}, r::LinSpace)
map{T<:AbstractFloat}(::Type{T}, r::FloatRange) = FloatRange(T(r.start), T(r.step), r.len, T(r.divisor))
function map{T<:AbstractFloat}(::Type{T}, r::LinSpace)
new_len = T(r.len)
new_len == r.len || error("$r: too long for $T")
LinSpace(T(r.start), T(r.stop), new_len, T(r.divisor))
Expand Down
4 changes: 2 additions & 2 deletions base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function circshift{T,N}(a::AbstractArray{T,N}, shiftamts)
end

# Uses K-B-N summation
function cumsum_kbn{T<:FloatingPoint}(v::AbstractVector{T})
function cumsum_kbn{T<:AbstractFloat}(v::AbstractVector{T})
n = length(v)
r = similar(v, n)
if n == 0; return r; end
Expand All @@ -128,7 +128,7 @@ function cumsum_kbn{T<:FloatingPoint}(v::AbstractVector{T})
end

# Uses K-B-N summation
function cumsum_kbn{T<:FloatingPoint}(A::AbstractArray{T}, axis::Integer=1)
function cumsum_kbn{T<:AbstractFloat}(A::AbstractArray{T}, axis::Integer=1)
dimsA = size(A)
ndimsA = ndims(A)
axis_size = dimsA[axis]
Expand Down
2 changes: 1 addition & 1 deletion base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function fill!(a::Union{Array{UInt8}, Array{Int8}}, x::Integer)
return a
end

function fill!{T<:Union{Integer,FloatingPoint}}(a::Array{T}, x)
function fill!{T<:Union{Integer,AbstractFloat}}(a::Array{T}, x)
# note: checking bit pattern
xT = convert(T,x)
if isbits(T) && nfields(T)==0 &&
Expand Down
2 changes: 1 addition & 1 deletion base/arraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ end
## Binary arithmetic operators ##

promote_array_type{Scalar, Arry}(F, ::Type{Scalar}, ::Type{Arry}) = promote_op(F, Scalar, Arry)
promote_array_type{S<:Real, A<:FloatingPoint}(F, ::Type{S}, ::Type{A}) = A
promote_array_type{S<:Real, A<:AbstractFloat}(F, ::Type{S}, ::Type{A}) = A
promote_array_type{S<:Integer, A<:Integer}(F, ::Type{S}, ::Type{A}) = A
promote_array_type{S<:Integer}(F, ::Type{S}, ::Type{Bool}) = S

Expand Down
4 changes: 2 additions & 2 deletions base/bool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ abs2(x::Bool) = x
^(x::Bool, y::Bool) = x | !y
^(x::Integer, y::Bool) = ifelse(y, x, one(x))

function +{T<:FloatingPoint}(x::Bool, y::T)
function +{T<:AbstractFloat}(x::Bool, y::T)
ifelse(x, one(promote_type(Bool,T)) + convert(promote_type(Bool,T),y),
convert(promote_type(Bool,T),y))
end
+(y::FloatingPoint, x::Bool) = x + y
+(y::AbstractFloat, x::Bool) = x + y

function *{T<:Number}(x::Bool, y::T)
ifelse(x, convert(promote_type(Bool,T),y),
Expand Down
10 changes: 5 additions & 5 deletions base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export
Module, Symbol, Task, Array, WeakRef,
# numeric types
Number, Real, Integer, Bool, Ref, Ptr,
FloatingPoint, Float16, Float32, Float64,
AbstractFloat, Float16, Float32, Float64,
Signed, Int, Int8, Int16, Int32, Int64, Int128,
Unsigned, UInt, UInt8, UInt16, UInt32, UInt64, UInt128,
# string types
Expand Down Expand Up @@ -180,14 +180,14 @@ const (===) = is

abstract Number
abstract Real <: Number
abstract FloatingPoint <: Real
abstract AbstractFloat <: Real
abstract Integer <: Real
abstract Signed <: Integer
abstract Unsigned <: Integer

bitstype 16 Float16 <: FloatingPoint
bitstype 32 Float32 <: FloatingPoint
bitstype 64 Float64 <: FloatingPoint
bitstype 16 Float16 <: AbstractFloat
bitstype 32 Float32 <: AbstractFloat
bitstype 64 Float64 <: AbstractFloat

bitstype 8 Bool <: Integer
bitstype 32 Char
Expand Down
32 changes: 16 additions & 16 deletions base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function complex_show(io::IO, z::Complex, compact::Bool)
print(io, compact ? "+" : " + ")
end
compact ? showcompact(io, i) : show(io, i)
if !(isa(i,Integer) && !isa(i,Bool) || isa(i,FloatingPoint) && isfinite(i))
if !(isa(i,Integer) && !isa(i,Bool) || isa(i,AbstractFloat) && isfinite(i))
print(io, "*")
end
print(io, "im")
Expand Down Expand Up @@ -227,7 +227,7 @@ function inv(w::Complex128)
return Complex128(p*s,q*s) # undo scaling
end

function ssqs{T<:FloatingPoint}(x::T, y::T)
function ssqs{T<:AbstractFloat}(x::T, y::T)
k::Int = 0
ρ = x*x + y*y
if !isfinite(ρ) && (isinf(x) || isinf(y))
Expand All @@ -241,7 +241,7 @@ function ssqs{T<:FloatingPoint}(x::T, y::T)
ρ, k
end

function sqrt{T<:FloatingPoint}(z::Complex{T})
function sqrt{T<:AbstractFloat}(z::Complex{T})
x, y = reim(z)
if x==y==0
return Complex(zero(x),y)
Expand Down Expand Up @@ -291,7 +291,7 @@ end

angle(z::Complex) = atan2(imag(z), real(z))

function log{T<:FloatingPoint}(z::Complex{T})
function log{T<:AbstractFloat}(z::Complex{T})
const T1::T = 1.25
const T2::T = 3
const ln2::T = log(convert(T,2)) #0.6931471805599453
Expand Down Expand Up @@ -405,7 +405,7 @@ function log1p{T}(z::Complex{T})
end
end

function ^{T<:FloatingPoint}(z::Complex{T}, p::Complex{T})
function ^{T<:AbstractFloat}(z::Complex{T}, p::Complex{T})
if p==2 #square
zr, zi = reim(z)
x = (zr-zi)*(zr+zi)
Expand Down Expand Up @@ -513,10 +513,10 @@ end
^(z::Complex, n::Bool) = n ? z : one(z)
^(z::Complex, n::Integer) = z^Complex(n)

^{T<:FloatingPoint}(z::Complex{T}, n::Bool) = n ? z : one(z) # to resolve ambiguity
^{T<:AbstractFloat}(z::Complex{T}, n::Bool) = n ? z : one(z) # to resolve ambiguity
^{T<:Integer}(z::Complex{T}, n::Bool) = n ? z : one(z) # to resolve ambiguity

^{T<:FloatingPoint}(z::Complex{T}, n::Integer) =
^{T<:AbstractFloat}(z::Complex{T}, n::Integer) =
n>=0 ? power_by_squaring(z,n) : power_by_squaring(inv(z),-n)
^{T<:Integer}(z::Complex{T}, n::Integer) = power_by_squaring(z,n) # DomainError for n<0

Expand Down Expand Up @@ -566,7 +566,7 @@ function asin(z::Complex)
Complex(ξ,η)
end

function acos{T<:FloatingPoint}(z::Complex{T})
function acos{T<:AbstractFloat}(z::Complex{T})
zr, zi = reim(z)
if isnan(zr)
if isinf(zi) return Complex(zr, -zi)
Expand Down Expand Up @@ -607,7 +607,7 @@ function cosh(z::Complex)
cos(Complex(-zi,zr))
end

function tanh{T<:FloatingPoint}(z::Complex{T})
function tanh{T<:AbstractFloat}(z::Complex{T})
const Ω = prevfloat(typemax(T))
ξ, η = reim(z)
if isnan(ξ) && η==0 return Complex(ξ, η) end
Expand Down Expand Up @@ -652,7 +652,7 @@ function acosh(z::Complex)
Complex(ξ, η)
end

function atanh{T<:FloatingPoint}(z::Complex{T})
function atanh{T<:AbstractFloat}(z::Complex{T})
const Ω = prevfloat(typemax(T))
const θ = sqrt(Ω)/4
const ρ = 1/θ
Expand Down Expand Up @@ -704,13 +704,13 @@ end
#Requires two different RoundingModes for the real and imaginary components

if WORD_SIZE==32
function round{T<:FloatingPoint, MR, MI}(z::Complex{T}, ::RoundingMode{MR}, ::RoundingMode{MI})
function round{T<:AbstractFloat, MR, MI}(z::Complex{T}, ::RoundingMode{MR}, ::RoundingMode{MI})
Complex((round(real(z), RoundingMode{MR}()),
round(imag(z), RoundingMode{MI}()))...)
end
round(z::Complex) = Complex((round(real(z)), round(imag(z)))...)
else
function round{T<:FloatingPoint, MR, MI}(z::Complex{T}, ::RoundingMode{MR}, ::RoundingMode{MI})
function round{T<:AbstractFloat, MR, MI}(z::Complex{T}, ::RoundingMode{MR}, ::RoundingMode{MI})
Complex(round(real(z), RoundingMode{MR}()),
round(imag(z), RoundingMode{MI}()))
end
Expand All @@ -724,11 +724,11 @@ function round(z::Complex, digits::Integer, base::Integer=10)
round(imag(z), digits, base))
end

float{T<:FloatingPoint}(z::Complex{T}) = z
float{T<:AbstractFloat}(z::Complex{T}) = z
float(z::Complex) = Complex(float(real(z)), float(imag(z)))
@vectorize_1arg Complex float

big{T<:FloatingPoint}(z::Complex{T}) = Complex{BigFloat}(z)
big{T<:AbstractFloat}(z::Complex{T}) = Complex{BigFloat}(z)
big{T<:Integer}(z::Complex{T}) = Complex{BigInt}(z)

## Array operations on complex numbers ##
Expand All @@ -743,11 +743,11 @@ function complex{T}(A::AbstractArray{T})
end

big{T<:Integer,N}(A::AbstractArray{Complex{T},N}) = convert(AbstractArray{Complex{BigInt},N}, A)
big{T<:FloatingPoint,N}(A::AbstractArray{Complex{T},N}) = convert(AbstractArray{Complex{BigFloat},N}, A)
big{T<:AbstractFloat,N}(A::AbstractArray{Complex{T},N}) = convert(AbstractArray{Complex{BigFloat},N}, A)

## promotion to complex ##

promote_array_type{S<:Union{Complex, Real}, AT<:FloatingPoint}(F, ::Type{S}, ::Type{Complex{AT}}) = Complex{AT}
promote_array_type{S<:Union{Complex, Real}, AT<:AbstractFloat}(F, ::Type{S}, ::Type{Complex{AT}}) = Complex{AT}

function complex{S<:Real,T<:Real}(A::Array{S}, B::Array{T})
if size(A) != size(B); throw(DimensionMismatch()); end
Expand Down
2 changes: 1 addition & 1 deletion base/datafmt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ readcsv(io; opts...) = readdlm(io, ','; opts...)
readcsv(io, T::Type; opts...) = readdlm(io, ',', T; opts...)

# todo: keyword argument for # of digits to print
writedlm_cell(io::IO, elt::FloatingPoint, dlm, quotes) = print_shortest(io, elt)
writedlm_cell(io::IO, elt::AbstractFloat, dlm, quotes) = print_shortest(io, elt)
function writedlm_cell{T}(io::IO, elt::AbstractString, dlm::T, quotes::Bool)
if quotes && !isempty(elt) && (('"' in elt) || ('\n' in elt) || ((T <: Char) ? (dlm in elt) : contains(elt, dlm)))
print(io, '"', replace(elt, r"\"", "\"\""), '"')
Expand Down
12 changes: 6 additions & 6 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ end

@deprecate oftype{T}(::Type{T},c) convert(T,c)

@deprecate inf(x::FloatingPoint) oftype(x,Inf)
@deprecate nan(x::FloatingPoint) oftype(x,NaN)
@deprecate inf{T<:FloatingPoint}(::Type{T}) convert(T,Inf)
@deprecate nan{T<:FloatingPoint}(::Type{T}) convert(T,NaN)
@deprecate inf(x::AbstractFloat) oftype(x,Inf)
@deprecate nan(x::AbstractFloat) oftype(x,NaN)
@deprecate inf{T<:AbstractFloat}(::Type{T}) convert(T,Inf)
@deprecate nan{T<:AbstractFloat}(::Type{T}) convert(T,NaN)

export String
const String = AbstractString
Expand Down Expand Up @@ -281,7 +281,7 @@ end
@deprecate bool(x::Number) x!=0

@deprecate char(x) Char(x)
@deprecate char(x::FloatingPoint) Char(round(UInt32,x))
@deprecate char(x::AbstractFloat) Char(round(UInt32,x))
@deprecate integer(x::Char) Int(x)

@deprecate complex128(r::Real, i::Real) Complex128(r, i)
Expand Down Expand Up @@ -323,7 +323,7 @@ for (f,t) in ((:uint8,:UInt8), (:uint16,:UInt16), (:uint32,:UInt32), (:uint64,:U
(:int128,:Int128), (:uint128,:UInt128), (:signed,:Int), (:unsigned,:UInt),
(:integer,:Int), (:int,:Int), (:uint,:UInt))
@eval begin
@deprecate ($f)(x::FloatingPoint) round($t,x)
@deprecate ($f)(x::AbstractFloat) round($t,x)
@deprecate ($f)(x::Rational) round($t,x)
end
end
Expand Down
4 changes: 2 additions & 2 deletions base/dft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export fft, ifft, bfft, fft!, ifft!, bfft!,
plan_fft, plan_ifft, plan_bfft, plan_fft!, plan_ifft!, plan_bfft!,
rfft, irfft, brfft, plan_rfft, plan_irfft, plan_brfft

complexfloat{T<:FloatingPoint}(x::AbstractArray{Complex{T}}) = x
complexfloat{T<:AbstractFloat}(x::AbstractArray{Complex{T}}) = x

# return an Array, rather than similar(x), to avoid an extra copy for FFTW
# (which only works on StridedArray types).
complexfloat{T<:Complex}(x::AbstractArray{T}) = copy!(Array(typeof(float(one(T))), size(x)), x)
complexfloat{T<:FloatingPoint}(x::AbstractArray{T}) = copy!(Array(typeof(complex(one(T))), size(x)), x)
complexfloat{T<:AbstractFloat}(x::AbstractArray{T}) = copy!(Array(typeof(complex(one(T))), size(x)), x)
complexfloat{T<:Real}(x::AbstractArray{T}) = copy!(Array(typeof(complex(float(one(T)))), size(x)), x)

# implementations only need to provide plan_X(x, region)
Expand Down
Loading

0 comments on commit 99fa597

Please sign in to comment.