JuliaGeometry / Quaternions.jl

A Julia implementation of quaternions
https://juliageometry.github.io/Quaternions.jl
MIT License
116 stars 37 forks source link

abs broken with Symbolics #128

Open blegat opened 1 year ago

blegat commented 1 year ago

We used to be able to use Symbolics.Num in quaternions but https://github.com/JuliaGeometry/Quaternions.jl/pull/122/ broke our workflow; see https://github.com/dionysos-dev/Dionysos.jl/issues/211

The issue is that isinf is not defined for Num types defined in Symbolics. Maybe these could be done only for AbstractFloat ?

cc @sethaxen

sethaxen commented 1 year ago

Thanks for the issue! I don't think the solution is to restrict the more accurate branch to AbstractFloat, because then we would hit the less accurate branch whenever using wrappers of floating point numbers, e.g. those in ForwardDiff and ReverseDiff.

A better way is probably to specialize abs(::Quaternion{Num}) to hit the simpler version. On Julia v1.9, we can do this with a package extension (suggested in https://github.com/JuliaGeometry/Quaternions.jl/issues/123#issuecomment-1404150924). It makes more sense to include such an extension QuaternionsSymbolicsExt here than in Symbolics.