Initial implementation of the sparse matrix.

@bsoetaer 
Tests pass when the contracts are disabled.
Should be each_with_index for this line and the next I believe.