'Sum the matrix over the given axis.  If the axis is None, sum
over both rows and columns, returning a scalar.'

def sum(self, axis=None, dtype=None, out=None):

    if ((not hasattr(self, 'blocksize')) and (axis in self._swap(((1, (-1)), (0, 2)))[0])):
        res_dtype = get_sum_dtype(self.dtype)
        ret = np.zeros((len(self.indptr) - 1), dtype=res_dtype)
        (major_index, value) = self._minor_reduce(np.add)
        ret[major_index] = value
        ret = np.asmatrix(ret)
        if ((axis % 2) == 1):
            ret = ret.T
        if ((out is not None) and (out.shape != ret.shape)):
            raise ValueError('dimensions    do    not    match')
        return ret.sum(axis=(), dtype=dtype, out=out)
    else:
        return spmatrix.sum(self, axis=axis, dtype=dtype, out=out)
