1 //------------------------------------------------------------------------------
2 // GB_mex_hack: get or set the global hack flags
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 #include "GB_mex.h"
11
12 #define USAGE "hack = GB_mex_hack (hack)"
13
mexFunction(int nargout,mxArray * pargout[],int nargin,const mxArray * pargin[])14 void mexFunction
15 (
16 int nargout,
17 mxArray *pargout [ ],
18 int nargin,
19 const mxArray *pargin [ ]
20 )
21 {
22 double *hack ;
23
24 if (nargin > 1 || nargout > 1)
25 {
26 mexErrMsgTxt ("usage: " USAGE "\n") ;
27 }
28
29 if (nargin == 1)
30 {
31 if (mxGetNumberOfElements (pargin [0]) != 2)
32 {
33 mexErrMsgTxt ("usage: " USAGE " where length(hack) is 2\n") ;
34 }
35 hack = mxGetDoubles (pargin [0]) ;
36 GB_Global_hack_set (0, (int64_t) hack [0]) ;
37 GB_Global_hack_set (1, (int64_t) hack [1]) ;
38 }
39
40 // GB_mex_hack returns an array of size 2
41 pargout [0] = mxCreateDoubleMatrix (1, 2, mxREAL) ;
42 hack = mxGetDoubles (pargout [0]) ;
43 hack [0] = (double) GB_Global_hack_get (0) ;
44 hack [1] = (double) GB_Global_hack_get (1) ;
45 }
46
47