I’ve defined a type of symbolic number, FastDifferentiation.Node,
struct Node <: Real
...
end
that causes this error when used with Quaternions.jl
:
julia> using FastDifferentiation,Quaternions
julia> @variables x y z w #creates 4 FastDifferentiation.Node instances
w
julia> q = Quaternion(x,y,z,w)
Quaternion{FastDifferentiation.Node}(x, y, z, w)
julia> a = q/w
ERROR: MethodError: /(::Quaternion{FastDifferentiation.Node}, ::FastDifferentiation.Node) is ambiguous.
Candidates:
/(q::Quaternion, x::Real)
@ Quaternions ~/.julia/packages/Quaternions/UZIvR/src/Quaternion.jl:153
/(a::Number, b::FastDifferentiation.Node)
@ FastDifferentiation ~/.julia/packages/FastDifferentiation/TzEqR/src/Methods.jl:58
Possible fix, define
/(::Quaternion, ::FastDifferentiation.Node)
The suggested solution
Possible fix, define
/(::Quaternion, ::FastDifferentiation.Node)
is not practical since it would force FastDifferentiation
to take a dependency on Quaternions
or vice versa.
Arithmetic methods for FastDifferentiation.Node
are defined using the number_methods
macro, cribbed from SymbolicUtils.jl
. This creates a definition for / in the FastDifferentiation.jl
package:
/(a::Number, b::FastDifferentiation.Node)
Quaternion.jl
also defines a method for /:
/(q::Quaternion, x::Real)
These two methods appear to be the source of the ambiguity. I want the method defined in Quaternion.jl
to be called but am having trouble figuring out how.
What is the best way to fix this?