Skip to content

NaNMath (and SpecialFunctions) as extensions? #648

@longemen3000

Description

@longemen3000

in particular, this code seems really weird:

ForwardDiff.jl/src/dual.jl

Lines 463 to 477 in 2263749

for (M, f, arity) in DiffRules.diffrules(filter_modules = nothing)
if (M, f) in ((:Base, :^), (:NaNMath, :pow), (:Base, :/), (:Base, :+), (:Base, :-), (:Base, :sin), (:Base, :cos))
continue # Skip methods which we define elsewhere.
elseif !(isdefined(@__MODULE__, M) && isdefined(getfield(@__MODULE__, M), f))
continue # Skip rules for methods not defined in the current scope
end
if arity == 1
eval(unary_dual_definition(M, f))
elseif arity == 2
eval(binary_dual_definition(M, f))
else
# error("ForwardDiff currently only knows how to autogenerate Dual definitions for unary and binary functions.")
# However, the presence of N-ary rules need not cause any problems here, they can simply be ignored.
end
end

in particular because NaNMath is loaded beforehand:

import NaNMath

The same thing can be said about SpecialFunctions.

I noticed that DiffRules also depends on NaNMath and SpecialFunctions, but does not load those packages. ForwardDiff does.

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