Skip to content

Complex needs more specialization. #389

@TravisWhitaker

Description

@TravisWhitaker

The base module Data.Complex includes specializations of most numerical functions and instances for Complex Double and sometimes Complex Float. The current set omits three sorts of specializations that may have quite severe negative performance impacts on downstream code:

  1. Many functions have specializations for Complex Double only, while downstream code would benefit from Complex Float as well.
  2. The Storable instance has no specializations. This is problematic for a variety of downstream applications, e.g. this observed ~100x slow down of operations on storable vectors containing Complex Doubles: Complex somehow destroys the performance of operations on storable vectors. vector#558
  3. It is quite common for programs manipulating complex numbers to deal with fixed width integer types. Complex Int8 and Complex Int16 specializations would be very helpful (Complex Int32 and Complex Int64 perhaps less so).

Therefore I propose that base:

  1. Add SPECIALISE ... Complex Float to the set of specialized functions and instances.
  2. Add the Storable instance to the set of specialized functions and instances.
  3. Add SPECIALISE ... Complex Int{8,16} to the set of specialized functions and instances.
  4. Add SPECIALISE ... ComplexInt{32,64} to the set of specialized functions and instances if anyone can find a person or program who cares for them to be added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaits-MRNo GHC MR (https://gitlab.haskell.org/ghc/ghc/-/merge_requests) has been raised yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions