Changeset 11940
- Timestamp:
- 04/05/12 14:52:39 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/toolkits/petsc/patches/PetscMatrixToMatlabMatrix.cpp
r11861 r11940 25 25 26 26 27 int PetscMatrixToMatlabMatrix(mxArray** pdataref,Mat matrix){27 int PetscMatrixToMatlabMatrix(mxArray** pdataref,Mat tmatrix){ 28 28 29 29 int i,j,k; … … 31 31 /*output: */ 32 32 mxArray* dataref=NULL; 33 mxArray* tdataref=NULL;34 33 int rows,cols; 35 34 … … 50 49 int* idxm=NULL; 51 50 int* idxn=NULL; 51 Mat matrix=NULL; 52 52 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: */ 53 59 MatGetType(matrix,&type); 54 60 MatGetSize(matrix,&rows,&cols); … … 128 134 129 135 dataref = mxCreateDoubleMatrix(0,0,mxREAL); 130 mxSetM(dataref, rows);131 mxSetN(dataref, cols);136 mxSetM(dataref,cols); 137 mxSetN(dataref,rows); 132 138 mxSetPr(dataref,(double*)matrix_ptr); 133 139 } 134 140 135 136 /*Transpose matrcol_indes: */ 137 mexCallMATLAB(1,&tdataref,1,&dataref, "transpose"); 138 141 /*Free ressources:*/ 142 MatFree(&matrix); 139 143 140 144 /*Assign output pointers: */ 141 *pdataref= tdataref;145 *pdataref=dataref; 142 146 143 147 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.