1 //------------------------------------------------------------------------------
2 // GB_bitmap_M_scatter_whole: scatter M into/from the C bitmap
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 #include "GB_bitmap_assign_methods.h"
11
GB_bitmap_M_scatter_whole(GrB_Matrix C,const GrB_Matrix M,const bool Mask_struct,const int operation,const int64_t * M_ek_slicing,const int M_ntasks,const int M_nthreads,GB_Context Context)12 void GB_bitmap_M_scatter_whole // scatter M into the C bitmap
13 (
14 // input/output:
15 GrB_Matrix C,
16 // inputs:
17 const GrB_Matrix M, // mask to scatter into the C bitmap
18 const bool Mask_struct, // true if M is structural, false if valued
19 const int operation, // +=2, -=2, or %=2
20 const int64_t *M_ek_slicing, // size 3*M_ntasks+1
21 const int M_ntasks,
22 const int M_nthreads,
23 GB_Context Context
24 )
25 {
26
27 //--------------------------------------------------------------------------
28 // check inputs
29 //--------------------------------------------------------------------------
30
31 ASSERT_MATRIX_OK (M, "M for bitmap scatter, whole", GB0) ;
32 ASSERT (GB_IS_SPARSE (M) || GB_IS_HYPERSPARSE (M)) ;
33 ASSERT (GB_JUMBLED_OK (M)) ;
34 ASSERT (M_ntasks > 0) ;
35 ASSERT (M_nthreads > 0) ;
36 ASSERT (M_ek_slicing != NULL) ;
37
38 //--------------------------------------------------------------------------
39 // get C and M
40 //--------------------------------------------------------------------------
41
42 GB_GET_M
43 int8_t *Cb = C->b ;
44 const int64_t cvlen = C->vlen ;
45 int64_t cnvals = 0 ;
46
47 //--------------------------------------------------------------------------
48 // scatter M into the C bitmap
49 //--------------------------------------------------------------------------
50
51 switch (operation)
52 {
53
54 case GB_BITMAP_M_SCATTER_PLUS_2 : // Cb (i,j) += 2
55
56 #undef GB_MASK_WORK
57 #define GB_MASK_WORK(pC) Cb [pC] += 2
58 #include "GB_bitmap_assign_M_all_template.c"
59 break ;
60
61 case GB_BITMAP_M_SCATTER_MINUS_2 : // Cb (i,j) -= 2
62
63 #undef GB_MASK_WORK
64 #define GB_MASK_WORK(pC) Cb [pC] -= 2
65 #include "GB_bitmap_assign_M_all_template.c"
66 break ;
67
68 case GB_BITMAP_M_SCATTER_SET_2 : // Cb (i,j) = 2
69
70 #undef GB_MASK_WORK
71 #define GB_MASK_WORK(pC) Cb [pC] = 2
72 #include "GB_bitmap_assign_M_all_template.c"
73 break ;
74
75 default: ;
76 }
77 }
78
79