File: GrB_Type_new.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 (37 lines) | stat: -rw-r--r-- 1,680 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
//------------------------------------------------------------------------------
// GrB_Type_new: create a new user-defined type
//------------------------------------------------------------------------------

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

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

// GrB_Type_new is implemented both as a macro and a function.  Both are
// user-callable.  The default is to use the macro, since this allows the name
// of the type to be saved as a string, for subsequent error reporting by
// GrB_error and for the return value of GxB_Matrix_type_name.  It is also
// provided as a function so that applications that require a function instead
// of macro can access it.  User code can simply do #undef GrB_Type_new before
// using the function.  This approach also places the function GrB_Type_new in
// the linkable SuiteSparse:GraphBLAS library so that it is visible for linking
// with applications in languages other than ANSI C.  The function version does
// not allow the name of the ctype to be saved in the new GraphBLAS type,
// however.  It is given a generic name, "user_type_of_size_%d" where "%d" is
// the size of the type.

#include "GB.h"

// the macro version of this function must first be #undefined
#undef GrB_Type_new
#undef GrM_Type_new

GrB_Info GRB (Type_new)         // create a new GraphBLAS type
(
    GrB_Type *type,             // handle of user type to create
    size_t sizeof_ctype         // size = sizeof (ctype) of the C type
)
{ 
    return (GxB_Type_new (type, sizeof_ctype, NULL, NULL)) ;
}