Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inv not working on Quaternion{Num} #123

Open
knuesel opened this issue Dec 21, 2022 · 3 comments
Open

inv not working on Quaternion{Num} #123

knuesel opened this issue Dec 21, 2022 · 3 comments

Comments

@knuesel
Copy link

knuesel commented Dec 21, 2022

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
@hyrodium
Copy link
Collaborator

I think the method inv(q::Quaternion) should be defined in Symbolics.jl because:

  • Base.inv(z::Complex{Num}) is defined on Symbolics.jl
  • Quaternions.jl should be a lightweight package that does not have a dependency on Symbolics.jl.

@sethaxen
Copy link
Collaborator

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.

@hyrodium
Copy link
Collaborator

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.

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

No branches or pull requests

3 participants