Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/KPMtools/mexutil.c @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 #include "mexutil.h" | |
2 | |
3 /* Functions to create uninitialized arrays. */ | |
4 | |
5 mxArray *mxCreateNumericArrayE(int ndim, const int *dims, | |
6 mxClassID class, mxComplexity ComplexFlag) | |
7 { | |
8 mxArray *a; | |
9 int i, *dims1 = mxMalloc(ndim*sizeof(int)); | |
10 size_t sz = 1; | |
11 for(i=0;i<ndim;i++) { | |
12 sz *= dims[i]; | |
13 dims1[i] = 1; | |
14 } | |
15 a = mxCreateNumericArray(ndim,dims1,class,ComplexFlag); | |
16 sz *= mxGetElementSize(a); | |
17 mxSetDimensions(a, dims, ndim); | |
18 mxFree(dims1); | |
19 mxSetData(a, mxRealloc(mxGetData(a), sz)); | |
20 if(ComplexFlag == mxCOMPLEX) { | |
21 mxSetPi(a, mxRealloc(mxGetPi(a),sz)); | |
22 } | |
23 return a; | |
24 } | |
25 mxArray *mxCreateNumericMatrixE(int m, int n, mxClassID class, | |
26 mxComplexity ComplexFlag) | |
27 { | |
28 size_t sz = m*n*sizeof(double); | |
29 mxArray *a = mxCreateNumericMatrix(1, 1, class, ComplexFlag); | |
30 mxSetM(a,m); | |
31 mxSetN(a,n); | |
32 mxSetPr(a, mxRealloc(mxGetPr(a),sz)); | |
33 if(ComplexFlag == mxCOMPLEX) { | |
34 mxSetPi(a, mxRealloc(mxGetPi(a),sz)); | |
35 } | |
36 return a; | |
37 } | |
38 mxArray *mxCreateDoubleMatrixE(int m, int n, | |
39 mxComplexity ComplexFlag) | |
40 { | |
41 return mxCreateNumericMatrixE(m,n,mxDOUBLE_CLASS,ComplexFlag); | |
42 } | |
43 |