'Returns a dense matrix representing self.
Mainly for debugging purposes.'

def to_dense(self):

    ret = np.zeros([self.n, self.m], dtype=np.float64)
    nvals = self.vals.size
    for i in range(nvals):
        ret[(self.rows[i], self.cols[i])] += self.vals[i]
    return ret
