1function C = mxm (arg1, arg2, arg3, arg4, arg5, arg6, arg7)
2%GRB.MXM sparse matrix-matrix multiplication.
3%
4% GrB.mxm computes C<M> = accum (C, A*B) using a given semiring.
5%
6% Usage:
7%
8%   C = GrB.mxm (semiring, A, B)
9%   C = GrB.mxm (semiring, A, B, desc)
10%
11%   C = GrB.mxm (Cin, accum, semiring, A, B)
12%   C = GrB.mxm (Cin, accum, semiring, A, B, desc)
13%
14%   C = GrB.mxm (Cin, M, semiring, A, B)
15%   C = GrB.mxm (Cin, M, semiring, A, B, desc)
16%
17%   C = GrB.mxm (Cin, M, accum, semiring, A, B)
18%   C = GrB.mxm (Cin, M, accum, semiring, A, B, desc)
19%
20% Cin is an optional input matrix.  If Cin is not present or is an empty
21% matrix (Cin = [ ]) then it is implicitly a matrix with no entries, of the
22% right size (which depends on A, B, and the descriptor).  Its type is the
23% output type of the accum operator, if it is present; otherwise, its type
24% is the type of the additive monoid of the semiring.
25%
26% M is the optional mask matrix.  If not present, or if empty, then no mask
27% is used.  If present, M must have the same size as C.
28%
29% If accum is not present, then the operation becomes C<...> = A*B.
30% Otherwise, accum (C,A*B) is computed.  The accum operator acts like a
31% sparse matrix addition (see GrB.eadd).
32%
33% The semiring is a required string defining the semiring to use, in the
34% form 'add.mult.type', where '.type' is optional.  For example,
35% '+.*.double' is the conventional semiring for numerical linear algebra,
36% used in MATLAB for C=A*B when A and B are double.  If A or B are double
37% complex, then C=A*B uses the '+.*.double complex' semiring. GraphBLAS has
38% many more semirings.  See 'help GrB.semiringinfo' for more details.
39%
40% A and B are the input matrices.  A is transposed on input if desc.in0
41% is 'transpose', and/or desc.in1 = 'transpose' transposes B.
42%
43% desc is optional.  See 'help GrB.descriptorinfo' for more details.
44%
45% Examples:
46%
47%   A = sprand (4,5,0.5) ;
48%   B = sprand (5,3,0.5) ;
49%   C = GrB.mxm ('+.*', A, B) ;
50%   norm (C-A*B,1)
51%   E = sprand (4,3,0.7) ;
52%   M = logical (sprand (4,3,0.5)) ;
53%   C2 = GrB.mxm (E, M, '+', '+.*', A, B) ;
54%   C3 = E ; AB = A*B ; C3 (M) = C3 (M) + AB (M) ;
55%   norm (C2-C3,1)
56%
57% See also GrB.descriptorinfo, GrB.add, GrB/mtimes.
58
59% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
60% SPDX-License-Identifier: GPL-3.0-or-later
61
62if (isobject (arg1))
63    arg1 = arg1.opaque ;
64end
65
66if (isobject (arg2))
67    arg2 = arg2.opaque ;
68end
69
70if (isobject (arg3))
71    arg3 = arg3.opaque ;
72end
73
74if (nargin > 3 && isobject (arg4))
75    arg4 = arg4.opaque ;
76end
77
78if (nargin > 4 && isobject (arg5))
79    arg5 = arg5.opaque ;
80end
81
82if (nargin > 5 && isobject (arg6))
83    arg6 = arg6.opaque ;
84end
85
86switch (nargin)
87    case 3
88        [C, k] = gbmxm (arg1, arg2, arg3) ;
89    case 4
90        [C, k] = gbmxm (arg1, arg2, arg3, arg4) ;
91    case 5
92        [C, k] = gbmxm (arg1, arg2, arg3, arg4, arg5) ;
93    case 6
94        [C, k] = gbmxm (arg1, arg2, arg3, arg4, arg5, arg6) ;
95    case 7
96        [C, k] = gbmxm (arg1, arg2, arg3, arg4, arg5, arg6, arg7) ;
97end
98
99if (k == 0)
100    C = GrB (C) ;
101end
102
103