1 //------------------------------------------------------------------------------
2 // GrB_Matrix_extract: C<M> = accum (C, A(I,J)) or A(J,I)'
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_extract.h"
11 
GrB_Matrix_extract(GrB_Matrix C,const GrB_Matrix M,const GrB_BinaryOp accum,const GrB_Matrix A,const GrB_Index * I,GrB_Index ni,const GrB_Index * J,GrB_Index nj,const GrB_Descriptor desc)12 GrB_Info GrB_Matrix_extract     // C<M> = accum (C, A(I,J))
13 (
14     GrB_Matrix C,               // input/output matrix for results
15     const GrB_Matrix M,         // optional mask for C, unused if NULL
16     const GrB_BinaryOp accum,   // optional accum for Z=accum(C,T)
17     const GrB_Matrix A,         // first input:  matrix A
18     const GrB_Index *I,         // row indices
19     GrB_Index ni,               // number of row indices
20     const GrB_Index *J,         // column indices
21     GrB_Index nj,               // number of column indices
22     const GrB_Descriptor desc   // descriptor for C, M, and A
23 )
24 {
25 
26     //--------------------------------------------------------------------------
27     // check inputs
28     //--------------------------------------------------------------------------
29 
30     GB_WHERE (C, "GrB_Matrix_extract (C, M, accum, A, I, ni, J, nj, desc)") ;
31     GB_BURBLE_START ("GrB_extract") ;
32     GB_RETURN_IF_NULL_OR_FAULTY (C) ;
33     GB_RETURN_IF_FAULTY (M) ;
34     GB_RETURN_IF_NULL_OR_FAULTY (A) ;
35 
36     // get the descriptor
37     GB_GET_DESCRIPTOR (info, desc, C_replace, Mask_comp, Mask_struct,
38         A_transpose, xx1, xx2, xx7) ;
39 
40     //--------------------------------------------------------------------------
41     // do the work in GB_extract
42     //--------------------------------------------------------------------------
43 
44     info = GB_extract (
45         C,      C_replace,          // output matrix C and its descriptor
46         M, Mask_comp, Mask_struct,  // mask and its descriptor
47         accum,                      // optional accum for Z=accum(C,T)
48         A,      A_transpose,        // A and its descriptor
49         I, ni,                      // row indices
50         J, nj,                      // column indices
51         Context) ;
52 
53     GB_BURBLE_END ;
54     return (info) ;
55 }
56 
57