achirkin / easytensor

Many-dimensional type-safe numeric ops
https://hackage.haskell.org/package/easytensor
BSD 3-Clause "New" or "Revised" License
46 stars 2 forks source link

instances for ad package missing #31

Open aavogt opened 2 years ago

aavogt commented 2 years ago

Hi I would like to use easytensor with ad but instance Quaternion (Reverse s Double) is missing. Perhaps the methods of class Quaternion can be ordinary functions on newtype Quater a = Quater (Vector a 4) with SPECIALIZE pragmas for Double and Float. Then Numeric.Quaternion.Internal.QDouble and QFloat duplication will be gone, and maybe the numbers defined by ad will also work.

achirkin commented 2 years ago

Thanks for the suggestion! Perhaps, we'd need to check how it plays with the unboxed unlifted element types, since the language support for this has become much better in the recent versions of ghc. Actually, I wanted to replace the two with the SIMD vectors at some point (which is currently easy, but I'm not sure if that's possible with rewrite rules alone). If you manage to do this, a PR would be greatly appreciated! Alternatively, you can try to implement your new quaternion type and the corrseponding class instance.