MCPcopy Create free account
hub / github.com/numpy/numpy / prod

Method prod

numpy/matrixlib/defmatrix.py:516–547  ·  view source on GitHub ↗

Return the product of the array elements over the given axis. Refer to `prod` for full documentation. See Also -------- prod, ndarray.prod Notes ----- Same as `ndarray.prod`, except, where that returns an `ndarray`, this ret

(self, axis=None, dtype=None, out=None)

Source from the content-addressed store, hash-verified

514 return N.ndarray.var(self, axis, dtype, out, ddof, keepdims=True)._collapse(axis)
515
516 def prod(self, axis=None, dtype=None, out=None):
517 """
518 Return the product of the array elements over the given axis.
519
520 Refer to `prod` for full documentation.
521
522 See Also
523 --------
524 prod, ndarray.prod
525
526 Notes
527 -----
528 Same as `ndarray.prod`, except, where that returns an `ndarray`, this
529 returns a `matrix` object instead.
530
531 Examples
532 --------
533 >>> x = np.matrix(np.arange(12).reshape((3,4))); x
534 matrix([[ 0, 1, 2, 3],
535 [ 4, 5, 6, 7],
536 [ 8, 9, 10, 11]])
537 >>> x.prod()
538 0
539 >>> x.prod(0)
540 matrix([[ 0, 45, 120, 231]])
541 >>> x.prod(1)
542 matrix([[ 0],
543 [ 840],
544 [7920]])
545
546 """
547 return N.ndarray.prod(self, axis, dtype, out, keepdims=True)._collapse(axis)
548
549 def any(self, axis=None, out=None):
550 """

Callers 1

test_prodMethod · 0.45

Calls 1

_collapseMethod · 0.80

Tested by 1

test_prodMethod · 0.36