1 //------------------------------------------------------------------------------
2 // GB_mask: definitions for GB_mask and related functions
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 #ifndef GB_MASK_H
11 #define GB_MASK_H
12 #include "GB.h"
13 
14 GrB_Info GB_mask                // C<M> = Z
15 (
16     GrB_Matrix C_result,        // both input C and result matrix
17     const GrB_Matrix M,         // optional mask matrix, can be NULL
18     GrB_Matrix *Zhandle,        // Z = results of computation, perhaps shallow.
19                                 // Z is freed when done.
20     const bool C_replace,       // true if clear(C) to be done first
21     const bool Mask_comp,       // true if M is to be complemented
22     const bool Mask_struct,     // if true, use the only structure of M
23     GB_Context Context
24 ) ;
25 
26 GrB_Info GB_masker          // R = masker (C, M, Z)
27 (
28     GrB_Matrix R,           // output matrix, static header
29     const bool R_is_csc,    // format of output matrix R
30     const GrB_Matrix M,     // required input mask
31     const bool Mask_comp,   // descriptor for M
32     const bool Mask_struct, // if true, use the only structure of M
33     const GrB_Matrix C,     // input C matrix
34     const GrB_Matrix Z,     // input Z matrix
35     GB_Context Context
36 ) ;
37 
38 GrB_Info GB_masker_phase1           // count nnz in each R(:,j)
39 (
40     // computed by phase1:
41     int64_t **Rp_handle,            // output of size Rnvec+1
42     size_t *Rp_size_handle,
43     int64_t *Rnvec_nonempty,        // # of non-empty vectors in R
44     // tasks from phase1a:
45     GB_task_struct *restrict TaskList,       // array of structs
46     const int R_ntasks,               // # of tasks
47     const int R_nthreads,             // # of threads to use
48     // analysis from phase0:
49     const int64_t Rnvec,
50     const int64_t *restrict Rh,
51     const int64_t *restrict R_to_M,
52     const int64_t *restrict R_to_C,
53     const int64_t *restrict R_to_Z,
54     // original input:
55     const GrB_Matrix M,             // required mask
56     const bool Mask_comp,           // if true, then M is complemented
57     const bool Mask_struct,         // if true, use the only structure of M
58     const GrB_Matrix C,
59     const GrB_Matrix Z,
60     GB_Context Context
61 ) ;
62 
63 GrB_Info GB_masker_phase2           // phase2 for R = masker (C,M,Z)
64 (
65     GrB_Matrix R,                   // output matrix, static header
66     const bool R_is_csc,            // format of output matrix R
67     // from phase1:
68     int64_t **Rp_handle,            // vector pointers for R
69     size_t Rp_size,
70     const int64_t Rnvec_nonempty,   // # of non-empty vectors in R
71     // tasks from phase1a:
72     const GB_task_struct *restrict TaskList,     // array of structs
73     const int R_ntasks,               // # of tasks
74     const int R_nthreads,             // # of threads to use
75     // analysis from phase0:
76     const int64_t Rnvec,
77     int64_t **Rh_handle,
78     size_t Rh_size,
79     const int64_t *restrict R_to_M,
80     const int64_t *restrict R_to_C,
81     const int64_t *restrict R_to_Z,
82     const int R_sparsity,
83     // original input:
84     const GrB_Matrix M,             // required mask
85     const bool Mask_comp,           // if true, then M is complemented
86     const bool Mask_struct,         // if true, use the only structure of M
87     const GrB_Matrix C,
88     const GrB_Matrix Z,
89     GB_Context Context
90 ) ;
91 
92 int GB_masker_sparsity      // return the sparsity structure for R
93 (
94     // input:
95     const GrB_Matrix C,     // input C matrix
96     const GrB_Matrix M,     // mask for C, always present
97     const bool Mask_comp,   // if true, use !M
98     const GrB_Matrix Z      // input Z matrix
99 ) ;
100 
101 #endif
102 
103