Changeset 12594
- Timestamp:
- 07/02/12 09:50:48 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/matlab/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/matlab/io/FetchMatlabData.cpp
r12511 r12594 27 27 outmatrix=NULL; 28 28 } 29 else if(mxIsClass(dataref,"double") || mxIsClass(dataref,"single") || mxIsClass(dataref,"int16")){ 29 else if( mxIsClass(dataref,"double") || 30 mxIsClass(dataref,"single") || 31 mxIsClass(dataref,"int16") || 32 mxIsClass(dataref,"int8") || 33 mxIsClass(dataref,"uint8")){ 30 34 /*Check dataref is not pointing to NaN: */ 31 35 if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){ … … 390 394 /*Assign output pointers:*/ 391 395 *pstring=outstring; 392 } 396 }/*}}}*/ 393 397 /*FUNCTION FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){{{*/ 394 398 void FetchData(char** pmatrix,int* pnumel,int* pndims,int** psize,const mxArray* dataref){ -
issm/trunk-jpl/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp
r12493 r12594 2 2 * \brief: convert a sparse or dense matlab matrix to a double* pointer 3 3 */ 4 5 4 6 5 #ifdef HAVE_CONFIG_H … … 10 9 #endif 11 10 12 13 11 /*Matlab includes: */ 14 12 #include "mex.h" 15 16 13 #include "../../shared/shared.h" 17 14 … … 19 16 20 17 int i,j,count,rows,cols; 21 double *pmxdoublematrix = NULL;22 float *pmxsinglematrix = NULL;23 short int *pmxint16matrix = NULL;24 18 25 19 /*output: */ … … 34 28 35 29 /*Dealing with sparse matrix: recover size first: */ 36 pmxdoublematrix=(double*)mxGetPr(mxmatrix);30 double* pmxmatrix=(double*)mxGetPr(mxmatrix); 37 31 rows=mxGetM(mxmatrix); 38 32 cols=mxGetN(mxmatrix); … … 49 43 for(i=0;i<cols;i++){ 50 44 for(j=0;j<(jc[i+1]-jc[i]);j++){ 51 matrix[rows*ir[count]+i]=pmx doublematrix[count];45 matrix[rows*ir[count]+i]=pmxmatrix[count]; 52 46 count++; 53 47 } … … 58 52 else if(mxIsClass(mxmatrix,"double")){ 59 53 /*Dealing with dense matrix: recover pointer and size: */ 60 pmxdoublematrix=(double*)mxGetPr(mxmatrix);54 double* pmxmatrix=(double*)mxGetPr(mxmatrix); 61 55 rows=mxGetM(mxmatrix); 62 56 cols=mxGetN(mxmatrix); … … 68 62 for(i=0;i<rows;i++){ 69 63 for(j=0;j<cols;j++){ 70 matrix[cols*i+j]=(double)pmx doublematrix[rows*j+i];64 matrix[cols*i+j]=(double)pmxmatrix[rows*j+i]; 71 65 } 72 66 } … … 75 69 else if(mxIsClass(mxmatrix,"single")){ 76 70 /*Dealing with dense matrix: recover pointer and size: */ 77 pmxsinglematrix=(float*)mxGetPr(mxmatrix);71 float *pmxmatrix=(float*)mxGetPr(mxmatrix); 78 72 rows=mxGetM(mxmatrix); 79 73 cols=mxGetN(mxmatrix); … … 85 79 for(i=0;i<rows;i++){ 86 80 for(j=0;j<cols;j++){ 87 matrix[cols*i+j]=(double)pmx singlematrix[rows*j+i];81 matrix[cols*i+j]=(double)pmxmatrix[rows*j+i]; 88 82 } 89 83 } … … 92 86 else if(mxIsClass(mxmatrix,"int16")){ 93 87 /*Dealing with dense matrix: recover pointer and size: */ 94 pmxint16matrix=(short*)mxGetPr(mxmatrix);88 short int *pmxmatrix=(short*)mxGetPr(mxmatrix); 95 89 rows=mxGetM(mxmatrix); 96 90 cols=mxGetN(mxmatrix); … … 102 96 for(i=0;i<rows;i++){ 103 97 for(j=0;j<cols;j++){ 104 matrix[cols*i+j]=(double)pmxint16matrix[rows*j+i]; 98 matrix[cols*i+j]=(double)pmxmatrix[rows*j+i]; 99 } 100 } 101 } 102 } 103 else if(mxIsClass(mxmatrix,"uint8")){ 104 /*Dealing with dense matrix: recover pointer and size: */ 105 char *pmxmatrix=(char*)mxGetPr(mxmatrix); 106 rows=mxGetM(mxmatrix); 107 cols=mxGetN(mxmatrix); 108 109 /*Create serial matrix: */ 110 if(rows*cols){ 111 matrix=xNewZeroInit<double>(rows*cols); 112 113 for(i=0;i<rows;i++){ 114 for(j=0;j<cols;j++){ 115 matrix[cols*i+j]=(double)pmxmatrix[rows*j+i]; 105 116 } 106 117 }
Note:
See TracChangeset
for help on using the changeset viewer.