@@ -70,37 +70,21 @@ void check_payment_system(bool *z, const Card *x, GrB_Index _i, GrB_Index _j, co
7070 * z = ((x -> system ) == * y );
7171}
7272
73- void tx_bool_mult (EdgeTX * z , const bool * x , const EdgeTX * y )
73+ void tx_bool_mult (EdgeTX * z , const Card * x , const EdgeTX * y )
7474{
75- if (* x )
76- * z = * y ;
77- else
78- {
79- z -> sum = 0 ;
80- z -> count = 0 ;
81- }
75+ * z = * y ;
8276}
8377
84- void tx_bool_mult_right (EdgeTX * z , const EdgeTX * x , const bool * y )
78+ void tx_bool_mult_right (EdgeTX * z , const EdgeTX * x , const Card * y )
8579{
86- if (* y )
87- * z = * x ;
88- else
89- {
90- z -> sum = 0 ;
91- z -> count = 0 ;
92- }
80+
81+ * z = * x ;
9382}
9483
9584void tx_bool_add (EdgeTX * z , const EdgeTX * x , const EdgeTX * y )
9685{
97- if (x -> count > 0 || y -> count > 0 )
98- * z = (x -> count > 0 ) ? * x : * y ;
99- else
100- {
101- z -> sum = 0 ;
102- z -> count = 0 ;
103- }
86+
87+ * z = * x ;
10488}
10589
10690void tx_is_nonempty (bool * z , const EdgeTX * x )
@@ -195,7 +179,7 @@ GrB_Info init_vertices(GrB_Vector *users, GrB_Vector *cards)
195179 // 5 - 9 & 11 - 12 --- cards
196180 Card card5 = {MIR , 600000.0 };
197181 Card card6 = {MIR , 700000.0 };
198- Card card7 = {VISA , 800000.0 };
182+ Card card7 = {MIR , 800000.0 };
199183 Card card8 = {MASTERCARD , 900000.0 };
200184 Card card9 = {VISA , 10000000.0 };
201185 Card card11 = {MIR , 99000000.0 };
@@ -325,15 +309,19 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
325309 // get cards with MIR payment system only
326310 TRY (GrB_Matrix_free (& ID ));
327311 TRY (GrB_Vector_free (& v ));
328- TRY (GrB_Vector_new (& v , GrB_BOOL , VERTICES_NUMBER ));
329- TRY (GrB_Vector_assign_BOOL (v , NULL , NULL , false, GrB_ALL , VERTICES_NUMBER , NULL ));
312+ TRY (GrB_Vector_new (& v , card , VERTICES_NUMBER ));
330313 GrB_IndexUnaryOp payment_system ;
331314 TRY (GrB_IndexUnaryOp_new (& payment_system , (GxB_index_unary_function )& check_payment_system , GrB_BOOL , card , GrB_UINT8 ));
332315 uint8_t pay_sys = MIR ;
333- TRY (GrB_Vector_apply_IndexOp_UDT (v , NULL , NULL , payment_system , cards , & pay_sys , NULL ));
334- TRY (GrB_Vector_eWiseMult_BinaryOp (filtered_cards , NULL , NULL , GrB_LAND , filtered_cards , v , NULL ));
316+ TRY (GrB_Vector_select_UDT (v , NULL , NULL , payment_system , cards , & pay_sys , NULL ));
317+ GxB_print (filtered_cards , GxB_COMPLETE );
318+ GxB_print (v , GxB_COMPLETE );
319+ GrB_Vector result_cards ;
320+ GrB_Vector_new (& result_cards , card , VERTICES_NUMBER );
321+ TRY (GrB_Vector_assign (result_cards , filtered_cards , NULL , v , GrB_ALL , VERTICES_NUMBER , NULL ));
322+ GxB_print (result_cards , GxB_COMPLETE );
335323
336- TRY (GrB_Matrix_diag (& ID , filtered_cards , 0 ));
324+ TRY (GrB_Matrix_diag (& ID , result_cards , 0 ));
337325 GxB_print (ID , GxB_COMPLETE );
338326
339327 // ------------------------------------------------------------------------
@@ -344,7 +332,7 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
344332 TRY (GrB_BinaryOp_new (& tx_bool_add_op , (GxB_binary_function )& tx_bool_add , tx_edge , tx_edge , tx_edge ));
345333
346334 GrB_BinaryOp tx_bool_mul_op ;
347- TRY (GrB_BinaryOp_new (& tx_bool_mul_op , (GxB_binary_function )& tx_bool_mult , tx_edge , GrB_BOOL , tx_edge ));
335+ TRY (GrB_BinaryOp_new (& tx_bool_mul_op , (GxB_binary_function )& tx_bool_mult , tx_edge , card , tx_edge ));
348336
349337 EdgeTX tx_identity = {0.0 , 0 };
350338 GrB_Monoid tx_bool_monoid ;
@@ -353,15 +341,16 @@ GrB_Info analyze_graph(GrB_Matrix tx_edge_mat, GrB_Matrix owns_edge_mat, GrB_Vec
353341 GrB_Semiring tx_bool_semiring ;
354342 TRY (GrB_Semiring_new (& tx_bool_semiring , tx_bool_monoid , tx_bool_mul_op ));
355343
356- GrB_BinaryOp tx_bool_mul_right_op ;
357- TRY (GrB_BinaryOp_new (& tx_bool_mul_right_op , (GxB_binary_function )& tx_bool_mult_right , tx_edge , tx_edge , GrB_BOOL ));
358-
359- GrB_Semiring tx_bool_semiring_right ;
360- TRY (GrB_Semiring_new (& tx_bool_semiring_right , tx_bool_monoid , tx_bool_mul_right_op ));
361344 GrB_Matrix tx_mat_filtered ;
362345 TRY (GrB_Matrix_new (& tx_mat_filtered , tx_edge , VERTICES_NUMBER , VERTICES_NUMBER ));
363346 TRY (GrB_mxm (tx_mat_filtered , NULL , NULL , tx_bool_semiring , ID , tx_edge_mat , NULL ));
347+
364348 GrB_Matrix tx_mat_filtered2 ;
349+ GrB_BinaryOp tx_bool_mul_right_op ;
350+ TRY (GrB_BinaryOp_new (& tx_bool_mul_right_op , (GxB_binary_function )& tx_bool_mult_right , tx_edge , tx_edge , card ));
351+
352+ GrB_Semiring tx_bool_semiring_right ;
353+ TRY (GrB_Semiring_new (& tx_bool_semiring_right , tx_bool_monoid , tx_bool_mul_right_op ));
365354 TRY (GrB_Matrix_new (& tx_mat_filtered2 , tx_edge , VERTICES_NUMBER , VERTICES_NUMBER ));
366355 TRY (GrB_mxm (tx_mat_filtered2 , NULL , NULL , tx_bool_semiring_right , tx_mat_filtered , ID , NULL ));
367356
0 commit comments