1 //------------------------------------------------------------------------------
2 // GB_AxB_saxpy3_coarseGus_M_phase1: symbolic coarse Gustavson, with M
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 {
11     // Initially, Hf [...] < mark for all of Hf.
12 
13     // Hf [i] < mark    : M(i,j)=0, C(i,j) is ignored.
14     // Hf [i] == mark   : M(i,j)=1, and C(i,j) not yet seen.
15     // Hf [i] == mark+1 : M(i,j)=1, and C(i,j) has been seen.
16 
17     for (int64_t kk = kfirst ; kk <= klast ; kk++)
18     {
19         GB_GET_B_j ;            // get B(:,j)
20         Cp [kk] = 0 ;
21 
22         //----------------------------------------------------------------------
23         // special case when B(:,j) is empty
24         //----------------------------------------------------------------------
25 
26         #if ( GB_B_IS_SPARSE || GB_B_IS_HYPER )
27         if (bjnz == 0) continue ;
28         #endif
29 
30         //----------------------------------------------------------------------
31         // get M(:,j) and scatter it into the Hf workspace
32         //----------------------------------------------------------------------
33 
34         GB_GET_M_j ;                                // get M(:,j)
35         if (mjnz == 0) continue ;
36         GB_GET_M_j_RANGE (64) ;
37         mark += 2 ;
38         const int64_t f0 = mark ;
39         const int64_t f1 = mark+1 ;
40         GB_SCATTER_M_j (pM_start, pM_end, f0) ;     // scatter M(:,j)
41 
42         //----------------------------------------------------------------------
43         // count nnz in C(:,j)
44         //----------------------------------------------------------------------
45 
46         int64_t cjnz = 0 ;
47         for ( ; pB < pB_end ; pB++)     // scan B(:,j)
48         {
49             GB_GET_B_kj_INDEX ;         // get k of B(k,j)
50             GB_GET_A_k ;                // get A(:,k)
51             if (aknz == 0) continue ;
52             #define GB_IKJ                                          \
53             {                                                       \
54                 if (Hf [i] == f0)       /* if true, M(i,j) is 1 */  \
55                 {                                                   \
56                     Hf [i] = f1 ;       /* flag C(i,j) as seen */   \
57                     cjnz++ ;            /* C(i,j) is new */         \
58                 }                                                   \
59             }
60             GB_SCAN_M_j_OR_A_k (((GB_A_IS_SPARSE || GB_A_IS_HYPER) &&
61                 !A_jumbled)) ;
62             #undef GB_IKJ
63         }
64         Cp [kk] = cjnz ;                // count the entries in C(:,j)
65     }
66 }
67 
68