MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / mexFunction

Function mexFunction

deps/GraphBLAS/Test/GB_mex_AplusB.c:26–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26void mexFunction
27(
28 int nargout,
29 mxArray *pargout [ ],
30 int nargin,
31 const mxArray *pargin [ ]
32)
33{
34 struct GB_Matrix_opaque C_header ;
35 GrB_Matrix C = GB_clear_static_header (&C_header) ;
36
37 bool malloc_debug = GB_mx_get_global (true) ;
38 GrB_Matrix A = NULL ;
39 GrB_Matrix B = NULL ;
40 GrB_BinaryOp op = NULL ;
41
42 GB_CONTEXT (USAGE) ;
43
44 // check inputs
45 if (nargout > 1 || nargin != 3)
46 {
47 mexErrMsgTxt ("Usage: " USAGE) ;
48 }
49
50 #define GET_DEEP_COPY ;
51 #define FREE_DEEP_COPY ;
52
53 // get A and B
54 A = GB_mx_mxArray_to_Matrix (pargin [0], "A", false, true) ;
55 B = GB_mx_mxArray_to_Matrix (pargin [1], "B", false, true) ;
56 if (A == NULL || B == NULL)
57 {
58 FREE_ALL ;
59 mexErrMsgTxt ("failed") ;
60 }
61
62 // get op
63 bool user_complex = (Complex != GxB_FC64)
64 && (A->type == Complex || B->type == Complex) ;
65 if (!GB_mx_mxArray_to_BinaryOp (&op, pargin [2], "op",
66 A->type, user_complex) || op == NULL)
67 {
68 FREE_ALL ;
69 mexErrMsgTxt ("op failed") ;
70 }
71
72 // C = A+B using the op. No mask
73 bool ignore ;
74 METHOD (GB_add (C, A->type, true, NULL, false, false, &ignore, A, B,
75 false, NULL, NULL, op, Context)) ;
76
77 // return C as a plain sparse matrix
78 pargout [0] = GB_mx_Matrix_to_mxArray (&C, "C AplusB result", false) ;
79
80 FREE_ALL ;
81}
82

Callers

nothing calls this directly

Calls 6

GB_mx_get_globalFunction · 0.85
GB_mx_mxArray_to_MatrixFunction · 0.85
GB_addFunction · 0.85
GB_mx_Matrix_to_mxArrayFunction · 0.85
GB_clear_static_headerFunction · 0.50

Tested by

no test coverage detected