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

Use dual-like type to reimplement cauchy(f,x,s) #81

Closed
dlfivefifty opened this issue Oct 28, 2016 · 2 comments
Closed

Use dual-like type to reimplement cauchy(f,x,s) #81

dlfivefifty opened this issue Oct 28, 2016 · 2 comments

Comments

@dlfivefifty
Copy link
Member

The current usage of s to indicate left/right limit is error prone. It should be replaced by a special type DirectedNumber, which special functions like log, etc. override.

(I want to think about whether a more general notion of choice of branch would be better.)

@dlfivefifty
Copy link
Member Author

This works:

"""
`Directed` represents a number that is a limit from either left (s=true) or right (s=false)
"""
immutable Directed{s,T}
    x::T
end

Base.convert{s}(::Type{Directed{s}},x) = Directed{s,eltype(x)}(x)
*{s}(a::Directed{s},b::Number) = Directed{s}(a.x*b)
*{s}(b::Number,a::Directed{s}) = a*b

const= Directed{true}(true)
const= Directed{false}(true)

11

I think all it takes then is to consider log, etc. oriented from [0,-∞) not (-∞,0], at least for _2F1 where we need to use -z.

@dlfivefifty
Copy link
Member Author

Implemented and merged!

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

1 participant