1 //------------------------------------------------------------------------------
2 // GB_op_is_second: return true if op is the SECOND operator of the right type
3 //------------------------------------------------------------------------------
4 
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: Apache-2.0
7 
8 //------------------------------------------------------------------------------
9 
10 #include "GB.h"
11 
12 GB_PUBLIC   // accessed by the MATLAB tests in GraphBLAS/Test only
GB_op_is_second(GrB_BinaryOp op,GrB_Type type)13 bool GB_op_is_second    // return true if op is SECOND, of the right type
14 (
15     GrB_BinaryOp op,
16     GrB_Type type
17 )
18 {
19 
20     if (op == NULL)
21     {
22         // op is NULL, which is interpretted as the implied SECOND operator
23         // of the right type
24         return (true) ;
25     }
26 
27     if (op->opcode == GB_SECOND_opcode)
28     {
29         // op is the explict SECOND operator; check its type
30         if (type == NULL)
31         {
32             // type is implicitly the right type
33             return (true) ;
34         }
35         else if (op->ytype == type && op->ztype == type && op->xtype == type)
36         {
37             // type is explicitly the right type
38             return (true) ;
39         }
40     }
41 
42     // wrong opcode or wrong type
43     return (false) ;
44 }
45 
46