InfiniteArrays.jl
InfiniteArrays.jl copied to clipboard
How is `0.0:0.0:∞` handled?
Currently this cannot be constructed with colons.
julia> 0.0:0.0:∞
ERROR: ArgumentError: InfStepRange must have infinite length
Stacktrace:
[1] (::Colon)(start::Float64, step::Float64, stop::Infinities.Infinity)
@ InfiniteArrays C:\Users\pty\.julia\dev\InfiniteArrays\src\infrange.jl:19
[2] top-level scope
@ REPL[40]:1
It can be generated using the type constructor or manipulating ranges.
julia> (1.0:∞)-(1.0:∞)
0.0:0.0:+∞
julia> InfStepRange(0.0,0.0)
0.0:0.0:+∞
julia> InfStepRange(0,0)
0:0:+∞
This is the same strategy that Julia Base uses. StepRangeLen is well defined for this purpose, while InfStepRange is ambiguous on what the stop
should be.
julia> (1.0:5.0)-(1.0:5.0)
StepRangeLen(0.0, 0.0, 5)
julia> (1:5)-(1:5)
StepRangeLen(0, 0, 5)
InfUnitRange has a different pipeline.
julia> (1:∞)-(1:∞)
ℵ₀-element Fill{Int64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}} with indices OneToInf(), with entries equal to 0
There is a case where 0.0:0.0:∞
has a problem, although it doesn't have much to do with the type definitions.
julia> r = InfiniteArrays.InfStepRange(0.0,0.0)
0.0:0.0:+∞
julia> s=-r
-0.0:-0.0:-∞
julia> last(s),last(r)
(-∞, +∞)
julia> s[end],r[end]
(ℵ₀, ℵ₀)
julia> s==r
false
iszero(0.0:0.0:+∞)
currently falls into infinite loop.
This change is related: https://github.com/JuliaArrays/InfiniteArrays.jl/pull/122