1 //------------------------------------------------------------------------------
2 // gbsetup: initialize or finalize GraphBLAS
3 //------------------------------------------------------------------------------
4
5 // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved.
6 // SPDX-License-Identifier: GPL-3.0-or-later
7
8 //------------------------------------------------------------------------------
9
10 // gbsetup initializes GraphBLAS by calling GxB_init and by setting
11 // all GraphBLAS global variables to their MATLAB defaults.
12
13 #include "gb_matlab.h"
14
15 #define USAGE "GrB.setup"
16
mexFunction(int nargout,mxArray * pargout[],int nargin,const mxArray * pargin[])17 void mexFunction
18 (
19 int nargout,
20 mxArray *pargout [ ],
21 int nargin,
22 const mxArray *pargin [ ]
23 )
24 {
25
26 //--------------------------------------------------------------------------
27 // get test coverage
28 //--------------------------------------------------------------------------
29
30 #ifdef GBCOV
31 gbcov_get ( ) ;
32 #endif
33
34 //--------------------------------------------------------------------------
35 // finalize GraphBLAS, if it is already started
36 //--------------------------------------------------------------------------
37
38 if (GB_Global_GrB_init_called_get ( ))
39 {
40 GrB_finalize ( ) ;
41 }
42
43 //--------------------------------------------------------------------------
44 // allow GraphBLAS to be called again
45 //--------------------------------------------------------------------------
46
47 GB_Global_GrB_init_called_set (false) ;
48
49 //--------------------------------------------------------------------------
50 // initialize GraphBLAS
51 //--------------------------------------------------------------------------
52
53 gb_usage (true, USAGE) ;
54
55 //--------------------------------------------------------------------------
56 // save test coverage
57 //--------------------------------------------------------------------------
58
59 GB_WRAPUP ;
60 }
61
62