1function C = apply2 (arg1, arg2, arg3, arg4, arg5, arg6, arg7)
2%GRB.APPLY2 apply a binary operator to a matrix, with scalar binding.
3%
4%   C = GrB.apply2 (op, A, B)
5%   C = GrB.apply2 (op, A, B, desc)
6%   C = GrB.apply2 (Cin, accum, op, A, B, desc)
7%   C = GrB.apply2 (Cin, M, op, A, B, desc)
8%   C = GrB.apply2 (Cin, M, accum, op, A, B, desc)
9%
10% GrB.apply2 applies a binary operator op(A,B) to a matrix, with one of the
11% inputs being the matrix and the other input is bound to a scalar.  See
12% 'help GrB.binopinfo'.
13%
14% The op, A, and B arguments are required.  One of A or B must be a scalar.
15% If a scalar is sparse with no entries, it is treated as the value zero.
16%
17% accum: a binary operator to accumulate the results.
18%
19% Cin, the mask matrix M, the accum operator, and desc are optional.  If
20% either accum or M is present, then Cin is a required input.  If B is the
21% scalar and desc.in0 is 'transpose' then A is transposed before applying
22% the operator.  If A is the scalar and desc.in1 is 'transpose.', then the
23% input matrix B is tranposed before applying the operator.
24%
25% See also GrB/apply, GrB/spfun.
26
27% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
28% SPDX-License-Identifier: GPL-3.0-or-later
29
30if (isobject (arg1))
31    arg1 = arg1.opaque ;
32end
33
34if (isobject (arg2))
35    arg2 = arg2.opaque ;
36end
37
38if (isobject (arg3))
39    arg3 = arg3.opaque ;
40end
41
42if (nargin > 3 && isobject (arg4))
43    arg4 = arg4.opaque ;
44end
45
46if (nargin > 4 && isobject (arg5))
47    arg5 = arg5.opaque ;
48end
49
50if (nargin > 5 && isobject (arg6))
51    arg6 = arg6.opaque ;
52end
53
54switch (nargin)
55    case 3
56        [C, k] = gbapply2 (arg1, arg2, arg3) ;
57    case 4
58        [C, k] = gbapply2 (arg1, arg2, arg3, arg4) ;
59    case 5
60        [C, k] = gbapply2 (arg1, arg2, arg3, arg4, arg5) ;
61    case 6
62        [C, k] = gbapply2 (arg1, arg2, arg3, arg4, arg5, arg6) ;
63    case 7
64        [C, k] = gbapply2 (arg1, arg2, arg3, arg4, arg5, arg6, arg7) ;
65end
66
67if (k == 0)
68    C = GrB (C) ;
69end
70
71