1 //------------------------------------------------------------------------------
2 // GB_mx_mxArray_to_array: get a dense numerical MATLAB array
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
GB_mx_mxArray_to_array(const mxArray * Xmatlab,GB_void ** X,int64_t * nrows,int64_t * ncols,GrB_Type * xtype)12 void GB_mx_mxArray_to_array // convert mxArray to array
13 (
14 const mxArray *Xmatlab, // input MATLAB array
15 // output:
16 GB_void **X, // pointer to numerical values (shallow)
17 int64_t *nrows, // number of rows of X
18 int64_t *ncols, // number of columns of X
19 GrB_Type *xtype // GraphBLAS type of X, NULL if error
20 )
21 {
22
23 if (!(mxIsNumeric (Xmatlab) || mxIsLogical (Xmatlab)))
24 {
25 mexWarnMsgIdAndTxt ("GB:warn","input must be numeric or logical array");
26 }
27 if (mxIsSparse (Xmatlab))
28 {
29 mexWarnMsgIdAndTxt ("GB:warn","input cannot be sparse") ;
30 }
31
32 (*X) = mxGetData (Xmatlab) ;
33 (*nrows) = mxGetM (Xmatlab) ;
34 (*ncols) = mxGetN (Xmatlab) ;
35 (*xtype) = GB_mx_Type (Xmatlab) ;
36 }
37
38