### Navigation

- index
- modules |
- modules |
- next |
- previous |
- NumPy v1.7 Manual (DRAFT) »
- NumPy Reference »
- Array objects »
- Standard array subclasses »
- numpy.matrix »

# numpy.matrix.sum

`matrix.``sum`(axis=None, dtype=None, out=None)

  Returns the sum of the matrix elements, along the given axis.

  Refer to `numpy.sum` for full documentation.

  See also

  `numpy.sum`

  Notes

  This is the same as `ndarray.sum`, except that where an `ndarray` would be returned, a `matrix` object is returned instead.

  Examples

      >>> x = np.matrix([[1, 2], [4, 3]])
      >>> x.sum()
      10
      >>> x.sum(axis=1)
      matrix([[3],
              [7]])
      >>> x.sum(axis=1, dtype='float')
      matrix([[ 3.],
              [ 7.]])
      >>> out = np.zeros((1, 2), dtype='float')
      >>> x.sum(axis=1, dtype='float', out=out)
      matrix([[ 3.],
              [ 7.]])

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- NumPy v1.7 Manual (DRAFT) »
- NumPy Reference »
- Array objects »
- Standard array subclasses »
- numpy.matrix »