1 //------------------------------------------------------------------------------ 2 // GB_emult.h: definitions for GB_emult 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_EMULT_H 11 #define GB_EMULT_H 12 #include "GB.h" 13 #include "GB_bitmap_assign_methods.h" 14 15 #define GB_EMULT_METHOD_ADD 0 /* use GB_add instead of emult */ 16 17 #define GB_EMULT_METHOD_01 1 /* use GB_emult_01 */ 18 #define GB_EMULT_METHOD_02A 2 /* use GB_emult_02 (A,B) */ 19 #define GB_EMULT_METHOD_02B (-2) /* use GB_emult_02 (B,A, flipxy true) */ 20 #define GB_EMULT_METHOD_03 3 /* use GB_emult_03 */ 21 #define GB_EMULT_METHOD_04A 4 /* use GB_emult_04 (M,A,B) */ 22 #define GB_EMULT_METHOD_04B (-4) /* use GB_emult_04 (M,B,A, flipxy true) */ 23 #define GB_EMULT_METHOD_05 5 /* use GB_emult_bitmap method 05 */ 24 #define GB_EMULT_METHOD_06 6 /* use GB_emult_bitmap method 06 */ 25 #define GB_EMULT_METHOD_07 7 /* use GB_emult_bitmap method 07 */ 26 27 GrB_Info GB_emult // C=A.*B or C<M>=A.*B 28 ( 29 GrB_Matrix C, // output matrix, static header 30 const GrB_Type ctype, // type of output matrix C 31 const bool C_is_csc, // format of output matrix C 32 const GrB_Matrix M, // optional mask, unused if NULL. Not complemented 33 const bool Mask_struct, // if true, use the only structure of M 34 const bool Mask_comp, // if true, use the !M 35 bool *mask_applied, 36 const GrB_Matrix A, // input A matrix 37 const GrB_Matrix B, // input B matrix 38 const GrB_BinaryOp op, // op to perform C = op (A,B) 39 GB_Context Context 40 ) ; 41 42 int GB_emult_sparsity // return the sparsity structure for C 43 ( 44 // output: 45 bool *apply_mask, // if true then mask will be applied by GB_emult 46 int *ewise_method, // method to use 47 // input: 48 const GrB_Matrix M, // optional mask for C, unused if NULL 49 const bool Mask_comp, // if true, use !M 50 const GrB_Matrix A, // input A matrix 51 const GrB_Matrix B // input B matrix 52 ) ; 53 54 GrB_Info GB_emult_01_phase0 // find vectors in C for C=A.*B or C<M>=A.*B 55 ( 56 int64_t *p_Cnvec, // # of vectors to compute in C 57 const int64_t *restrict *Ch_handle, // Ch is M->h, A->h, B->h, or NULL 58 size_t *Ch_size_handle, 59 int64_t *restrict *C_to_M_handle, // C_to_M: size Cnvec, or NULL 60 size_t *C_to_M_size_handle, 61 int64_t *restrict *C_to_A_handle, // C_to_A: size Cnvec, or NULL 62 size_t *C_to_A_size_handle, 63 int64_t *restrict *C_to_B_handle, // C_to_B: size Cnvec, or NULL 64 size_t *C_to_B_size_handle, 65 int *C_sparsity, // sparsity structure of C 66 // original input: 67 const GrB_Matrix M, // optional mask, may be NULL 68 const GrB_Matrix A, 69 const GrB_Matrix B, 70 GB_Context Context 71 ) ; 72 73 GrB_Info GB_emult_01_phase1 // count nnz in each C(:,j) 74 ( 75 // computed by phase1: 76 int64_t **Cp_handle, // output of size Cnvec+1 77 size_t *Cp_size_handle, 78 int64_t *Cnvec_nonempty, // # of non-empty vectors in C 79 // tasks from phase1a: 80 GB_task_struct *restrict TaskList, // array of structs 81 const int C_ntasks, // # of tasks 82 const int C_nthreads, // # of threads to use 83 // analysis from phase0: 84 const int64_t Cnvec, 85 const int64_t *restrict Ch, // Ch is NULL, or shallow pointer 86 const int64_t *restrict C_to_M, 87 const int64_t *restrict C_to_A, 88 const int64_t *restrict C_to_B, 89 // original input: 90 const GrB_Matrix M, // optional mask, may be NULL 91 const bool Mask_struct, // if true, use the only structure of M 92 const bool Mask_comp, // if true, use !M 93 const GrB_Matrix A, 94 const GrB_Matrix B, 95 GB_Context Context 96 ) ; 97 98 GrB_Info GB_emult_01_phase2 // C=A.*B or C<M>=A.*B 99 ( 100 GrB_Matrix C, // output matrix, static header 101 const GrB_Type ctype, // type of output matrix C 102 const bool C_is_csc, // format of output matrix C 103 const GrB_BinaryOp op, // op to perform C = op (A,B) 104 // from phase1: 105 int64_t **Cp_handle, // vector pointers for C 106 size_t Cp_size, 107 const int64_t Cnvec_nonempty, // # of non-empty vectors in C 108 // tasks from phase1a: 109 const GB_task_struct *restrict TaskList, // array of structs 110 const int C_ntasks, // # of tasks 111 const int C_nthreads, // # of threads to use 112 // analysis from phase0: 113 const int64_t Cnvec, 114 const int64_t *restrict Ch, 115 size_t Ch_size, 116 const int64_t *restrict C_to_M, 117 const int64_t *restrict C_to_A, 118 const int64_t *restrict C_to_B, 119 const int C_sparsity, 120 // from GB_emult_sparsity: 121 const int ewise_method, 122 // original input: 123 const GrB_Matrix M, // optional mask, may be NULL 124 const bool Mask_struct, // if true, use the only structure of M 125 const bool Mask_comp, // if true, use !M 126 const GrB_Matrix A, 127 const GrB_Matrix B, 128 GB_Context Context 129 ) ; 130 131 GrB_Info GB_emult_02 // C=A.*B when A is sparse/hyper, B bitmap/full 132 ( 133 GrB_Matrix C, // output matrix, static header 134 const GrB_Type ctype, // type of output matrix C 135 const bool C_is_csc, // format of output matrix C 136 const GrB_Matrix M, // optional mask, unused if NULL 137 const bool Mask_struct, // if true, use the only structure of M 138 const bool Mask_comp, // if true, use !M 139 const GrB_Matrix A, // input A matrix (sparse/hyper) 140 const GrB_Matrix B, // input B matrix (bitmap/full) 141 GrB_BinaryOp op, // op to perform C = op (A,B) 142 bool flipxy, // if true use fmult(y,x) else fmult(x,y) 143 GB_Context Context 144 ) ; 145 146 GrB_Info GB_emult_03 // C<M>=A.*B, M sparse/hyper, A and B bitmap/full 147 ( 148 GrB_Matrix C, // output matrix, static header 149 const GrB_Type ctype, // type of output matrix C 150 const bool C_is_csc, // format of output matrix C 151 const GrB_Matrix M, // sparse/hyper, not NULL 152 const bool Mask_struct, // if true, use the only structure of M 153 bool *mask_applied, // if true, the mask was applied 154 const GrB_Matrix A, // input A matrix (bitmap/full) 155 const GrB_Matrix B, // input B matrix (bitmap/full) 156 const GrB_BinaryOp op, // op to perform C = op (A,B) 157 GB_Context Context 158 ) ; 159 160 GrB_Info GB_bitmap_emult // C=A.*B, C<M>=A.*B, or C<!M>=A.*B 161 ( 162 GrB_Matrix C, // output matrix, static header 163 const int ewise_method, 164 const GrB_Type ctype, // type of output matrix C 165 const bool C_is_csc, // format of output matrix C 166 const GrB_Matrix M, // optional mask, unused if NULL 167 const bool Mask_struct, // if true, use the only structure of M 168 const bool Mask_comp, // if true, use !M 169 bool *mask_applied, // if true, the mask was applied 170 const GrB_Matrix A, // input A matrix (bitmap/full) 171 const GrB_Matrix B, // input B matrix (bitmap/full) 172 const GrB_BinaryOp op, // op to perform C = op (A,B) 173 GB_Context Context 174 ) ; 175 176 #endif 177 178