1 //------------------------------------------------------------------------------
2 // GrB_Descriptor_new: create a new descriptor
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 // Default values are set to GxB_DEFAULT
11 
12 #include "GB.h"
13 
GrB_Descriptor_new(GrB_Descriptor * descriptor)14 GrB_Info GrB_Descriptor_new     // create a new descriptor
15 (
16     GrB_Descriptor *descriptor  // handle of descriptor to create
17 )
18 {
19 
20     //--------------------------------------------------------------------------
21     // check inputs
22     //--------------------------------------------------------------------------
23 
24     GB_WHERE1 ("GrB_Descriptor_new (&descriptor)") ;
25     GB_RETURN_IF_NULL (descriptor) ;
26     (*descriptor) = NULL ;
27 
28     //--------------------------------------------------------------------------
29     // create the descriptor
30     //--------------------------------------------------------------------------
31 
32     // allocate the descriptor
33     size_t header_size ;
34     (*descriptor) = GB_MALLOC (1, struct GB_Descriptor_opaque, &header_size) ;
35     if (*descriptor == NULL)
36     {
37         // out of memory
38         return (GrB_OUT_OF_MEMORY) ;
39     }
40 
41     // initialize the descriptor
42     GrB_Descriptor desc = *descriptor ;
43     desc->magic = GB_MAGIC ;
44     desc->header_size = header_size ;
45     desc->logger = NULL ;          // error string
46     desc->logger_size = 0 ;
47     desc->out  = GxB_DEFAULT ;     // descriptor for output
48     desc->mask = GxB_DEFAULT ;     // descriptor for the mask input
49     desc->in0  = GxB_DEFAULT ;     // descriptor for the first input
50     desc->in1  = GxB_DEFAULT ;     // descriptor for the second input
51     desc->axb  = GxB_DEFAULT ;     // descriptor for selecting the C=A*B method
52     desc->nthreads_max = GxB_DEFAULT ;  // max # of threads to use
53     desc->chunk = GxB_DEFAULT ;         // chunk for auto-tuning of # threads
54     desc->do_sort = false ;        // do not sort in GrB_mxm and others
55     return (GrB_SUCCESS) ;
56 }
57 
58