-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Have an exp
for pure imaginary numbers
#5625
Comments
There have been previous proposals/discussions for a (cos, sin) function, and, IIRC, an |
Alright, thanks. I'll take a look. Do you know off hand if there is a reason previous proposals haven't been incorporated? |
It seems to be a thing in mpmath |
I'd bet part of it is that the gains aren't very large relative to just On Monday, March 2, 2015, jakirkham notifications@github.com wrote:
|
@argriffing Thanks. I'll take a look. Though I still see some value in having it in NumPy. @ewmoore I'm not sure if you are referencing the implementation in C or Python. If you mean the latter, taking a few simple examples I find using |
There is a |
@charris Interesting. So, are you thinking that exposing a form of sincos in NumPy would be worthwhile? I think there is something similar in clang. |
Yes, I think it would be worthwhile, there are some common operations involved, reduction of interval, etc. Probably the easiest way to expose it would be as |
note glibc internally already uses sincos for the computation of cexp, so there is not much to gain. |
@juliantaylor but the NumPy version does not seem to use |
that is the fallback version for when libc does not provide the function. It should only be used on windows. On windows you also should not have sincos available. |
Ah ok, sorry, so is there some other code I should be looking at? |
should be
|
Alright, thanks for your help. I'm going to close this as using |
glibc does not do a real = 0 optimization so there is still a exp(0) call in there that makes some overhead. |
I sent a patch, not super significant but measureable |
@juliantaylor, the I don't know if this sort of thing still has an effect on performance, but it probably could be shortened to a ternary expression. On second thought, there should no longer be a need for the multiplication at the end in the event that the real part is |
It would be nice to have a pure imaginary
exp
implemented likenpy_cexp
, but only for pure imaginary arguments (maybenpy_iexp
ornpy_ciexp
). It would take a real value$\theta$
and evaluate$e^{i\cdot\theta}$
. The hope is this would be a little bit faster in cases where it is know there is no real part to the complex number.The text was updated successfully, but these errors were encountered: