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

Complex valued pow gives stackoverflow error #486

Open
GiggleLiu opened this issue Dec 2, 2020 · 1 comment
Open

Complex valued pow gives stackoverflow error #486

GiggleLiu opened this issue Dec 2, 2020 · 1 comment

Comments

@GiggleLiu
Copy link

julia> using ForwardDiff: Dual

julia> x = Complex(Dual(2, 1.0), Dual(3.0, 0.0))
Dual{Nothing}(2.0,1.0) + Dual{Nothing}(3.0,0.0)*im

julia> x^2
ERROR: StackOverflowError:
Stacktrace:
 [1] Complex at ./complex.jl:12 [inlined] (repeats 2 times)
 [2] float at ./complex.jl:1016 [inlined]
 [3] _cpow(::Complex{Dual{Nothing,Float64,1}}, ::Complex{Dual{Nothing,Float64,1}}) at ./complex.jl:780 (repeats 79984 times)

versioninfo: Julia v1.5.2, ForwardDiff v0.10.12

Also see the error report here: QuantumBFS/Yao.jl#263 (comment)
The second point.

@mcabbott
Copy link
Member

mcabbott commented Dec 4, 2024

The behaviour on ForwardDiff#master, i.e. 0.11-DEV which includes #481, is this:

julia> using ForwardDiff: Dual

julia> x = Complex(Dual(2, 1.0), Dual(3.0, 0.0))
Dual{Nothing}(2.0,1.0) + Dual{Nothing}(3.0,0.0)*im

julia> x^2
Dual{Nothing}(-5.0,4.0) + Dual{Nothing}(12.0,6.0)*im

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

2 participants