Changeset 7218
- Timestamp:
- 01/28/11 11:32:16 (14 years ago)
- Location:
- issm/trunk/src/c/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/io/FetchData.cpp
r7188 r7218 41 41 else{ 42 42 /*This is an error: we don't have the correct input!: */ 43 _error_(" wrong input parameter!");43 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref)); 44 44 } 45 45 } … … 79 79 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref)); 80 80 } 81 82 81 83 82 /*Assign output pointers:*/ … … 86 85 if (pN)*pN=outmatrix_cols; 87 86 88 87 } 88 /*}}}*/ 89 /*FUNCTION FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/ 90 void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){ 91 92 int i,outmatrix_rows,outmatrix_cols; 93 double *doublematrix=NULL; 94 int *outmatrix=NULL; 95 96 if(mxIsEmpty(dataref) ){ 97 /*Nothing to pick up. Just initialize matrix pointer to NULL: */ 98 outmatrix_rows=0; 99 outmatrix_cols=0; 100 outmatrix=NULL; 101 } 102 else if (mxIsDouble(dataref) ){ 103 104 /*Check dataref is not pointing to NaN: */ 105 if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){ 106 outmatrix_rows=0; 107 outmatrix_cols=0; 108 outmatrix=NULL; 109 } 110 else{ 111 112 /*Convert matlab matrix to double* matrix: */ 113 MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref); 114 115 /*Convert double matrix into integer matrix: */ 116 outmatrix=(int*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(int)); 117 for(i=0;i<outmatrix_rows*outmatrix_cols;i++)outmatrix[i]=(int)doublematrix[i]; 118 } 119 } 120 else{ 121 /*This is an error: we don't have the correct input!: */ 122 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref)); 123 } 124 125 /*Assign output pointers:*/ 126 *pmatrix=outmatrix; 127 if (pM)*pM=outmatrix_rows; 128 if (pN)*pN=outmatrix_cols; 129 } 130 /*}}}*/ 131 /*FUNCTION FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/ 132 void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref){ 133 134 int i,outmatrix_rows,outmatrix_cols; 135 double *doublematrix=NULL; 136 bool *outmatrix=NULL; 137 138 if(mxIsEmpty(dataref) ){ 139 /*Nothing to pick up. Just initialize matrix pointer to NULL: */ 140 outmatrix_rows=0; 141 outmatrix_cols=0; 142 outmatrix=NULL; 143 } 144 else if (mxIsDouble(dataref) ){ 145 146 /*Check dataref is not pointing to NaN: */ 147 if ( mxIsNaN(*(mxGetPr(dataref))) && (mxGetM(dataref)==1) && (mxGetN(dataref)==1) ){ 148 outmatrix_rows=0; 149 outmatrix_cols=0; 150 outmatrix=NULL; 151 } 152 else{ 153 154 /*Convert matlab matrix to double* matrix: */ 155 MatlabMatrixToDoubleMatrix(&doublematrix,&outmatrix_rows,&outmatrix_cols,dataref); 156 157 /*Convert double matrix into integer matrix: */ 158 outmatrix=(bool*)xmalloc(outmatrix_rows*outmatrix_cols*sizeof(bool)); 159 for(i=0;i<outmatrix_rows;i++)outmatrix[i]=(bool)doublematrix[i]; 160 } 161 } 162 else{ 163 /*This is an error: we don't have the correct input!: */ 164 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref)); 165 } 166 167 /*Assign output pointers:*/ 168 *pmatrix=outmatrix; 169 if (pM)*pM=outmatrix_rows; 170 if (pN)*pN=outmatrix_cols; 89 171 } 90 172 /*}}}*/ … … 109 191 else{ 110 192 /*This is an error: we don't have the correct input!: */ 111 _error_(" wrong input parameter");193 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref)); 112 194 } 113 195 … … 135 217 else{ 136 218 /*This is an error: we don't have the correct input!: */ 137 _error_(" wrong input parameter");219 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref)); 138 220 } 139 221 … … 167 249 else{ 168 250 /*This is an error: we don't have the correct input!: */ 169 _error_("wrong input parameter"); 251 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref)); 252 } 253 254 /*Assign output pointers:*/ 255 *pvector=outvector; 256 if (pM)*pM=outvector_rows; 257 } 258 /*}}}*/ 259 /*FUNCTION FetchData(bool** pvector,int* pM,const mxArray* dataref){{{1*/ 260 void FetchData(bool** pvector,int* pM,const mxArray* dataref){ 261 262 int i; 263 double *doublevector = NULL; 264 bool *outvector = NULL; 265 int outvector_rows; 266 267 if(mxIsEmpty(dataref)){ 268 /*Nothing to pick up. Just initialize matrix pointer to NULL: */ 269 outvector_rows=0; 270 outvector=NULL; 271 } 272 else if (mxIsDouble(dataref) ){ 273 274 /*Convert matlab vector to double* vector: */ 275 MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref); 276 277 /*Convert double vector into integer vector: */ 278 outvector=(bool*)xmalloc(outvector_rows*sizeof(bool)); 279 for(i=0;i<outvector_rows;i++)outvector[i]=(bool)doublevector[i]; 280 } 281 else{ 282 /*This is an error: we don't have the correct input!: */ 283 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref)); 170 284 } 171 285 … … 199 313 else{ 200 314 /*This is an error: we don't have the correct input!: */ 201 _error_(" wrong input parameter");315 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref)); 202 316 } 203 317 … … 224 338 else{ 225 339 /*This is an error: we don't have the correct input!: */ 226 _error_(" wrong input parameter");340 _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref)); 227 341 } 228 342 -
issm/trunk/src/c/io/io.h
r6014 r7218 33 33 void FetchData(DataSet** pdataset,const mxArray* dataref); 34 34 void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref); 35 void FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref); 36 void FetchData(bool** pmatrix,int* pM,int *pN,const mxArray* dataref); 35 37 void FetchData(Mat* pmatrix,const mxArray* dataref); 36 38 void FetchData(int** pvector,int* pM,const mxArray* dataref); 37 39 void FetchData(float** pvector,int* pM,const mxArray* dataref); 38 40 void FetchData(double** pvector,int* pM,const mxArray* dataref); 41 void FetchData(bool** pvector,int* pM,const mxArray* dataref); 39 42 void FetchData(Vec* pvector,const mxArray* dataref); 40 43 void FetchData(char** pstring,const mxArray* dataref);
Note:
See TracChangeset
for help on using the changeset viewer.