File: GB_AxB_saxpy3_coarseGus_noM_phase1.c

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 503; asm: 369; python: 125; awk: 10
file content (63 lines) | stat: -rw-r--r-- 2,382 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//------------------------------------------------------------------------------
// GB_AxB_saxpy3_coarseGus_noM_phase1: symbolic coarse Gustavson, no mask
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2022, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

// Initially, Hf [...] < mark for all Hf.
// Hf [i] is set to mark when C(i,j) is found.

{
    for (int64_t kk = kfirst ; kk <= klast ; kk++)
    {
        GB_GET_B_j ;                    // get B(:,j)

        //----------------------------------------------------------------------
        // special cases when B(:,j) has zero or one entries
        //----------------------------------------------------------------------

        #if ( GB_B_IS_SPARSE || GB_B_IS_HYPER )
        if (bjnz == 0)
        { 
            Cp [kk] = 0 ;               // C(:,j) is empty
            continue ;
        }
        #if ( GB_A_IS_SPARSE )
        if (bjnz == 1)
        { 
            GB_GET_B_kj_INDEX ;         // get index k of entry B(k,j)
            GB_GET_A_k ;                // get A(:,k)
            Cp [kk] = aknz ;            // nnz (C (:,j)) = nnz (A (:,k))
            continue ;
        }
        #endif
        #endif

        //----------------------------------------------------------------------
        // count nnz in C(:,j), terminating early if C(:,j) becomes dense
        //----------------------------------------------------------------------

        const int64_t f = (++mark) ;
        int64_t cjnz = 0 ;
        for ( ; pB < pB_end && cjnz < cvlen ; pB++)     // scan B(:,j)
        {
            GB_GET_B_kj_INDEX ;         // get index k of entry B(k,j)
            GB_GET_A_k ;                // get A(:,k)
            // scan A(:,k)
            for (int64_t pA = pA_start ; pA < pA_end ; pA++)
            {
                GB_GET_A_ik_INDEX ;     // get index i of entry A(i,k)
                if (Hf [i] != f)        // if true, i is new
                { 
                    Hf [i] = f ;        // mark C(i,j) as seen
                    cjnz++ ;            // C(i,j) is a new entry
                }
            }
        }
        Cp [kk] = cjnz ;                // save count of entries in C(:,j)
    }
}