| 29 | } |
| 30 | |
| 31 | void mexFunction |
| 32 | ( |
| 33 | int nargout, |
| 34 | mxArray *pargout [ ], |
| 35 | int nargin, |
| 36 | const mxArray *pargin [ ] |
| 37 | ) |
| 38 | { |
| 39 | |
| 40 | GrB_Info info ; |
| 41 | bool malloc_debug = GB_mx_get_global (true) ; |
| 42 | GrB_Matrix A = NULL ; |
| 43 | GrB_Matrix *Tiles = NULL ; |
| 44 | |
| 45 | // check inputs |
| 46 | if (nargout > 1 || nargin != 3) |
| 47 | { |
| 48 | mexErrMsgTxt ("Usage: " USAGE) ; |
| 49 | } |
| 50 | |
| 51 | // get A (shallow copy) |
| 52 | A = GB_mx_mxArray_to_Matrix (pargin [0], "A input", false, true) ; |
| 53 | if (A == NULL) |
| 54 | { |
| 55 | FREE_ALL ; |
| 56 | mexErrMsgTxt ("A failed") ; |
| 57 | } |
| 58 | |
| 59 | // get ms (deep copy) |
| 60 | if (mxGetClassID (pargin [1]) != mxDOUBLE_CLASS) |
| 61 | { |
| 62 | mexErrMsgTxt ("ms must be double") ; |
| 63 | } |
| 64 | double *ms_double = mxGetDoubles (pargin [1]) ; |
| 65 | GrB_Index m = mxGetNumberOfElements (pargin [1]) ; |
| 66 | GrB_Index *Tile_nrows = mxMalloc (m * sizeof (GrB_Index)) ; |
| 67 | for (int64_t k = 0 ; k < m ; k++) |
| 68 | { |
| 69 | Tile_nrows [k] = (GrB_Index) (ms_double [k]) ; |
| 70 | } |
| 71 | |
| 72 | // get ns (deep copy) |
| 73 | if (mxGetClassID (pargin [2]) != mxDOUBLE_CLASS) |
| 74 | { |
| 75 | mexErrMsgTxt ("ns must be double") ; |
| 76 | } |
| 77 | double *ns_double = mxGetDoubles (pargin [2]) ; |
| 78 | GrB_Index n = mxGetNumberOfElements (pargin [2]) ; |
| 79 | GrB_Index *Tile_ncols = mxMalloc (n * sizeof (GrB_Index)) ; |
| 80 | for (int64_t k = 0 ; k < n ; k++) |
| 81 | { |
| 82 | Tile_ncols [k] = (GrB_Index) (ns_double [k]) ; |
| 83 | } |
| 84 | |
| 85 | // create Tiles |
| 86 | Tiles = mxCalloc (m * n, sizeof (GrB_Matrix)) ; |
| 87 | |
| 88 | // construct the empty Tiles array |
nothing calls this directly
no test coverage detected