3
3
#include < nix.hpp>
4
4
5
5
mxArray* make_mx_array_from_ds (const nix::DataSet &da) {
6
- mexPrintf (" [PURGE_ME] mkArray.cc 01\n " );
7
6
nix::NDSize size = da.dataExtent ();
8
- mexPrintf (" [PURGE_ME] mkArray.cc 02\n " );
9
7
const size_t len = size.size ();
10
- mexPrintf (" [PURGE_ME] mkArray.cc 03\n " );
11
8
std::vector<mwSize> dims (len);
12
- mexPrintf (" [PURGE_ME] mkArray.cc 03\n " );
13
9
14
10
// NB: matlab is column-major, while HDF5 is row-major
15
11
// data is correct with this, but dimensions don't
@@ -18,26 +14,27 @@ mxArray* make_mx_array_from_ds(const nix::DataSet &da) {
18
14
for (size_t i = 0 ; i < len; i++) {
19
15
dims[len - (i + 1 )] = static_cast <mwSize>(size[i]);
20
16
}
21
- mexPrintf (" [PURGE_ME] mkArray.cc 04\n " );
22
17
nix::DataType da_type = da.dataType ();
23
- mexPrintf (" [PURGE_ME] mkArray.cc 05\n " );
24
18
DType2 dtype = dtype_nix2mex (da_type);
25
- mexPrintf (" [PURGE_ME] mkArray.cc 06\n " );
26
19
27
20
if (!dtype.is_valid ) {
28
- mexPrintf (" [PURGE_ME] mkArray.cc 07\n " );
29
21
throw std::domain_error (" Unsupported data type" );
30
22
}
31
23
32
- mexPrintf (" [PURGE_ME] mkArray.cc 08\n " );
33
- mxArray *data = mxCreateNumericArray (dims.size (), dims.data (), dtype.cid , dtype.clx );
34
- mexPrintf (" [PURGE_ME] mkArray.cc 09\n " );
35
- double *ptr = mxGetPr (data);
36
- mexPrintf (" [PURGE_ME] mkArray.cc 10\n " );
37
- nix::NDSize offset (size.size (), 0 );
38
- mexPrintf (" [PURGE_ME] mkArray.cc 11\n " );
39
- da.getData (da_type, ptr, size, offset);
40
- mexPrintf (" [PURGE_ME] mkArray.cc 12\n " );
24
+ mxArray *data;
25
+ if (dtype.cid == mxCHAR_CLASS)
26
+ {
27
+ data = mxCreateCharArray (dims.size (), dims.data ());
28
+ // double *ptr = mxGetPr(data);
29
+ // da.getData(ptr);
30
+ }
31
+ else
32
+ {
33
+ data = mxCreateNumericArray (dims.size (), dims.data (), dtype.cid , dtype.clx );
34
+ double *ptr = mxGetPr (data);
35
+ nix::NDSize offset (size.size (), 0 );
36
+ da.getData (da_type, ptr, size, offset);
37
+ }
41
38
42
39
return data;
43
40
}
@@ -105,4 +102,3 @@ mxArray* make_mx_array(const nix::Value &v)
105
102
return res;
106
103
107
104
}
108
-
0 commit comments