-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
What about Complex{Irrational}? #21204
Comments
IMO we should add/widen methods to allow |
I tend to agree. They can be promoted to big(z::Complex{<:Irrational}) = Complex{BigFloat}(z) BTW, my fix for #21200 is to define exp2(z::Complex{<:Real}) = exp2(float(z)) and change the current signature of function exp2(z::Complex{T}) where {T<:AbstractFloat} Does it make sense? |
Might make sense to define a big{T<:Real}(z::Complex{T}) = Complex{big(T)}(z) could replace the separate ones for |
I'd like to work on this, but I'm unsure about what's the best way. I was going to define a method of float{T<:Number}(::Type{T}) = typeof(float(zero(T))) This is inefficient for Big* and doesn't handle |
big(::Type{<:Integer}) = BigInt
big(::Type{<:Union{AbstractFloat,Irrational}}) = BigFloat
big(::Type) = typeof(big(zero(T))) should suffice I would think. Backing up, how is |
Those methods allow promoting |
I really don't see the purpose of |
I don't have a particular purpose, but the type just exists, I don't see why making it impossible to use if it can be done with little effort (actually by improving other functions). In addition,
|
Hm, there cannot be an irrational zero, I am pessimistic about the last bullet point. |
You mean of allowing |
You can achieve |
Right. Though |
Each irrational number is a different type, given how The easiest fix is probably complex(x::Irrational) = Complex{Float64}(x) |
`complex(x::Irrational)` cannot create a `Complex{Irrational}` instance, we have to fall back on some other type, `Complex{Float64}` seems a reasonable option. Closes JuliaLang#22878, see JuliaLang#21204.
Create a `Complex{Real}` instance which preserves precision of the irrational number. Closes JuliaLang#22878, see JuliaLang#21204.
A
Complex{Irrational}
is allowed (e.g.,Complex(pi, pi)
), but there are a few functions that currently don't work with this type (e.g.,exp
,exp2
,exp10
;exp
can be easily fixed if #21203 is merged, the other two functions can be fixed as part of the fix to #21200).Should this type be kept (and non-working functions fixed) or automatically converted to, say,
Complex{Float64}
? I don't think this type is widely used (its odd representation in the REPL seems to confirm this) and any mathematical operation with it promotes it to another type, but I think that a decision should be taken about its status.TODO list:
big(complex(pi, pi))
work (PR Define methods for big(T) #21218)exp
(PR Make exp(::Complex{Irrational}) work #21596)sinpi(complex(pi, pi))
work (actually, not evensinpi(pi)
works right now). Same forcospi
. Requires More efficient float(T) for rationals and big*, works with Irrational #21219 (PR Fix sinpi and cospi with Irrational arguments #21781)log1p
: can be fixed withone(float(T))
in place offloat(one(T))
(which is also more efficient for Big numbers, only one number is allocated) if More efficient float(T) for rationals and big*, works with Irrational #21219 if merged (PR Fix log1p with complex Irrational argument #21784)exp2
andexp10
: see this comment below, requires PR More efficient float(T) for rationals and big*, works with Irrational #21219 (PR Fix complex exp2 and exp10 with boolean and irrational argument #21874)makeThe decision was to not makecomplex(pi)
work (PR Define method for complex(x::Irrational) #22928)complex(irrational)
work at all.The text was updated successfully, but these errors were encountered: