MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / GB_enumify_reduce

Function GB_enumify_reduce

deps/GraphBLAS/Source/GB_enumify_reduce.c:15–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include "GB_stringify.h"
14
15void GB_enumify_reduce // enumerate a GrB_reduce problem
16(
17 // output:
18 uint64_t *rcode, // unique encoding of the entire problem
19 // input:
20 GrB_Monoid reduce, // the monoid to enumify
21 GrB_Matrix A
22)
23{
24
25 //--------------------------------------------------------------------------
26 // get the monoid and type of A
27 //--------------------------------------------------------------------------
28
29 GrB_BinaryOp reduceop = reduce->op ;
30 GrB_Type atype = A->type ;
31 GrB_Type ztype = reduceop->ztype ;
32 GB_Opcode reduce_opcode = reduceop->opcode ;
33 // these must always be true for any monoid:
34 ASSERT (reduceop->xtype == reduceop->ztype) ;
35 ASSERT (reduceop->ytype == reduceop->ztype) ;
36
37 //--------------------------------------------------------------------------
38 // rename redundant boolean operators
39 //--------------------------------------------------------------------------
40
41 // consider z = op(x,y) where both x and y are boolean:
42 // DIV becomes FIRST
43 // RDIV becomes SECOND
44 // MIN and TIMES become LAND
45 // MAX and PLUS become LOR
46 // NE, ISNE, RMINUS, and MINUS become LXOR
47 // ISEQ becomes EQ
48 // ISGT becomes GT
49 // ISLT becomes LT
50 // ISGE becomes GE
51 // ISLE becomes LE
52
53 GB_Type_code zcode = ztype->code ;
54 if (zcode == GB_BOOL_code)
55 {
56 // rename the monoid
57 reduce_opcode = GB_boolean_rename (reduce_opcode) ;
58 }
59
60 //--------------------------------------------------------------------------
61 // enumify the monoid
62 //--------------------------------------------------------------------------
63
64 int red_ecode, id_ecode, term_ecode ;
65 GB_enumify_monoid (&red_ecode, &id_ecode, &term_ecode, reduce_opcode,
66 zcode) ;
67
68 //--------------------------------------------------------------------------
69 // enumify the type and sparsity structure of A
70 //--------------------------------------------------------------------------
71
72 int acode = atype->code ; // 0 to 14

Callers 2

GB_debugify_reduceFunction · 0.85
reduce_factoryMethod · 0.85

Calls 4

GB_boolean_renameFunction · 0.85
GB_enumify_monoidFunction · 0.85
GB_sparsityFunction · 0.85
GB_enumify_sparsityFunction · 0.85

Tested by

no test coverage detected