What do I need? [an unordered list]
-
VERY easy parallelization
- support for map, filter etc.
- ability to perform array based computations efficiently, like A=B+C, sort of like matlab arrays.
- Generation of SIMD code. I guess this is out of the question in the near future for anything, but hey, I can ask :)
- support for matrices should be there at a minimum, higher dimensions are lower priority right now.
- ability to get a pointer to it and create one from a C pointer.
- Support from other libraries. IE, bindings to popular C math packages, i/o to disk or images if the arrays are 2D
What do I see?
- Array package in haskell-platform. It's the blessed one and can do parallel
- Data.Vector. Has loop fusion, but not in platform, so its maturity is unknown to me.
- repa package, contributed by the DPH team, but doesn't work well with any stable ghc today.
- Lots of variation in the level of support for array implementations. For instance, there doesn't seem to be an easy way to dump a 2D vector to a image file. IOW, the haskell community apparently hasn't settled on an array implementation.
So please, help me choose.
EDIT A=B+C refers to element wise addition, and not list concatenation
Correct, the community hasn't settled on a good array implementation. I think it would be a good Haskell Prime submission to put forward the Vector API and remove Data.Array.
Vector is very mature! It has:
- VERY easy parallelization
- support for map, filter etc.
- performs array based computations efficiently, like A=B+C (but I'm not in tune with how matlab does it)
- vector creation from a pointer via Vector.Storable
It does not:
- have enough support from other libraries. IE, bindings to popular C math packages
- support matrices, but you can have vectors of vectors. If you build some vector-based matrix operations then perhaps you could upload to hackage as vector-matrix.
- Generate SIMD code.
NOTE: You can turn bytestrings into vectors of whatever, so if you have an image as a bytestring then, via Vector.Storable, you might be able to do what you want with the image as a vector.
(I am not allowed to comment)
rpg: Does hmatrix accept Data.Vector
? It has a Data.Packed.Vector
but are they the same?
Yes. The last version of hmatrix uses by default Data.Vector.Storable
for 1D vectors (previously it was optional). The dependency on vector is not shown in Hackage, probably because it is in a configuration flag.
For LAPACK compatibility matrices are not Vector
or Vector t
, but they can be easily converted (e.g.: Data.Vector.fromList . toRows
).