Changeset 4638


Ignore:
Timestamp:
07/16/10 17:39:41 (15 years ago)
Author:
Eric.Larour
Message:

Added new FetchData overloads, for integer and float vectors

Location:
issm/trunk/src/c/io
Files:
2 edited

Legend:

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

    r4531 r4638  
    150150}
    151151/*}}}*/
     152/*FUNCTION FetchData(int** pvector,int* pM,const mxArray* dataref){{{1*/
     153void FetchData(int** pvector,int* pM,const mxArray* dataref){
     154
     155        int    i;
     156        double *doublevector   = NULL;
     157        int    *outvector      = NULL;
     158        int     outvector_rows;
     159
     160        if(mxIsEmpty(dataref)){
     161                /*Nothing to pick up. Just initialize matrix pointer to NULL: */
     162                outvector_rows=0;
     163                outvector=NULL;
     164        }
     165        else if (mxIsDouble(dataref) ){
     166
     167                /*Convert matlab vector to double*  vector: */
     168                MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
     169
     170                /*Convert double vector into integer vector: */
     171                outvector=(int*)xmalloc(outvector_rows*sizeof(int));
     172                for(i=0;i<outvector_rows;i++)outvector[i]=(int)doublevector[i];
     173        }
     174        else{
     175                /*This is an error: we don't have the correct input!: */
     176                ISSMERROR("wrong input parameter");
     177        }
     178
     179        /*Assign output pointers:*/
     180        *pvector=outvector;
     181        if (pM)*pM=outvector_rows;
     182}
     183/*}}}*/
     184/*FUNCTION FetchData(float** pvector,int* pM,const mxArray* dataref){{{1*/
     185void FetchData(float** pvector,int* pM,const mxArray* dataref){
     186
     187        int    i;
     188        double *doublevector   = NULL;
     189        float  *outvector      = NULL;
     190        int     outvector_rows;
     191
     192        if(mxIsEmpty(dataref)){
     193                /*Nothing to pick up. Just initialize matrix pointer to NULL: */
     194                outvector_rows=0;
     195                outvector=NULL;
     196        }
     197        else if (mxIsDouble(dataref) ){
     198
     199                /*Convert matlab vector to double*  vector: */
     200                MatlabVectorToDoubleVector(&doublevector,&outvector_rows,dataref);
     201
     202                /*Convert double vector into float vector: */
     203                outvector=(float*)xmalloc(outvector_rows*sizeof(float));
     204                for(i=0;i<outvector_rows;i++)outvector[i]=(float)doublevector[i];
     205        }
     206        else{
     207                /*This is an error: we don't have the correct input!: */
     208                ISSMERROR("wrong input parameter");
     209        }
     210
     211        /*Assign output pointers:*/
     212        *pvector=outvector;
     213        if (pM)*pM=outvector_rows;
     214}
     215/*}}}*/
    152216/*FUNCTION FetchData(Vec* pvector,const mxArray* dataref){{{1*/
    153217void FetchData(Vec* pvector,const mxArray* dataref){
  • issm/trunk/src/c/io/io.h

    r4236 r4638  
    3434void FetchData(double** pmatrix,int* pM,int *pN,const mxArray* dataref);
    3535void FetchData(Mat* pmatrix,const mxArray* dataref);
     36void FetchData(int** pvector,int* pM,const mxArray* dataref);
     37void FetchData(float** pvector,int* pM,const mxArray* dataref);
    3638void FetchData(double** pvector,int* pM,const mxArray* dataref);
    3739void FetchData(Vec* pvector,const mxArray* dataref);
Note: See TracChangeset for help on using the changeset viewer.