File: GxB_Vector_Option_get.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 (92 lines) | stat: -rw-r--r-- 3,105 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
83
84
85
86
87
88
89
90
91
92
//------------------------------------------------------------------------------
// GxB_Vector_Option_get: get 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_get_INT32: get vector options (int32_t scalars)
//------------------------------------------------------------------------------

GrB_Info GxB_Vector_Option_get_INT32    // gets the current option of a vector
(
    GrB_Vector v,                   // vector to query
    int field,                      // option to query
    int32_t *value                  // return value of the vector option
)
{ 
    return (GrB_Vector_get_INT32 (v, value, field)) ;
}

//------------------------------------------------------------------------------
// GxB_Vector_Option_get_FP64: get vector options (double scalars)
//------------------------------------------------------------------------------

#define GB_FREE_ALL GrB_Scalar_free (&scalar) ;

GrB_Info GxB_Vector_Option_get_FP64      // gets the current option of a vector
(
    GrB_Vector v,                   // vector to query
    int field,                      // option to query
    double *value                   // return value of the vector option
)
{ 
    GrB_Info info ;
    GrB_Scalar scalar = NULL ;
    GB_OK (GrB_Scalar_new (&scalar, GrB_FP64)) ;
    GB_OK (GrB_Vector_get_Scalar (v, scalar, field)) ;
    GB_OK (GrB_Scalar_extractElement_FP64 (value, scalar)) ;
    GB_FREE_ALL ;
    return (GrB_SUCCESS) ;
}

#undef GB_FREE_ALL

//------------------------------------------------------------------------------
// GxB_Vector_Option_get: based on va_arg
//------------------------------------------------------------------------------

GrB_Info GxB_Vector_Option_get      // gets the current option of a vector
(
    GrB_Vector v,                   // vector to query
    int field,                      // option to query
    ...                             // return value of the vector option
)
{ 
    va_list ap ;
    switch (field)
    {
        case GxB_IS_HYPER : 
        {
            va_start (ap, field) ;
            bool *value = va_arg (ap, bool *) ;
            va_end (ap) ;
            (*value) = false ;
            #pragma omp flush
            return (GrB_SUCCESS) ;
        }

        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_get_FP64 (v, field, value)) ;
        }

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