1function C = prod (G, option)
2%PROD product of elements.
3% C = prod (G), where G is an m-by-n matrix, is a 1-by-n row vector C where
4% C(j) is the product of all entries in G(:,j).  If G is a row or column
5% vector, then prod (G) is a scalar product of all the entries in the
6% vector.
7%
8% C = prod (G,'all') takes the product of all elements of G to a single
9% scalar.
10%
11% C = prod (G,1) is the default when G is a matrix, which is to take the
12% product of each column, giving a 1-by-n row vector.  If G is already a
13% row vector, then C = G.
14%
15% C = prod (G,2) takes the product of each row, resulting in an m-by-1
16% column vector C where C(i) is the product of all entries in G(i,:).
17%
18% The built-in MATLAB prod (A, ... type, nanflag) allows for different
19% kinds of products to be computed, and the NaN behavior can be specified.
20% The GraphBLAS prod (G,...) uses only a type of 'native', and a nanflag of
21% 'includenan'.  See 'help prod' for more details.
22%
23% See also GrB/all, GrB/max, GrB/min, GrB/sum.
24
25% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
26% SPDX-License-Identifier: GPL-3.0-or-later
27
28G = G.opaque ;
29type = gbtype (G) ;
30if (isequal (type, 'logical'))
31    op = '&.logical' ;
32else
33    op = '*' ;
34end
35
36if (nargin == 1)
37    C = GrB (gb_prod (op, type, G)) ;
38else
39    C = GrB (gb_prod (op, type, G, option)) ;
40end
41
42