JuliaDiff / DualNumbers.jl

Julia package for representing dual numbers and for performing dual algebra
Other
80 stars 30 forks source link

fix use of global variables #35

Closed KristofferC closed 8 years ago

KristofferC commented 8 years ago

global variables bad for performance etc

Fixes:

julia> @code_warntype foo()
Variables:
  d::DualNumbers.Dual{Float64}
  a::Any

Body:
  begin  # none, line 2:
      a = 0.0 # none, line 3:
      d = $(Expr(:new, DualNumbers.Dual{Float64}, 1.0, 1.0)) # none, line 5:
      a = a::Float64 + (Main.dualpart)(d::DualNumbers.Dual{Float64})::Any::Any # none, line 6:
      return a
  end::Any
mlubin commented 8 years ago

Thanks!

KristofferC commented 8 years ago

Maybe should tag a new version since realpart is used in Optim for example.

KristofferC commented 8 years ago

I could do it... with permission.

mlubin commented 8 years ago

Granted