1 //------------------------------------------------------------------------------
2 // gbmonoidinfo : print a GraphBLAS monoid (for illustration only)
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 // Usage:
11
12 // gbmonoidinfo (monoid)
13 // gbmonoidinfo (monoid, type)
14
15 #include "gb_matlab.h"
16
17 #define USAGE "usage: GrB.monoidinfo (monoid) or GrB.monoidinfo (monoid,type)"
18
mexFunction(int nargout,mxArray * pargout[],int nargin,const mxArray * pargin[])19 void mexFunction
20 (
21 int nargout,
22 mxArray *pargout [ ],
23 int nargin,
24 const mxArray *pargin [ ]
25 )
26 {
27
28 //--------------------------------------------------------------------------
29 // check inputs
30 //--------------------------------------------------------------------------
31
32 gb_usage (nargin >= 1 && nargin <= 2 && nargout == 0, USAGE) ;
33
34 //--------------------------------------------------------------------------
35 // construct the GraphBLAS monoid and print it
36 //--------------------------------------------------------------------------
37
38 #define LEN 256
39 char opstring [LEN+2] ;
40 gb_mxstring_to_string (opstring, LEN, pargin [0], "binary operator") ;
41
42 GrB_Type type = NULL ;
43 if (nargin > 1)
44 {
45 type = gb_mxstring_to_type (pargin [1]) ;
46 CHECK_ERROR (type == NULL, "unknown type") ;
47 }
48
49 GrB_Monoid op = gb_mxstring_to_monoid (pargin [0], type) ;
50 OK (GxB_Monoid_fprint (op, opstring, GxB_COMPLETE, NULL)) ;
51 GB_WRAPUP ;
52 }
53
54