Sparse array representation?

82 views
Skip to first unread message

Mark Flamer

unread,
Dec 3, 2012, 2:54:08 AM12/3/12
to haskel...@googlegroups.com
I am working on a sparse matrix library in Haskell. After studying the repa3 library more closely, it seems like a good base would be to add some sparse array representations to repa instead of starting from scratch. I came to this conclusion because I'm fining myself wanting to recreate a lot of the structure that has already been worked out, like Source and Target classes for immutable and mutable arrays. Is there any reason this would not work? Thanks.  

Ben Lippmeier

unread,
Dec 3, 2012, 8:11:17 AM12/3/12
to Mark Flamer, haskel...@googlegroups.com

On 03/12/2012, at 18:54 , Mark Flamer wrote:

> I am working on a sparse matrix library in Haskell. After studying the repa3 library more closely, it seems like a good base would be to add some sparse array representations to repa instead of starting from scratch. I came to this conclusion because I'm fining myself wanting to recreate a lot of the structure that has already been worked out, like Source and Target classes for immutable and mutable arrays. Is there any reason this would not work? Thanks.

We (meaning the DPH/Repa team at UNSW and I) are also interested in sparse matrix algorithms.

If you start a project based on Repa you should consider using Repa 4 which is under active development. Repa 4 is embodied in the repa-bulk, repa-flow and repa-vector packages in the source repository. When this code is completed the repa-vector package will be renamed to 'repa' and replace the package currently on Hackage.

The main changes for Repa 4 are:
1) The representation of most array operators now depends on their source representations. This means all operators become like the Structured 'smap' and 'szipWith' methods of Repa 3.
2) We have an additional fusion mechanism called 'data flow fusion' which coexists with the original Repa index-transform based fusion.
3) The data flow fusion framework supports filtering and segmented operators for vectors, which we don't have in Repa 3.

In particular, you can express algorithms on sparse compressed row matrices using the Repa 4 segmented operators. Check out [1] for a simple sparse-matrix /dense-vector multiply routine.

Other things:
1) The Repa 3 'Source' class is replaced by 'Bulk' in Repa 4.
2) Repa 4 will include the 'Target' class, but I haven't 'ported across the code yet.

Repa 4 is my main project right now. There are a few pieces missing, but it should match the base Repa 3 functionality within a couple of weeks.

You should be able to use "cabal haddock" to build the docs for the repa-bulk, repa-flow and repa-vector packages. Feel free to ask any other questions you might have.

Cheers,
Ben.

[1] http://code.ouroborus.net/repa/repa-head/repa-examples/examples/SMVM/Solver.hs


Reply all
Reply to author
Forward
0 new messages