1 //------------------------------------------------------------------------------
2 // GxB_Matrix_select: select entries from a matrix
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 // C<M> = accum(C,select(A,k)) or accum(C,select(A',))
11
12 #include "GB_select.h"
13
GxB_Matrix_select(GrB_Matrix C,const GrB_Matrix M,const GrB_BinaryOp accum,const GxB_SelectOp op,const GrB_Matrix A,const GxB_Scalar Thunk,const GrB_Descriptor desc)14 GrB_Info GxB_Matrix_select // C<M> = accum (C, select(A,k)) or select(A',k)
15 (
16 GrB_Matrix C, // input/output matrix for results
17 const GrB_Matrix M, // optional mask for C, unused if NULL
18 const GrB_BinaryOp accum, // optional accum for Z=accum(C,T)
19 const GxB_SelectOp op, // operator to select the entries
20 const GrB_Matrix A, // first input: matrix A
21 const GxB_Scalar Thunk, // optional input for select operator
22 const GrB_Descriptor desc // descriptor for C, M, and A
23 )
24 {
25
26 //--------------------------------------------------------------------------
27 // check inputs
28 //--------------------------------------------------------------------------
29
30 GB_WHERE (C, "GxB_Matrix_select (C, M, accum, op, A, Thunk, desc)") ;
31 GB_BURBLE_START ("GxB_select") ;
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 // select the entries and optionally transpose; assemble pending tuples
42 //--------------------------------------------------------------------------
43
44 info = GB_select (
45 C, C_replace, // C and its descriptor
46 M, Mask_comp, Mask_struct, // mask and its descriptor
47 accum, // optional accum for Z=accum(C,T)
48 op, // operator to select the entries
49 A, // first input: A
50 Thunk, // optional input for select operator
51 A_transpose, // descriptor for A
52 Context) ;
53
54 GB_BURBLE_END ;
55 return (info) ;
56 }
57