Skip to content

Complex valued pow gives stackoverflow error #486

Closed

Description

@GiggleLiu
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.

Activity

  1. mcabbott commented on Dec 4, 2024

    @mcabbott
    Member

    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
  2. KristofferC commented on Mar 26, 2025

    @KristofferC
    Collaborator

    Since it doesn't stackoverflow anymore I will close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions