| 14 | #include "GB_stringify.h" |
| 15 | |
| 16 | void GB_enumify_binop |
| 17 | ( |
| 18 | // output: |
| 19 | int *ecode, // enumerated operator, range 0 to 139 |
| 20 | // input: |
| 21 | GB_Opcode opcode, // opcode of GraphBLAS operator to convert into a macro |
| 22 | GB_Type_code xcode, // op->xtype->code of the operator |
| 23 | bool for_semiring // true for A*B, false for A+B or A.*B |
| 24 | ) |
| 25 | { |
| 26 | |
| 27 | int e = 0 ; |
| 28 | |
| 29 | switch (opcode) |
| 30 | { |
| 31 | |
| 32 | //---------------------------------------------------------------------- |
| 33 | // user-defined operator |
| 34 | //---------------------------------------------------------------------- |
| 35 | |
| 36 | case GB_USER_binop_code : |
| 37 | |
| 38 | e = 0 ; break ; |
| 39 | |
| 40 | //---------------------------------------------------------------------- |
| 41 | // built-in ops that can be used in a monoid: |
| 42 | //---------------------------------------------------------------------- |
| 43 | |
| 44 | case GB_FIRST_binop_code : // z = x, can be used as the ANY monoid |
| 45 | |
| 46 | e = 1 ; break ; |
| 47 | |
| 48 | case GB_ANY_binop_code : // z = y (same as SECOND) |
| 49 | |
| 50 | e = 2 ; break ; |
| 51 | |
| 52 | case GB_MIN_binop_code : // z = min(x,y) |
| 53 | |
| 54 | switch (xcode) |
| 55 | { |
| 56 | case GB_BOOL_code : e = 18 ; break ; // x && y |
| 57 | case GB_FP32_code : e = 3 ; break ; // fminf (x,y) |
| 58 | case GB_FP64_code : e = 4 ; break ; // fmin (x,y) |
| 59 | default : e = 5 ; break ; // GB_IMIN (x,y) |
| 60 | } |
| 61 | break ; |
| 62 | |
| 63 | case GB_MAX_binop_code : // z = max(x,y) |
| 64 | |
| 65 | switch (xcode) |
| 66 | { |
| 67 | case GB_BOOL_code : e = 17 ; break ; // x || y |
| 68 | case GB_FP32_code : e = 6 ; break ; // fmaxf (x,y) |
| 69 | case GB_FP64_code : e = 7 ; break ; // fmax (x,y) |
| 70 | default : e = 8 ; break ; // GB_IMAX (x,y) |
| 71 | } |
| 72 | break ; |
| 73 |
no outgoing calls
no test coverage detected