File: GB_code_type.c

package info (click to toggle)
suitesparse-graphblas 7.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 67,112 kB
  • sloc: ansic: 1,072,243; cpp: 8,081; sh: 512; makefile: 506; asm: 369; python: 125; awk: 10
file content (47 lines) | stat: -rw-r--r-- 1,869 bytes parent folder | download | duplicates (3)
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
//------------------------------------------------------------------------------
// GB_code_type: convert a type code to a GrB_Type
//------------------------------------------------------------------------------

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

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

// The GrB_assign, GxB_subassign, and GrB_setElement operations all accept
// scalar inputs.  The scalar code is converted to an appropriate GrB_Type
// here.  For user-defined types, the scalar is required to have the same type
// as the matrix being operated on.  This cannot be checked; results are
// undefined if the user passes in a void * pointer to a different user-defined
// type.

#include "GB.h"

GB_PUBLIC
GrB_Type GB_code_type           // return the GrB_Type corresponding to the code
(
    const GB_Type_code code,    // type code to convert
    const GrB_Type type         // user type if code is user-defined
)
{

    ASSERT (code <= GB_UDT_code) ;
    switch (code)
    {
        case GB_BOOL_code   : return (GrB_BOOL)   ;
        case GB_INT8_code   : return (GrB_INT8)   ;
        case GB_INT16_code  : return (GrB_INT16)  ;
        case GB_INT32_code  : return (GrB_INT32)  ;
        case GB_INT64_code  : return (GrB_INT64)  ;
        case GB_UINT8_code  : return (GrB_UINT8)  ;
        case GB_UINT16_code : return (GrB_UINT16) ;
        case GB_UINT32_code : return (GrB_UINT32) ;
        case GB_UINT64_code : return (GrB_UINT64) ;
        case GB_FP32_code   : return (GrB_FP32)   ;
        case GB_FP64_code   : return (GrB_FP64)   ;
        case GB_FC32_code   : return (GxB_FC32)   ;
        case GB_FC64_code   : return (GxB_FC64)   ;
        case GB_UDT_code    : 
        default             : return (type) ;
    }
}