Ignore:
Timestamp:
01/28/11 11:32:16 (14 years ago)
Author:
Mathieu Morlighem
Message:

Added additional FetchData

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/io/FetchData.cpp

    r7188 r7218  
    4141                else{
    4242                        /*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));
    4444                }
    4545        }
     
    7979                _error_("Input parameter of class %s not supported yet",mxGetClassName(dataref));
    8080        }
    81 
    8281                       
    8382        /*Assign output pointers:*/
     
    8685        if (pN)*pN=outmatrix_cols;
    8786
    88 
     87}
     88/*}}}*/
     89/*FUNCTION FetchData(int** pmatrix,int* pM,int *pN,const mxArray* dataref){{{1*/
     90void 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*/
     132void 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;
    89171}
    90172/*}}}*/
     
    109191        else{
    110192                /*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));
    112194        }
    113195
     
    135217        else{
    136218                /*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));
    138220        }
    139221
     
    167249        else{
    168250                /*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*/
     260void 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));
    170284        }
    171285
     
    199313        else{
    200314                /*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));
    202316        }
    203317
     
    224338        else{
    225339                /*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));
    227341        }
    228342
Note: See TracChangeset for help on using the changeset viewer.