1 //------------------------------------------------------------------------------
2 // GxB_Vector_select: select entries from a vector
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_select.h"
11
GxB_Vector_select(GrB_Vector w,const GrB_Vector M,const GrB_BinaryOp accum,const GxB_SelectOp op,const GrB_Vector u,const GxB_Scalar Thunk,const GrB_Descriptor desc)12 GrB_Info GxB_Vector_select // w<M> = accum (w, select(u,k))
13 (
14 GrB_Vector w, // input/output vector for results
15 const GrB_Vector M, // optional mask for w, unused if NULL
16 const GrB_BinaryOp accum, // optional accum for z=accum(w,t)
17 const GxB_SelectOp op, // operator to apply to the entries
18 const GrB_Vector u, // first input: vector u
19 const GxB_Scalar Thunk, // optional input for select operator
20 const GrB_Descriptor desc // descriptor for w and mask
21 )
22 {
23
24 //--------------------------------------------------------------------------
25 // check inputs
26 //--------------------------------------------------------------------------
27
28 GB_WHERE (w, "GxB_Vector_select (w, M, accum, op, u, Thunk, desc)") ;
29 GB_BURBLE_START ("GxB_select") ;
30 GB_RETURN_IF_NULL_OR_FAULTY (w) ;
31 GB_RETURN_IF_FAULTY (M) ;
32 GB_RETURN_IF_NULL_OR_FAULTY (u) ;
33
34 // get the descriptor
35 GB_GET_DESCRIPTOR (info, desc, C_replace, Mask_comp, Mask_struct,
36 xx1, xx2, xx3, xx7) ;
37
38 //--------------------------------------------------------------------------
39 // select the entries; do not transpose; assemble pending entries
40 //--------------------------------------------------------------------------
41
42 info = GB_select (
43 (GrB_Matrix) w, C_replace, // w and its descriptor
44 (GrB_Matrix) M, Mask_comp, Mask_struct, // mask and its descriptor
45 accum, // optional accum for Z=accum(C,T)
46 op, // operator to select the entries
47 (GrB_Matrix) u, // first input: u
48 Thunk, // optional input for select op
49 false, // u, not transposed
50 Context) ;
51
52 GB_BURBLE_END ;
53 return (info) ;
54 }
55
56