Changeset 11940


Ignore:
Timestamp:
04/05/12 14:52:39 (13 years ago)
Author:
Eric.Larour
Message:

Fixed bug: do not use the transpose anymore

File:
1 edited

Legend:

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

    r11861 r11940  
    2525
    2626
    27 int PetscMatrixToMatlabMatrix(mxArray** pdataref,Mat matrix){
     27int PetscMatrixToMatlabMatrix(mxArray** pdataref,Mat tmatrix){
    2828
    2929        int i,j,k;
     
    3131        /*output: */
    3232        mxArray* dataref=NULL;
    33         mxArray* tdataref=NULL;
    3433        int    rows,cols;
    3534
     
    5049        int*    idxm=NULL;
    5150        int*    idxn=NULL;
     51        Mat     matrix=NULL;
    5252
     53       
     54        /*First off, we need to transpose the matrix using the Petsc API. We tried using the transpose operation from
     55         * Matlab, but this ends up creating issues with lost pointers and references: */
     56        MatTranspose(tmatrix,MAT_INITIAL_MATRIX,&matrix);
     57
     58        /*Some needed information: */
    5359        MatGetType(matrix,&type);
    5460        MatGetSize(matrix,&rows,&cols);
     
    128134
    129135                dataref = mxCreateDoubleMatrix(0,0,mxREAL);
    130                 mxSetM(dataref,rows);
    131                 mxSetN(dataref,cols);
     136                mxSetM(dataref,cols);
     137                mxSetN(dataref,rows);
    132138                mxSetPr(dataref,(double*)matrix_ptr);   
    133139        }
    134140
    135 
    136         /*Transpose matrcol_indes: */
    137         mexCallMATLAB(1,&tdataref,1,&dataref, "transpose");
    138 
     141        /*Free ressources:*/
     142        MatFree(&matrix);
    139143
    140144        /*Assign output pointers: */
    141         *pdataref=tdataref;
     145        *pdataref=dataref;
    142146
    143147        return 1;
Note: See TracChangeset for help on using the changeset viewer.