[Haskell-cafe] Vector (or List) to CArray?

Judah Jacobson judah.jacobson at gmail.com
Thu Jan 19 23:12:40 CET 2012

On Thu, Jan 19, 2012 at 10:15 AM, Dominic Espinosa <dcespin at fastmail.fm> wrote:
> Hello,
> I'm trying to use the fftw binding, and its functions operate on CArrays of
> Complex. My data is coming from hsndfile, so it starts out as a Vector of
> Double. How do I convert this data to CArray? The API functions in the
> CArray module don't seem to indicate how.

My first recommendation would be to use the vector-fftw package, which
uses Vectors instead of CArrays.  But as the author of that package I
may be a bit biased.

Alternately, converting between CArrays and Vectors isn't too hard if
you want to do it directly.  For example, you can convert from Vector
to CArray by using Data.Vector.Storable.unsafeToForeignPtr and
Data.Array.CArray.Base.unsafeForeignPtrToIOCArray.  Other functions in
those modules will let you go in the other direction.


More information about the Haskell-Cafe mailing list