|  | 
| 1 | 1 | module Infinities | 
| 2 | 2 | 
 | 
| 3 |  | -import Base: angle, isone, iszero, isinf, isfinite, abs, one, oneunit, zero, isless, | 
|  | 3 | +import Base: angle, isone, iszero, isinf, isfinite, abs, one, oneunit, zero, isless, inv, | 
| 4 | 4 |                 +, -, *, ==, <, ≤, >, ≥, fld, cld, div, mod, min, max, sign, signbit, | 
| 5 | 5 |                 string, show, promote_rule, convert, getindex | 
| 6 | 6 | 
 | 
| @@ -42,6 +42,7 @@ one(::Type{Infinity}) = 1 | 
| 42 | 42 | oneunit(::Type{Infinity}) = 1 | 
| 43 | 43 | oneunit(::Infinity) = 1 | 
| 44 | 44 | zero(::Infinity) = 0 | 
|  | 45 | +zero(::Type{Infinity}) = 0 | 
| 45 | 46 | 
 | 
| 46 | 47 | struct RealInfinity <: Real | 
| 47 | 48 |     signbit::Bool | 
| @@ -70,6 +71,13 @@ show(io::IO, y::RealInfinity) = print(io, string(y)) | 
| 70 | 71 | 
 | 
| 71 | 72 | Base.to_index(i::RealInfinity) = convert(Integer, i) | 
| 72 | 73 | 
 | 
|  | 74 | +one(::Type{RealInfinity}) = 1.0 | 
|  | 75 | +oneunit(::Type{RealInfinity}) = 1.0 | 
|  | 76 | +oneunit(::RealInfinity) = 1.0 | 
|  | 77 | +zero(::RealInfinity) = 0.0 | 
|  | 78 | +zero(::Type{RealInfinity}) = 0.0 | 
|  | 79 | + | 
|  | 80 | + | 
| 73 | 81 | ####### | 
| 74 | 82 | # ComplexInfinity | 
| 75 | 83 | ####### | 
| @@ -110,6 +118,12 @@ angle(x::ComplexInfinity) = π*x.signbit | 
| 110 | 118 | 
 | 
| 111 | 119 | show(io::IO, x::ComplexInfinity) = print(io, "exp($(x.signbit)*im*π)∞") | 
| 112 | 120 | 
 | 
|  | 121 | +one(::Type{<:ComplexInfinity}) = one(ComplexF64) | 
|  | 122 | +oneunit(::Type{<:ComplexInfinity}) = oneunit(ComplexF64) | 
|  | 123 | +oneunit(::ComplexInfinity) = oneunit(ComplexF64) | 
|  | 124 | +zero(::ComplexInfinity) = zero(ComplexF64) | 
|  | 125 | +zero(::Type{<:ComplexInfinity}) = zero(ComplexF64) | 
|  | 126 | + | 
| 113 | 127 | Base.hash(::Infinity) = 0x020113134b21797f # made up | 
| 114 | 128 | 
 | 
| 115 | 129 | 
 | 
|  | 
0 commit comments