method
matrix.sum(axis=None, dtype=None, out=None)
Returns the sum of the matrix elements, along the given axis.
Refer to
for full documentation.
Notes
This is the same as
, except that where an
would be returned, a
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=np.float64)matrix([[3.], [7.]])>>> out=np.zeros((2,1),dtype=np.float64)>>> x.sum(axis=1,dtype=np.float64,out=np.asmatrix(out))matrix([[3.], [7.]])