[GHC] #8061: Support for Complex Double in Foreign Function Interface

GHC ghc-devs at haskell.org
Wed Nov 6 22:41:36 UTC 2013


#8061: Support for Complex Double in Foreign Function Interface
-------------------------------------+------------------------------------
        Reporter:  dsamperi          |            Owner:
            Type:  feature request   |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.6.3
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by carter):

 hey,

 1) nope, and wont until 7.10 at the earliest. That said, theres a pretty
 easy work around

 2) theres a very very easy work around, just use storable instances, some
 tiny storable vectors and do a wee pointer wrapper!
 I have that for some C code I wrote for complex numbers. heres an example
 that does that boxing for a scalar complex double result for dot product.
 You'll have to write your own wee C wrapper for each thing, but its not
 much work and will work with a wide range of GHC versions (which is never
 a bad thing)

 {{{
 /// NOTE: complex valued dot products have a different type than the real
 float dot products
 /// this is important to remember!

 void arrayDotProduct_complex_double(int32_t length, complex_double  *
 left, int32_t leftStride ,complex_double  *   right,int32_t rightStride,
 complex_double * resultSingleton);

 void arrayDotProduct_complex_double(int32_t length, complex_double  *
 left, int32_t leftStride ,complex_double  *   right,int32_t rightStride,
 complex_double * resultSingleton){
     complex_double result =
 arrayDotProduct_internal_complex_double(length,left,leftStride,right,rightStride);
     resultSingleton[0] = result ;
 }


 void arrayDotProduct_complex_float(int32_t length, complex_float  *
 left, int32_t leftStride ,complex_float  *   right,int32_t rightStride,
 complex_float * resultSingleton);

 void arrayDotProduct_complex_float(int32_t length, complex_float  *
 left, int32_t leftStride ,complex_float  *   right,int32_t rightStride,
 complex_float * resultSingleton){
     complex_float result =
 arrayDotProduct_internal_complex_float(length,left,leftStride,right,rightStride);
     resultSingleton[0] = result ;
 }
 }}}

 3) asking me on a ticket is probably the most inefficient way to find out,
 you'll hear about the initial release very soon though :)

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8061#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list