-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Project plan #2
Comments
@cjdoris For consistency in naming we should choose one of the following:
In the previous proposal it mixes terms. Which of the two do you prefer? |
I prefer But then if we go with 1 then logically we should also have |
I think just |
I'm OK with that. |
Hmm, Note that |
Does it? What does the type parameter mean? |
I was thinking about it earlier, and I definitely think that |
See Infinities.jl/src/Infinities.jl Line 264 in 3d27318
I currently represent it by the angle, but stored as But I don't think I actually use |
Projective Infinity (the infinity of the Riemann sphere) |
Yes please. As a general rule I think |
There's already https://github.com/scheinerman/RiemannComplexNumbers.jl No reason we couldn't add projective infinities in general though, if there's demand. |
Hmm, I think what we really want are union types that are subtypes of const RiemannSphere{T} = Union{Complex{T}, ComplexInfinity{T}} but we cannot since But what do you think about this: struct IntegerUnion{TYPES<:Union} <: Integer
types::TYPES
end
struct RealUnion{TYPES<:Union} <: Real
types::TYPES
end
struct ComplexUnion{TYPES<:Union} <: Number
types::TYPES
end
const ExtendedInt = IntegerUnion{Union{Int,RealInfinity}}
const ExtendedComplex{T} = ComplexUnion{Union{Complex{T},ComplexInfinity{T}}}
const RiemannSphere{T} = ComplexUnion{Union{Complex{T},Infinity}} |
Sorry, I was wrong: julia> Union{Real,Complex} <: Number
true So actually, my new proposal is have no special types for extended numbers and just do: const ExtendedInt = Union{Int,RealInfinity}
const ExtendedComplex{T} = Union{Complex{T},ComplexInfinity{T}}
const RiemannSphere{T} = Union{Complex{T},Infinity} What if any draw back would there be? |
Type instability and promotion craziness! This is what |
Small union types do not suffer from type instability: this is the whole point of |
I have done something similar.
|
Perhaps we should nail down |
That relies on the specifics of the Julia compiler, and the notion of "small union". If I have a |
Your example doesn't make any sense since Your logic applies also to |
To hammer down the point, a working example does type inferrence with union types: julia> @inferred(map(something, Union{Int,Nothing}[1,2]))
2-element Array{Int64,1}:
1
2 |
Or an example more close to home: julia> closeint(::Infinity) = typemax(Int)
closeint (generic function with 1 method)
julia> closeint(x::Int) = x
closeint (generic function with 2 methods)
julia> @inferred(map(closeint, [1,5,∞]))
3-element Array{Int64,1}:
1
5
9223372036854775807
No it does not, as the behaviour for |
|
The above is exactly the sort of thing that someone doing numerical computing shouldn't have to think about: the existing API for number types is that they promote to a common concrete type when mixed together. |
Also I suppose one fix would be to have a promotion rule |
Hmm, with the right overrides we can get things to work: julia> Base.typejoin(::Type{Vector{Infinity}}, ::Type{Vector{Int}}) = Vector{Union{Int,Infinity}}
julia> Base.typejoin(::Type{Vector{Int}}, ::Type{Vector{Infinity}}) = Vector{Union{Int,Infinity}}
julia> Base.promote_rule(::Type{Int}, ::Type{Infinity}) = Union{Int,Infinity}
julia> map(a->[a], [1,Infinity()])
2-element Array{Array{Union{Infinity, Int64},1},1}:
[1]
[∞] Though you are right it might be necessary to just have custom types, e.g., the last line is not type-inferred. |
PS: julia> map(a -> [a], [1,missing])
2-element Array{Array{T,1} where T,1}:
[1]
[missing] So it seems like a missing case in the compiler. |
My point was not specific to |
I get File Not Found. <<<< see below for a pdf version >>>> But the name reminds me to say that |
Agreed, you won the argument and these should be special types (at least until Julia v2.0 comes along and improves |
Glad I won you around :) What's happening in v2.0? Where do I go to find out such things? |
Was just being facetious...but perhaps they can be convinced to improve the type inference. (It might be pretty easy actually with an improved |
Arithmetic of ComplexInfinity |
Infinity <: Real
(replacesInfinity.Infinite
)InfiniteCardinal{K} <: Integer
(InfiniteCardinal{0}
replacesInfiniteArrays.Infinity
andInfiniteCardinal{K}
replacesContinuumArrays.AlephInfinity{K}
)RealInfinity <: Real
ComplexInfinity <: Number
for angled infinityInfiniteTime <: TimeType
InfExtended*
I'll plan to do 1--4 by copying over the code from InfiniteArrays.jl.
The text was updated successfully, but these errors were encountered: