Change sparsity to use rmult and cmult. Fix matrix assembly for the flattened case.