@@ -270,36 +270,55 @@ GrB_Info matrix_dup_empty(Matrix *output, Matrix *input) {
270
270
return matrix_dup_format (output , input );
271
271
}
272
272
273
- GrB_Info matrix_mxm (Matrix * output , Matrix * first , Matrix * second , bool accum ) {
273
+ GrB_Info matrix_wise_empty (Matrix * output , Matrix * first , Matrix * second , bool accum );
274
+
275
+ GrB_Info matrix_mxm (Matrix * output , Matrix * first , Matrix * second , bool accum ,
276
+ bool swap ) {
277
+ Matrix * left = swap ? second : first ;
278
+ Matrix * right = swap ? first : second ;
279
+
274
280
GrB_Info result = GrB_mxm (output -> base , GrB_NULL , accum ? GxB_ANY_BOOL : GrB_NULL ,
275
- GxB_ANY_PAIR_BOOL , first -> base , second -> base , GrB_NULL );
281
+ GxB_ANY_PAIR_BOOL , left -> base , right -> base , GrB_NULL );
276
282
IS_ISO (output -> base , "MXM output" );
277
283
matrix_update (output );
278
284
return result ;
279
285
}
280
286
281
- GrB_Info matrix_mxm_format (Matrix * output , Matrix * first , Matrix * second , bool accum ) {
287
+ GrB_Info matrix_mxm_format (Matrix * output , Matrix * first , Matrix * second , bool accum ,
288
+ bool swap ) {
289
+ if (swap ) {
290
+ Matrix * temp = first ;
291
+ first = second ;
292
+ second = temp ;
293
+ }
294
+
282
295
int32_t desired_orientation =
283
296
first -> nvals > second -> nvals ? GrB_COLMAJOR : GrB_ROWMAJOR ;
284
297
298
+ if (swap ) {
299
+ desired_orientation =
300
+ desired_orientation == GrB_ROWMAJOR ? GrB_COLMAJOR : GrB_ROWMAJOR ;
301
+ }
302
+
285
303
if (!first -> is_both && first -> format != desired_orientation &&
286
304
!(first -> nvals > second -> nvals / 3.0 )) {
287
- GrB_Info result = matrix_mxm (output , first , second , accum );
305
+ GrB_Info result = matrix_mxm (output , first , second , accum , swap );
288
306
return result ;
289
307
}
290
308
291
309
matrix_to_format (first , desired_orientation , true);
292
310
matrix_to_format (second , desired_orientation , false);
293
311
matrix_to_format (output , desired_orientation , false);
294
- GrB_Info result = matrix_mxm (output , first , second , accum );
312
+ GrB_Info result = matrix_mxm (output , first , second , accum , swap );
295
313
return result ;
296
314
}
297
315
298
- GrB_Info matrix_mxm_empty (Matrix * output , Matrix * first , Matrix * second , bool accum ) {
316
+ GrB_Info matrix_mxm_empty (Matrix * output , Matrix * first , Matrix * second , bool accum ,
317
+ bool swap ) {
299
318
if (first -> nvals == 0 || second -> nvals == 0 )
300
319
return GrB_SUCCESS ;
301
320
302
- return matrix_mxm_format (output , first , second , accum );
321
+ return matrix_mxm_format (output , first , second , accum , swap );
303
322
}
304
323
305
324
GrB_Info matrix_rmxm_format (Matrix * output , Matrix * first , Matrix * second , bool accum ) {
@@ -395,6 +414,7 @@ GrB_Info matrix_wise_empty(Matrix *output, Matrix *first, Matrix *second, bool a
395
414
return matrix_wise_format (output , first , second , accum );
396
415
}
397
416
417
+ printf ("" );
398
418
GrB_Info matrix_rsub (Matrix * output , Matrix * mask ) {
399
419
GrB_Info result = GrB_eWiseAdd (output -> base , mask -> base , GrB_NULL , GxB_ANY_BOOL ,
400
420
output -> base , output -> base , GrB_DESC_RSC );
@@ -720,7 +740,7 @@ GrB_Info LAGraph_CFL_reachability_adv(
720
740
LAGraph_rule_WCNF bin_rule = rules [bin_rules [i ]];
721
741
722
742
matrix_mxm_empty (& temp_matrices [bin_rule .nonterm ], & matrices [bin_rule .prod_A ],
723
- & delta_matrices [bin_rule .prod_B ], false);
743
+ & delta_matrices [bin_rule .prod_B ], false, false );
724
744
}
725
745
TIMER_STOP ("MXM 1" , & mxm1 );
726
746
@@ -734,9 +754,9 @@ GrB_Info LAGraph_CFL_reachability_adv(
734
754
for (size_t i = 0 ; i < bin_rules_count ; i ++ ) {
735
755
LAGraph_rule_WCNF bin_rule = rules [bin_rules [i ]];
736
756
737
- matrix_rmxm_empty (& temp_matrices [bin_rule .nonterm ],
738
- & delta_matrices [bin_rule .prod_A ],
739
- & matrices [ bin_rule . prod_B ] , true);
757
+ matrix_mxm_empty (& temp_matrices [bin_rule .nonterm ],
758
+ & delta_matrices [bin_rule .prod_A ], & matrices [ bin_rule . prod_B ],
759
+ true , true);
740
760
}
741
761
TIMER_STOP ("MXM 2" , & mxm2 );
742
762
0 commit comments