
#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: -------------------------------------+------------------------------------ Changes (by carter): * cc: carter.schonwald@… (added) Comment: this is a matter near and dear to me. the best way to work around this in current GHC (and indeed what i'll be doing soon) is to have a wrapper on the C/Fortran side that takes a pointer to a single element storable array for a Complex Floats and Complex Doubles. I'll then pass a pointer to a single elem array via FFI, and read the answer from the storable array on the haskell side. For any interesting numerical algorithms, i believe this trick, which would be internal/private to the library, is not likely to be any performance bottle neck. the complex number case is pretty easy to handle that way. Also you shouldn't use hs-linear-algebra, no ones maintaining it (i spent some time trying to clean it up, decided it wasn't worth it, will be releasing my own alternative in a few weeks) though because complex doubles and floats have a memory layout specified by the ieee (i believe), adding support via a scheme like what Simon is suggesting would be pretty nice I *believe* that for general structs, it might be less clear... aren't C structure padded to satisfy platform specific alignment constraints? Is that specified per platform ABI? @Simon, GHC HEAD in the -fllvm path could pretty cheaply have unboxed complex numbers using the SIMD machinery on supported platforms. (gratned... that wouldn't quite be portable and the native code gen needs some simd love before such a rep would be viable) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8061#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler