1 //------------------------------------------------------------------------------
2 // GxB_Vector_Option_set: set an option in 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_transpose.h"
11
12 #define GB_FREE_ALL ;
13
GxB_Vector_Option_set(GrB_Vector v,GxB_Option_Field field,...)14 GrB_Info GxB_Vector_Option_set // set an option in a vector
15 (
16 GrB_Vector v, // descriptor to modify
17 GxB_Option_Field field, // option to change
18 ... // value to change it to
19 )
20 {
21
22 //--------------------------------------------------------------------------
23 // check inputs
24 //--------------------------------------------------------------------------
25
26 GrB_Info info = GrB_SUCCESS ;
27 GB_WHERE (v, "GxB_Vector_Option_set (v, field, value)") ;
28 GB_BURBLE_START ("GxB_set (vector option)") ;
29 GB_RETURN_IF_NULL_OR_FAULTY (v) ;
30 ASSERT_VECTOR_OK (v, "v to set option", GB0) ;
31
32 //--------------------------------------------------------------------------
33 // set the vector option
34 //--------------------------------------------------------------------------
35
36 va_list ap ;
37
38 switch (field)
39 {
40
41 case GxB_BITMAP_SWITCH :
42
43 {
44 va_start (ap, field) ;
45 double bitmap_switch = va_arg (ap, double) ;
46 va_end (ap) ;
47 v->bitmap_switch = (float) bitmap_switch ;
48 }
49 break ;
50
51 case GxB_SPARSITY_CONTROL :
52
53 {
54 va_start (ap, field) ;
55 int sparsity = va_arg (ap, int) ;
56 va_end (ap) ;
57 v->sparsity = GB_sparsity_control (sparsity, (int64_t) (-1)) ;
58 }
59 break ;
60
61 default :
62
63 return (GrB_INVALID_VALUE) ;
64 }
65
66 //--------------------------------------------------------------------------
67 // conform the vector to its new desired sparsity structure
68 //--------------------------------------------------------------------------
69
70 GB_OK (GB_conform ((GrB_Matrix) v, Context)) ;
71 GB_BURBLE_END ;
72 ASSERT_VECTOR_OK (v, "v set", GB0) ;
73 return (info) ;
74 }
75
76