Skip to content
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

distinct types for positive and negative (Real) infinity #5

Open
tpapp opened this issue Feb 11, 2021 · 18 comments
Open

distinct types for positive and negative (Real) infinity #5

tpapp opened this issue Feb 11, 2021 · 18 comments

Comments

@tpapp
Copy link

tpapp commented Feb 11, 2021

In order to make use of this package for TransformVariables.jl, I would like to ask for distinct types for positive and negative (real) infinity, ideally accessible with and -∞. I need types I can dispatch on for type stability.

Basically this code does what I need.

(cf discussion)

@dlfivefifty
Copy link
Member

OK I misunderstood. I thought you wanted const ∞ = SignedInfinity() so that typeof(-∞) == typeof(∞). But it sounds like you really want to change it so and -∞ are two different types.

I see zero problems. Would you be willing to make a PR?

@tpapp
Copy link
Author

tpapp commented Feb 11, 2021

Sure. Should I just extend Infinity with a type parameter for the sign bit?

@dlfivefifty
Copy link
Member

Yes, just replace struct Infinity <: Real end with struct Infinity{signbit} <: Real end, as you are doing.

@JeffreySarnoff
Copy link
Member

related #6

@tpapp
Copy link
Author

tpapp commented Feb 16, 2021

@dlfivefifty: I am kind of done with this change, but before making a PR, I thought I would ask if I should keep RealInfinity, or remove it. TBH, I think with the proposed change it becomes redundant, and the special cases of op(::Infinity, ::RealInfinty) are numerous and make maintaining this package more difficult.

@dlfivefifty
Copy link
Member

I think I'm OK either way.

@cjdoris do you have any opinions?

@JeffreySarnoff
Copy link
Member

JeffreySarnoff commented Feb 16, 2021

I do not want to advocate for something that mostly brings crossclutter. If you are trimming Infinities, I would choose to keep ProjectiveInfinity over ComplexInfinity because it is a more flexible concept (geometrical as well as Riemannian extension). If RealInfinity be dropped, then ComplexInfinity is more terminology than portion.

AbstractInfinity as a shared locus of typic infinite realizations is, imo, good math.

@dlfivefifty
Copy link
Member

ComplexInfinity is needed in ApproxFun to represent contours going to infinity at an angle

AbstractInfinity can be done as a union type, with a different name

@JeffreySarnoff
Copy link
Member

ok (thanks to each of you for this effort)

@dlfivefifty
Copy link
Member

For comparison: Mathematica is usually a good reference implementation, which only has DirectedInfinity, which is analogous to ComplexInfinity.

A special case is DirectedInfinity[] (also known as ComplexInfinity) which corresponds to an infinity with no known direction, which we can take to mean the same as ProjectiveInfinity.

I'm surprised not to see any cardinal numbers in Mathematica. So I'm not sure if there's a reference implementation for them. I only needed ℵ₁ in ContinuumArrays.jl to represent a notion of length for intervals.

@tpapp
Copy link
Author

tpapp commented Feb 17, 2021

Just to clarify: I am not planning to touch anything other than Infinity (extend) and RealInfinity (remove) in the upcoming PR.

They can be renamed later on as far as I am concerned. I will wait few days for input from @cjdoris regarding the removal of RealInfinity; it would be best to arrive at a consensus and there is no need to rush.

@cjdoris
Copy link

cjdoris commented Feb 26, 2021

To be honest, my personal interest in this package is in the InfExtended* types which I am yet to migrate over from Infinity.jl (partly time, partly letting these questions be resolved.)

I'm not especially wed to RealInfinity, I'll leave it to you to decide the best type system for the "pure infinity" types. It doesn't affect InfExtended* too much, the main interaction will be that there will be some promotion rules such as Infinity + Real => InfExtendedReal.

I'm a bit lost, can you summarise the proposed types?

PS Sorry I didn't notice the mention.

@dlfivefifty
Copy link
Member

I think the proposal is to add Infinity{posneg}() in place of RealInfinity(posneg). Everything else will stay the same.

@cjdoris
Copy link

cjdoris commented Feb 26, 2021

Ah ok. Is it <: Real?

@tpapp
Copy link
Author

tpapp commented Feb 26, 2021

For my purposes, it does not have to be, but it is fine if it is. You decide.

@cjdoris
Copy link

cjdoris commented Feb 26, 2021

I also don't mind, just curious. I think it's natural, since they coincide with Inf and -Inf.

@tpapp
Copy link
Author

tpapp commented Feb 26, 2021

Thanks for the feedback, this is sufficient for me to complete the PR, I hope to finish it soon.

@dlfivefifty
Copy link
Member

Yes we would want <: Real so that it can replace RealInfinity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants