-
-
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
cumsum loses the sign of zero imaginary part #18336
Comments
Similarly for julia> cumprod!(Array{Complex128}(1), -0.0im + (0:0))
1-element Array{Complex{Float64},1}:
0.0+0.0im |
Is it too horrible a hack to simply change Line 445 in 40c0fc6
|
Or we could just use |
Would it be really breaking if |
Note that this is not specific to complex arithmetic:
|
Well -- if we're not changing Another option would be to change By the way: julia> cumsum([])
ERROR: BoundsError: attempt to access 0-element Array{Any,1} at index [1]
in cumsum(::Array{Any,1}) at ./arraymath.jl:480 |
@eschnett, |
|
2-element arrays also don't work correctly: julia> cumsum([-0.0, -0.0])
2-element Array{Float64,1}:
0.0
0.0
julia> sum([-0.0, -0.0])
-0.0 |
That definitely is an argument to start at the additive identity, whether or not |
I think I should probably mention that there is an argument over whether isequal(-0.0, 0.0) should return true. #18485 |
I'm not sure one can unambiguously say this was wrong. For example: julia> 1.7 - 0.0im + convert(Vector{Complex128}, [0:7;])
8-element Array{Complex{Float64},1}:
1.7+0.0im
2.7+0.0im
3.7+0.0im
4.7+0.0im
5.7+0.0im
6.7+0.0im
7.7+0.0im
8.7+0.0im If one considers that promotion should happen before arithmetic, then the given result is simply a consequence of the fact that |
(I would have expected
-0.0im
imaginary parts.)Similarly for
cumprod
.The text was updated successfully, but these errors were encountered: