skelterjohn/go.matrix — pull request #8 by sbroadfoot90 (2013-03-01 13:58:55+00:00)
Title: Fixed some problems with the implementation of sparse matrices

Hey John,

I had some time to fix up lots of the bugs in the sparse implementation. In particular, when iterating over the elements in the map, you generally would only want to change those elements that are valid members of the current matrix, and not part of some larger matrix.

I think it would be good to make two more significant changes to the package. One would be to change all matrix indexes to an unsigned integer type (probably uint64). One reason is that integer division rounds towards 0 so for the conversions from index to row/col, you can get unexpected results if you don't first check for negatives.

The other major change would be to not export any functions that refer to indexes for sparse matrices. This basically reveals the details of the implementation and if you later want to change the implementation of sparse, or the type of the keys for your map (perhaps to a struct with row and column fields), then you are going to have to break a lot of people's code.

I'm happy to have a go at making these changes if you don't mind.