-
-
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
log(im) not implemented #5295
Comments
See #4922, for some discussion about why we have this situation. |
On 4 Jan 2014, at 7:02 pm, Ivar Nesje notifications@github.com wrote:
|
Closing this as a dup of #4922. The discussion can continue there. |
Closing as a dup of a closed PR? |
Oops, I didn't realize that the PR was also closed. |
I think they're all supposed to be closed as we decided not to treat a standalone |
Perhaps we should note this in our documentation, before closing this. |
Yes, and this issue is now (as so many other issues) about giving a better error message. It seems that |
There is a genuine issue about Although in #4922, @JeffBezanson wrote that the alternative to current behavior would lead to problems like:
However, we already have these problems and so have the worst of both worlds at the moment (where functions over julia> im==complex(false,true)
true I assume the NaN problem refers to the issue which Kahan points out [pdf], namely that automatically promoting all operations on julia> 4*complex(Inf, 5)
Inf + 20.0im
julia> complex(4,0)*complex(Inf, 5)
complex(Inf,NaN) While this works correctly for julia> 4im*complex(Inf,5) #Expect complex(-20,Inf)
NaN + Inf*im or in other words, that the current arithmetic rules obtained via type promotion retain half the "NaN problem". This can be fixed fairly simply with parentheses, viz.: julia> 4(im*complex(Inf,5))
complex(-20.0,Inf) so it could be simply an order-of-operations issue. (and similarly with division) For addition and subtraction, however, I don't see how to rescue the sign-of-zero problem without special casing: julia> 4.0 + complex(5.0, -0.0)
9.0 - 0.0im
julia> complex(4.0) + complex(5.0, -0.0) #0.0 + (-0.0) == 0.0
9.0 + 0.0im
julia> 4.0im + complex(-0.0, 5.0) #expect -0.0 + 9.0im
0.0 + 9.0im |
I fairly strongly support the addition of a purely imaginary type. I suspect that we can define |
Since Imaginary would have to have a Number parameter, would defining im as Imaginary(true) incur cost in type promotion? |
No, I don't think so. I'm actually working on a pr for this, so we'll see how it works out. |
See #5313. |
We would still face the question of whether to implement every function for the Half seriously, would we define |
Fixed by #5468, since |
Looks like the lack of a pure imaginary type continues to haunt us; c.f. #9531 |
log(im)
no method log(ImaginaryUnit)
while loading In[39], in expression starting on line 1
But log(1.im) works.
The text was updated successfully, but these errors were encountered: