1 //------------------------------------------------------------------------------
2 // GB_boolean_rename_op: rename a boolean operator
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 // If the user requests the creation of a monoid based on a duplicate
11 // built-in binary operator, the unique boolean operator is used instead.
12 // See also GB_boolean_rename, which does this for opcodes, not operators.
13 // This is done before the operator is checked, so that any error messages
14 // reflect the renaming.
15 
16 #include "GB.h"
17 #include "GB_binop.h"
18 
GB_boolean_rename_op(const GrB_BinaryOp op)19 GrB_BinaryOp GB_boolean_rename_op   // return renamed op
20 (
21     const GrB_BinaryOp op           // op to rename
22 )
23 {
24 
25     if (op == GrB_DIV_BOOL)
26     {
27         // FIRST and DIV are the same for boolean:
28         return (GrB_FIRST_BOOL) ;
29     }
30     if (op == GxB_RDIV_BOOL)
31     {
32         // SECOND and RDIV are the same for boolean:
33         return (GrB_SECOND_BOOL) ;
34     }
35     if (op == GrB_MIN_BOOL || op == GrB_TIMES_BOOL)
36     {
37         // MIN, TIMES, and LAND are the same for boolean:
38         return (GrB_LAND) ;
39     }
40     if (op == GrB_MAX_BOOL || op == GrB_PLUS_BOOL)
41     {
42         // MAX, PLUS, and OR are the same for boolean:
43         return (GrB_LOR) ;
44     }
45     if (op == GxB_ISNE_BOOL || op == GrB_NE_BOOL || op == GrB_MINUS_BOOL
46         || op == GxB_RMINUS_BOOL)
47     {
48         // ISNE, NE, MINUS, RMINUS, and XOR are the same for boolean:
49         return (GrB_LXOR) ;
50     }
51     if (op == GxB_ISEQ_BOOL || op == GrB_LXNOR)
52     {
53         // LXNOR, ISEQ, EQ are the same for boolean:
54         return (GrB_EQ_BOOL) ;
55     }
56     if (op == GxB_ISGT_BOOL)
57     {
58         // ISGT, GT are the same for boolean:
59         return (GrB_GT_BOOL) ;
60     }
61     if (op == GxB_ISLT_BOOL)
62     {
63         // ISLT, LT are the same for boolean:
64         return (GrB_LT_BOOL) ;
65     }
66     if (op == GxB_ISGE_BOOL || op == GxB_POW_BOOL)
67     {
68         // POW, ISGE, GE are the same for boolean:
69         return (GrB_GE_BOOL) ;
70     }
71     if (op == GxB_ISLE_BOOL)
72     {
73         // ISLE, LE are the same for boolean:
74         return (GrB_LE_BOOL) ;
75     }
76 
77     // operator is not changed
78     return (op) ;
79 }
80 
81