class_docstr: base matrix class for compressed row and column oriented matrices
class_docstr_tok: ["base","matrix","class","for","compressed","row","and","column","oriented","matrices"]
docstr: Sum the matrix over the given axis.  If the axis is None, sum
  over both rows and columns, returning a scalar.
code: def sum(self, axis=None, dtype=None, out=None):
      """Sum the matrix over the given axis.  If the axis is None, sum
      over both rows and columns, returning a scalar.
      """
      # The spmatrix base class already does axis=0 and axis=1 efficiently
      # so we only do the case axis=None here
      if (
          not hasattr(self, "blocksize")
          and axis in self._swap(((1, -1), (0, 2)))[0]
      ):
          # faster than multiplication for large minor axis in CSC/CSR
          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 = 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)
      # spmatrix will handle the remaining situations when axis
      # is in {None, -1, 0, 1}
      else:
          return spmatrix.sum(self, axis=axis, dtype=dtype, out=out)
  
imports: from __future__ import division, print_function, absolute_import
  from warnings import warn
  import operator
  import numpy
  from scipy._lib.six import zip
  from scipy._lib._util import _prune_array
  from .base import spmatrix, isspmatrix, SparseEfficiencyWarning
  from .data import _data_matrix, _minmax_mixin
  from .dia import dia_matrix
  from .None import _sparsetools
  from .sputils import upcast, upcast_char, to_native, isdense, isshape, getdtype, isscalarlike, IndexMixin, get_index_dtype, downcast_intp_index, get_sum_dtype, check_shape, matrix, asmatrix
label_desc: Use image node_id 24 for calling the _cs_matrix obj's underlying member method code with example usage: obj.sum(axis, dtype, out) and returns: ret, spmatrix