File: GxB_Vector_Option_set.c

package info (click to toggle)
suitesparse 1%3A7.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 254,920 kB
  • sloc: ansic: 1,134,743; cpp: 46,133; makefile: 4,875; fortran: 2,087; java: 1,826; sh: 996; ruby: 725; python: 495; asm: 371; sed: 166; awk: 44
file content (82 lines) | stat: -rw-r--r-- 2,773 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//------------------------------------------------------------------------------
// GxB_Vector_Option_set: set an option in a vector: historical methods
//------------------------------------------------------------------------------

// SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2025, All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

#include "GB.h"

//------------------------------------------------------------------------------
// GxB_Vector_Option_set_INT32: set vector options (int32_t scalars)
//------------------------------------------------------------------------------

GrB_Info GxB_Vector_Option_set_INT32    // set an option in a vector
(
    GrB_Vector v,                   // vector to modify
    int field,                      // option to change
    int32_t value                   // value to change it to
)
{
    return (GrB_Vector_set_INT32 (v, value, field)) ;
}

//------------------------------------------------------------------------------
// GxB_Vector_Option_set_FP64: set vector options (double scalars)
//------------------------------------------------------------------------------

#define GB_FREE_ALL GrB_Scalar_free (&scalar) ;

GrB_Info GxB_Vector_Option_set_FP64    // set an option in a vector
(
    GrB_Vector v,                   // vector to modify
    int field,                      // option to change
    double value                    // value to change it to
)
{
    GrB_Info info ;
    GrB_Scalar scalar = NULL ;
    GB_OK (GrB_Scalar_new (&scalar, GrB_FP64)) ;
    GB_OK (GrB_Scalar_setElement_FP64 (scalar, value)) ;
    GB_OK (GrB_Vector_set_Scalar (v, scalar, field)) ;
    GB_FREE_ALL
    return (GrB_SUCCESS) ;
}

#undef GB_FREE_ALL

//------------------------------------------------------------------------------
// GxB_Vector_Option_set: based on va_arg
//------------------------------------------------------------------------------

GrB_Info GxB_Vector_Option_set      // set an option in a vector
(
    GrB_Vector v,                   // vector to modify
    int field,                      // option to change
    ...                             // value to change it to
)
{
    va_list ap ;
    switch (field)
    {
        case GxB_BITMAP_SWITCH : 
        case GxB_HYPER_SWITCH : 
        {
            va_start (ap, field) ;
            double value = va_arg (ap, double) ;
            va_end (ap) ;
            return (GxB_Vector_Option_set_FP64 (v, field, value)) ;
        }

        default : 
        {
            va_start (ap, field) ;
            int value = va_arg (ap, int) ;
            va_end (ap) ;
            return (GxB_Vector_Option_set_INT32 (v, field, value)) ;
        }
    }
}