Changeset 12397
- Timestamp:
- 06/09/12 17:29:22 (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
r12365 r12397 27 27 outmatrix=NULL; 28 28 } 29 else if(mxIsClass(dataref,"double") || mxIsClass(dataref,"single") ){29 else if(mxIsClass(dataref,"double") || mxIsClass(dataref,"single") || mxIsClass(dataref,"int16")){ 30 30 /*Check dataref is not pointing to NaN: */ 31 31 if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){ … … 35 35 } 36 36 else{ 37 if(!mxIsClass(dataref,"double") && !mxIsClass(dataref,"single")){ 38 printf("Warning: converting matlab data from '%s' to 'double'\n",mxGetClassName(dataref)); 39 } 37 40 /*Convert matlab matrix to double* matrix: */ 38 41 MatlabMatrixToDoubleMatrix(&outmatrix,&outmatrix_rows,&outmatrix_cols,dataref); -
issm/trunk-jpl/src/c/matlab/io/MatlabMatrixToDoubleMatrix.cpp
r12011 r12397 18 18 int MatlabMatrixToDoubleMatrix(double** pmatrix,int* pmatrix_rows,int* pmatrix_cols,const mxArray* mxmatrix){ 19 19 20 int i,j,count,rows,cols; 21 double *pmxdoublematrix = NULL; 22 float *pmxsinglematrix = NULL; 20 int i,j,count,rows,cols; 21 double *pmxdoublematrix = NULL; 22 float *pmxsinglematrix = NULL; 23 short int *pmxint16matrix = NULL; 23 24 24 25 /*output: */ … … 89 90 } 90 91 } 92 else if(mxIsClass(mxmatrix,"int16")){ 93 /*Dealing with dense matrix: recover pointer and size: */ 94 pmxint16matrix=(short*)mxGetPr(mxmatrix); 95 rows=mxGetM(mxmatrix); 96 cols=mxGetN(mxmatrix); 97 98 /*Create serial matrix: */ 99 if(rows*cols){ 100 matrix=(double*)xcalloc(rows*cols,sizeof(double)); 101 102 for(i=0;i<rows;i++){ 103 for(j=0;j<cols;j++){ 104 matrix[cols*i+j]=(double)pmxint16matrix[rows*j+i]; 105 } 106 } 107 } 108 } 91 109 else{ 92 110 _error_("Matlab matrix type Not implemented yet");
Note:
See TracChangeset
for help on using the changeset viewer.