Haskell arrays : Libraries

1 | Single-linked lists | Data.Array and variants | Data.Vector and variants | hmatrix' Data.Packed.Vector | blas' Data.Matrix.*, Data.Vector.* etc. | Repa's Data.Array.Repa | |
---|---|---|---|---|---|---|---|

2 | General performance | Slow | Average | Fast | ? | ? | ? |

3 | Random access | O(N) | ? | O(1) | ? | ? | ? |

4 | Inplace update | No | in IO/ST variants | in MVector | in STVector | in IO- and ST- variants | No |

5 | |||||||

6 | 2D arrays | nested lists | Yes | No | Yes (Matrix) | Yes (Matrix) | Yes |

7 | n-dimensional arrays | nested lists | Yes | No | No | No? (Tensor?) | Yes |

8 | |||||||

9 | Unary elementwise ops | Yes, map | Yes, fmap | Yes | Yes, cmap for some types, mapVector | Yes, tmap | Yes, map |

10 | Binary elementwise ops | Yes, zipWith | No | Yes, with zipWith | Yes | Some | Yes, zipWith |

11 | Folds | Yes, foldr/foldl' | Yes, accum | Yes | Yes | No | Yes |

12 | |||||||

13 | Transpositions | Yes, O(N)? | Yes, ixmap | n/a | Yes | Yes, herm | Yes |

14 | Reshaping | No¹ | Yes, ixmap | n/a | Yes | Some (to/from Vector) | Yes |

15 | Slices aka strides (from:to:step) | No¹ | No | Yes, but only continuous | No | Yes, subvectorWithStride | Yes, with index transformations¹ |

16 | Blocks ([x0:x1]×[y0:y1]) | No¹ | No | Yes | Yes | Yes | No² |

17 | Stacking | No¹ | No | Yes, but O(N+M) | Yes, fromBlocks etc. | No | Yes |

18 | |||||||

19 | Linear algebra | No | No | No | Yes | Yes | No³ |

20 | |||||||

21 | Storable (interoperability with C) | Yes, Foreign.Marshall.Array | Only IO/ST variants | Only Storable variant | Yes | ?² | No |

22 | Unboxed (optimized memory footprint) | No | Only U-, IOU- and STU- variants | Only Storable, Unboxed and Primitive variants | Yes | Yes?³ | Yes |

23 | |||||||

24 | Parallel strategies | Yes | Yes | Only boxed variant | No | ? | Parallel by design |

25 | |||||||

26 | Stability | OK | OK | OK¹ | OK | OK¹ | experimental |

27 | GHC compatibility | any | GHC6, GHC7 | GHC6, GHC7 | GHC6, GHC7 | GHC6 only¹ | GHC7 |

28 | License | BSD3 | BSD3 | BSD3 | GPL | BSD3 | BSD3 |

29 | |||||||

30 | |||||||

31 | |||||||

32 | ¹ Can be simulated | ¹ To become a part of the Haskell platform | ¹ Last update: Jan 2009 | ¹ Repa's slices are different beasts | |||

33 | ² Probably yes, Storable elements; to check | ² Can be simulated with traverse | |||||

34 | ³ Can view in-memory array as a matrix | ³ There is an implementation of matrix multiplication on Hackage |