>>> import numpy as np
>>> bb = np.matrix(np.arange(12).reshape((3,4)))
>>> bb
matrix([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> bb.cumsum(axis=0)
matrix([[ 0, 1, 2, 3],
[ 4, 6, 8, 10],
[12, 15, 18, 21]])
>>> bb.cumsum(axis=1)
matrix([[ 0, 1, 3, 6],
[ 4, 9, 15, 22],
[ 8, 17, 27, 38]])
>>> bb.cumprod(axis=0)
matrix([[ 0, 1, 2, 3],
[ 0, 5, 12, 21],
[ 0, 45, 120, 231]])
>>> bb.cumprod(axis=1)
matrix([[ 0, 0, 0, 0],
[ 4, 20, 120, 840],
[ 8, 72, 720, 7920]])