Quaternions.jl
Quaternions.jl copied to clipboard
inv not working on Quaternion{Num}
The inv function doesn't work for quaternions of Symbolics.Num type:
julia> using Quaternions, Symbolics
julia> q = quat(Num.([0,0,0,1])...)
Quaternion{Num}(0, 0, 0, 1)
julia> inv(q)
ERROR: MethodError: /(::Quaternion{Num}, ::Num) is ambiguous. Candidates:
/(a::Number, b::Num) in Symbolics at /home/j/.julia/packages/SymbolicUtils/qulQp/src/methods.jl:71
/(q::Quaternion, x::Real) in Quaternions at /home/j/.julia/packages/Quaternions/kqEsP/src/Quaternion.jl:123
Possible fix, define
/(::Quaternion, ::Num)
Stacktrace:
[1] inv(q::Quaternion{Num})
@ Quaternions ~/.julia/packages/Quaternions/kqEsP/src/Quaternion.jl:143
[2] top-level scope
@ REPL[3]:1
I think the method inv(q::Quaternion) should be defined in Symbolics.jl because:
Base.inv(z::Complex{Num})is defined on Symbolics.jlQuaternions.jlshould be a lightweight package that does not have a dependency on Symbolics.jl.
On Julia v1.9 this could be done by setting up a weakdep of Symbolics on Quaternions or the other way around. I'm not certain which makes more sense.
It seems the issue is not just implementations of /(::Quaternion{Num}, ::Num), inv(::Quaternion{Num}) etc.
For example, we need a quaternionic version of Symbolics.ComplexTerm, so the problem is not that simple and that should not be finished in this package.