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 openlibm jn and yn instead of AMOS #4187

Closed
stevengj opened this issue Aug 30, 2013 · 5 comments
Closed

use openlibm jn and yn instead of AMOS #4187

stevengj opened this issue Aug 30, 2013 · 5 comments
Labels
performance Must go faster
Milestone

Comments

@stevengj
Copy link
Member

For example, besselj(1,1.5) gives 0.5579365079100995, but bessely(1,1.5) gives a Complex result -0.4123086269739113 + 0.0im. There is no reason not to return a Real result for Real arguments.

@staticfloat
Copy link
Member

bessely is Real for positive-real input arguments, but for negative real it turns Complex again:

julia>  bessely(3,-3)
0.5385416161050315 - 0.6181254445105032im

Therefore, I don't think we can use type-inference on the inputs to determine the types outputs.

@ivarne
Copy link
Member

ivarne commented Aug 31, 2013

The sqrt() function solves this by throwing a DomainError if the argument is Real and negative. Thus you have to convert the argument to Complex if you want the complex result. I don't know the bessely function so this might not be intuitive for users, but I really like the approach for sqrt().

@StefanKarpinski
Copy link
Member

I suspect that following the pattern of sqrt here is the way to go.

@stevengj
Copy link
Member Author

stevengj commented Sep 2, 2013

I agree that following sqrt is the thing to do.

Note also that we are currently inconsistent: bessely0 and bessely1 give real results for positive real arguments, and NaN for negative real arguments.

(Also, it's not clear why we don't use openlibm's jn and yn functions for integer order and real arguments, rather than the slower complex AMOS routines, about 2× slower on my machine.)

@ivarne
Copy link
Member

ivarne commented Sep 9, 2013

besseli apparently also need to be changed.

JeffBezanson added a commit that referenced this issue Sep 13, 2013
add DomainErrors to some bessel functions, part of #4187
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

No branches or pull requests

4 participants