Changeset 376


Ignore:
Timestamp:
05/13/09 09:11:08 (16 years ago)
Author:
seroussi
Message:

fixed problem with empty matrix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp

    r374 r376  
    107107                dataref = mxCreateSparse((mwSize)0,(mwSize)0,(mwSize)0,mxREAL);
    108108       
     109                /* free first to avoid mem leaks...: */
     110                mxFree(mxGetData(dataref));
     111                mxFree(mxGetIr(dataref));
     112                mxFree(mxGetJc(dataref));
     113               
     114                /* ...then set data: */
    109115                mxSetM(dataref,(mwSize)cols);
    110116                mxSetN(dataref,(mwSize)rows);
    111117                mxSetNzmax(dataref,(mwSize)nzmax);
    112        
    113                 if(nnz){
    114                         /* free first to avoid mem leaks...: */
    115                         mxFree(mxGetData(dataref));
    116                         mxFree(mxGetIr(dataref));
    117                         mxFree(mxGetJc(dataref));
    118 
    119                         /* ...then set data: */
    120                         mxSetData( dataref, val);
    121                         mxSetIr(dataref,col_ind);
    122                         mxSetJc(dataref,row_ptr);
    123                 }
    124        
     118                mxSetData( dataref, val);
     119                mxSetIr(dataref,col_ind);
     120                mxSetJc(dataref,row_ptr);
    125121
    126122        }
Note: See TracChangeset for help on using the changeset viewer.