1 //------------------------------------------------------------------------------ 2 // GB_add.h: definitiions for GB_add 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_ADD_H 11 #define GB_ADD_H 12 #include "GB.h" 13 14 GB_PUBLIC // accessed by the MATLAB tests in GraphBLAS/Test only 15 GrB_Info GB_add // C=A+B, C<M>=A+B, or C<!M>=A+B 16 ( 17 GrB_Matrix C, // output matrix, static header 18 const GrB_Type ctype, // type of output matrix C 19 const bool C_is_csc, // format of output matrix C 20 const GrB_Matrix M, // optional mask for C, unused if NULL 21 const bool Mask_struct, // if true, use the only structure of M 22 const bool Mask_comp, // if true, use !M 23 bool *mask_applied, // if true, the mask was applied 24 const GrB_Matrix A, // input A matrix 25 const GrB_Matrix B, // input B matrix 26 const GrB_BinaryOp op, // op to perform C = op (A,B) 27 GB_Context Context 28 ) ; 29 30 GrB_Info GB_add_phase0 // find vectors in C for C=A+B or C<M>=A+B 31 ( 32 int64_t *p_Cnvec, // # of vectors to compute in C 33 int64_t *restrict *Ch_handle, // Ch: size Cnvec, or NULL 34 size_t *Ch_size_handle, // size of Ch in bytes 35 int64_t *restrict *C_to_M_handle, // C_to_M: size Cnvec, or NULL 36 size_t *C_to_M_size_handle, // size of C_to_M in bytes 37 int64_t *restrict *C_to_A_handle, // C_to_A: size Cnvec, or NULL 38 size_t *C_to_A_size_handle, // size of C_to_A in bytes 39 int64_t *restrict *C_to_B_handle, // C_to_B: of size Cnvec, or NULL 40 size_t *C_to_B_size_handle, // size of C_to_A in bytes 41 bool *p_Ch_is_Mh, // if true, then Ch == Mh 42 int *C_sparsity, // sparsity structure of C 43 const GrB_Matrix M, // optional mask, may be NULL; not complemented 44 const GrB_Matrix A, // first input matrix 45 const GrB_Matrix B, // second input matrix 46 GB_Context Context 47 ) ; 48 49 GrB_Info GB_add_phase1 // count nnz in each C(:,j) 50 ( 51 int64_t **Cp_handle, // output of size Cnvec+1 52 size_t *Cp_size_handle, 53 int64_t *Cnvec_nonempty, // # of non-empty vectors in C 54 const bool A_and_B_are_disjoint, // if true, then A and B are disjoint 55 // tasks from phase0b: 56 GB_task_struct *restrict TaskList, // array of structs 57 const int C_ntasks, // # of tasks 58 const int C_nthreads, // # of threads to use 59 // analysis from phase0: 60 const int64_t Cnvec, 61 const int64_t *restrict Ch, 62 const int64_t *restrict C_to_M, 63 const int64_t *restrict C_to_A, 64 const int64_t *restrict C_to_B, 65 const bool Ch_is_Mh, // if true, then Ch == M->h 66 // original input: 67 const GrB_Matrix M, // optional mask, may be NULL 68 const bool Mask_struct, // if true, use the only structure of M 69 const bool Mask_comp, // if true, use !M 70 const GrB_Matrix A, 71 const GrB_Matrix B, 72 GB_Context Context 73 ) ; 74 75 GrB_Info GB_add_phase2 // C=A+B, C<M>=A+B, or C<!M>=A+B 76 ( 77 GrB_Matrix C, // output matrix, static header 78 const GrB_Type ctype, // type of output matrix C 79 const bool C_is_csc, // format of output matrix C 80 const GrB_BinaryOp op, // op to perform C = op (A,B), or NULL if no op 81 // from phase1: 82 int64_t **Cp_handle, // vector pointers for C 83 size_t Cp_size, 84 const int64_t Cnvec_nonempty, // # of non-empty vectors in C 85 // tasks from phase1a: 86 const GB_task_struct *restrict TaskList, // array of structs 87 const int C_ntasks, // # of tasks 88 const int C_nthreads, // # of threads to use 89 // analysis from phase0: 90 const int64_t Cnvec, 91 int64_t **Ch_handle, 92 size_t Ch_size, 93 const int64_t *restrict C_to_M, 94 const int64_t *restrict C_to_A, 95 const int64_t *restrict C_to_B, 96 const bool Ch_is_Mh, // if true, then Ch == M->h 97 const int C_sparsity, 98 // original input: 99 const GrB_Matrix M, // optional mask, may be NULL 100 const bool Mask_struct, // if true, use the only structure of M 101 const bool Mask_comp, // if true, use !M 102 const GrB_Matrix A, 103 const GrB_Matrix B, 104 GB_Context Context 105 ) ; 106 107 int GB_add_sparsity // return the sparsity structure for C 108 ( 109 // output: 110 bool *apply_mask, // if true then mask will be applied 111 // input: 112 const GrB_Matrix M, // optional mask for C, unused if NULL 113 const bool Mask_comp, // if true, use !M 114 const GrB_Matrix A, // input A matrix 115 const GrB_Matrix B // input B matrix 116 ) ; 117 118 #endif 119