Changeset 11761
- Timestamp:
- 03/20/12 16:53:19 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/toolkits/double
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/toolkits/double/MatlabMatrixToDoubleMatrix.cpp
r11695 r11761 38 38 rows=mxGetM(mxmatrix); 39 39 cols=mxGetN(mxmatrix); 40 matrix=(double*)xcalloc(rows*cols,sizeof(double)); 40 41 if(rows*cols){ 42 matrix=(double*)xcalloc(rows*cols,sizeof(double)); 41 43 42 /*Now, get ir,jc and pr: */43 ir=mxGetIr(mxmatrix);44 jc=mxGetJc(mxmatrix);44 /*Now, get ir,jc and pr: */ 45 ir=mxGetIr(mxmatrix); 46 jc=mxGetJc(mxmatrix); 45 47 46 /*Now, start inserting data into double* matrix: */ 47 count=0; 48 for(i=0;i<cols;i++){ 49 for(j=0;j<(jc[i+1]-jc[i]);j++){ 50 matrix[rows*ir[count]+i]=pmxdoublematrix[count]; 51 count++; 48 /*Now, start inserting data into double* matrix: */ 49 count=0; 50 for(i=0;i<cols;i++){ 51 for(j=0;j<(jc[i+1]-jc[i]);j++){ 52 matrix[rows*ir[count]+i]=pmxdoublematrix[count]; 53 count++; 54 } 52 55 } 53 56 } … … 61 64 62 65 /*Create serial matrix: */ 63 matrix=(double*)xcalloc(rows*cols,sizeof(double)); 66 if(rows*cols){ 67 matrix=(double*)xcalloc(rows*cols,sizeof(double)); 64 68 65 for(i=0;i<rows;i++){ 66 for(j=0;j<cols;j++){ 67 matrix[cols*i+j]=(double)pmxdoublematrix[rows*j+i]; 69 for(i=0;i<rows;i++){ 70 for(j=0;j<cols;j++){ 71 matrix[cols*i+j]=(double)pmxdoublematrix[rows*j+i]; 72 } 68 73 } 69 74 } … … 76 81 77 82 /*Create serial matrix: */ 78 matrix=(double*)xcalloc(rows*cols,sizeof(double)); 83 if(rows*cols){ 84 matrix=(double*)xcalloc(rows*cols,sizeof(double)); 79 85 80 for(i=0;i<rows;i++){ 81 for(j=0;j<cols;j++){ 82 matrix[cols*i+j]=(double)pmxsinglematrix[rows*j+i]; 86 for(i=0;i<rows;i++){ 87 for(j=0;j<cols;j++){ 88 matrix[cols*i+j]=(double)pmxsinglematrix[rows*j+i]; 89 } 83 90 } 84 91 } -
issm/trunk-jpl/src/c/toolkits/double/MatlabVectorToDoubleVector.cpp
r11733 r11761 52 52 nz=(int)((double)nnz/(double)rows); 53 53 54 vector=(double*)xcalloc(rows,sizeof(double)); 54 if(rows){ 55 vector=(double*)xcalloc(rows,sizeof(double)); 55 56 56 /*Now, get ir,jc and pr: */57 pr=mxGetPr(mxvector);58 ir=mxGetIr(mxvector);59 jc=mxGetJc(mxvector);57 /*Now, get ir,jc and pr: */ 58 pr=mxGetPr(mxvector); 59 ir=mxGetIr(mxvector); 60 jc=mxGetJc(mxvector); 60 61 61 /*Now, start inserting data into sparse vector: */ 62 count=0; 63 for(i=0;i<cols;i++){ 64 for(j=0;j<(jc[i+1]-jc[i]);j++){ 65 vector[ir[count]]=pr[count]; 66 count++; 62 /*Now, start inserting data into sparse vector: */ 63 count=0; 64 for(i=0;i<cols;i++){ 65 for(j=0;j<(jc[i+1]-jc[i]);j++){ 66 vector[ir[count]]=pr[count]; 67 count++; 68 } 67 69 } 68 70 }
Note:
See TracChangeset
for help on using the changeset viewer.