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

Function get_descriptor

deps/GraphBLAS/Test/GB_mx_mxArray_to_Descriptor.c:16–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include "GB_mex.h"
15
16static bool get_descriptor
17(
18 GrB_Descriptor D, // GraphBLAS descriptor to modify
19 const mxArray *D_builtin, // built-in struct with D.output, etc
20 const char *fieldname, // fieldname to extract from D_builtin
21 const GrB_Desc_Field field // field to set in D
22)
23{
24
25 // A NULL means the descriptor is not in the list of input parameters.
26 // An empty Descriptor is OK. Both mean the GraphBLAS descriptor is NULL,
27 // which each method uses to denote default values for all parameters.
28 if (D_builtin == NULL || mxIsEmpty (D_builtin))
29 {
30 return (true) ;
31 }
32
33 // if present, the built-in D must be a struct
34 if (!mxIsStruct (D_builtin))
35 {
36 mexWarnMsgIdAndTxt ("GB:warn","descriptor must be a struct") ;
37 return (false) ;
38 }
39
40 // find the field in the built-in struct
41 int fieldnumber = mxGetFieldNumber (D_builtin, fieldname) ;
42 if (fieldnumber >= 0)
43 {
44 // the field is present
45 mxArray *value = mxGetFieldByNumber (D_builtin, 0, fieldnumber) ;
46
47 // its value must be a string
48 if (!mxIsChar (value))
49 {
50 mexWarnMsgIdAndTxt ("GB:warn","D.field must be a string") ;
51 return (false) ;
52 }
53
54 // get the string from the built-in field
55 #define LEN 100
56 char s [LEN] ;
57 mxGetString (value, s, LEN) ;
58
59 // convert the string to a Descriptor value, and set the value
60 GrB_Info info ;
61 if (MATCH (s, "default"))
62 {
63 info = GxB_Desc_set (D, field, GxB_DEFAULT) ;
64 }
65 else if (MATCH (s, "tran") || MATCH (s, "transpose"))
66 {
67 info = GxB_Desc_set (D, field, GrB_TRAN) ;
68 }
69 else if (MATCH (s, "complement"))
70 {
71 info = GxB_Desc_set (D, field, GrB_COMP) ;
72 }
73 else if (MATCH (s, "structure") || MATCH (s, "structural"))

Callers 1

Calls 1

GxB_Desc_setFunction · 0.85

Tested by

no test coverage detected