/[escript]/trunk/paso/src/SparseMatrix.cpp
ViewVC logotype

Diff of /trunk/paso/src/SparseMatrix.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4802 by caltinay, Mon Mar 24 05:42:42 2014 UTC revision 4803 by caltinay, Wed Mar 26 06:52:28 2014 UTC
# Line 107  void q_sort( index_t *row, index_t *col, Line 107  void q_sort( index_t *row, index_t *col,
107     pattern is already unrolled to match the requested block size     pattern is already unrolled to match the requested block size
108     and offsets. Otherwise unrolling and offset adjustment will be performed.     and offsets. Otherwise unrolling and offset adjustment will be performed.
109  */  */
110  SparseMatrix* SparseMatrix_alloc(SparseMatrixType type, Paso_Pattern *pattern,  SparseMatrix* SparseMatrix_alloc(SparseMatrixType type, Pattern *pattern,
111                                   int row_block_size, int col_block_size,                                   int row_block_size, int col_block_size,
112                                   bool patternIsUnrolled)                                   bool patternIsUnrolled)
113  {  {
# Line 150  SparseMatrix* SparseMatrix_alloc(SparseM Line 150  SparseMatrix* SparseMatrix_alloc(SparseM
150       if (type & MATRIX_FORMAT_CSC) {       if (type & MATRIX_FORMAT_CSC) {
151             if (unroll) {             if (unroll) {
152                if (patternIsUnrolled) {                if (patternIsUnrolled) {
153                      out->pattern=Paso_Pattern_getReference(pattern);                      out->pattern=Pattern_getReference(pattern);
154                } else {                } else {
155                      out->pattern=Paso_Pattern_unrollBlocks(pattern,pattern_format_out,col_block_size,row_block_size);                      out->pattern=Pattern_unrollBlocks(pattern,pattern_format_out,col_block_size,row_block_size);
156                }                }
157                out->row_block_size=1;                out->row_block_size=1;
158                out->col_block_size=1;                out->col_block_size=1;
159             } else {             } else {
160               out->pattern=Paso_Pattern_unrollBlocks(pattern,pattern_format_out,1,1);               out->pattern=Pattern_unrollBlocks(pattern,pattern_format_out,1,1);
161                out->row_block_size=row_block_size;                out->row_block_size=row_block_size;
162                out->col_block_size=col_block_size;                out->col_block_size=col_block_size;
163             }             }
# Line 170  SparseMatrix* SparseMatrix_alloc(SparseM Line 170  SparseMatrix* SparseMatrix_alloc(SparseM
170       /* ====== compressed sparse row === */       /* ====== compressed sparse row === */
171             if (unroll) {             if (unroll) {
172                if (patternIsUnrolled) {                if (patternIsUnrolled) {
173                     out->pattern=Paso_Pattern_getReference(pattern);                     out->pattern=Pattern_getReference(pattern);
174                } else {                } else {
175                     out->pattern=Paso_Pattern_unrollBlocks(pattern,pattern_format_out,row_block_size,col_block_size);                     out->pattern=Pattern_unrollBlocks(pattern,pattern_format_out,row_block_size,col_block_size);
176                }                }
177                out->row_block_size=1;                out->row_block_size=1;
178                out->col_block_size=1;                out->col_block_size=1;
179             } else {             } else {
180                out->pattern=Paso_Pattern_unrollBlocks(pattern,pattern_format_out,1,1);                out->pattern=Pattern_unrollBlocks(pattern,pattern_format_out,1,1);
181                out->row_block_size=row_block_size;                out->row_block_size=row_block_size;
182                out->col_block_size=col_block_size;                out->col_block_size=col_block_size;
183             }             }
# Line 235  void SparseMatrix_free(SparseMatrix* in) Line 235  void SparseMatrix_free(SparseMatrix* in)
235                 break;                 break;
236          }          }
237          delete[] in->val;          delete[] in->val;
238          Paso_Pattern_free(in->pattern);          Pattern_free(in->pattern);
239          delete in;          delete in;
240       }       }
241     }     }
# Line 248  SparseMatrix* SparseMatrix_loadMM_toCSR( Line 248  SparseMatrix* SparseMatrix_loadMM_toCSR(
248          index_t *row_ptr = NULL;          index_t *row_ptr = NULL;
249          double *val = NULL;          double *val = NULL;
250          FILE *fileHandle_p = NULL;          FILE *fileHandle_p = NULL;
251          Paso_Pattern* mainPattern=NULL;          Pattern* mainPattern=NULL;
252          SparseMatrix *out = NULL;          SparseMatrix *out = NULL;
253          int i, curr_row, scan_ret;          int i, curr_row, scan_ret;
254          MM_typecode matrixCode;          MM_typecode matrixCode;
# Line 330  SparseMatrix* SparseMatrix_loadMM_toCSR( Line 330  SparseMatrix* SparseMatrix_loadMM_toCSR(
330          }          }
331          row_ptr[M] = nz;          row_ptr[M] = nz;
332    
333          mainPattern=Paso_Pattern_alloc(MATRIX_FORMAT_DEFAULT,M,N,row_ptr,col_ind);          mainPattern=Pattern_alloc(MATRIX_FORMAT_DEFAULT,M,N,row_ptr,col_ind);
334          out  = SparseMatrix_alloc(MATRIX_FORMAT_DEFAULT, mainPattern, 1, 1, TRUE);          out  = SparseMatrix_alloc(MATRIX_FORMAT_DEFAULT, mainPattern, 1, 1, TRUE);
335          /* copy values and cleanup temps */          /* copy values and cleanup temps */
336          for( i=0; i<nz; i++ ) out->val[i] = val[i];          for( i=0; i<nz; i++ ) out->val[i] = val[i];
337    
338          Paso_Pattern_free(mainPattern);          Pattern_free(mainPattern);
339          delete[] val;          delete[] val;
340          delete[] row_ind;          delete[] row_ind;
341          return out;          return out;
# Line 409  void SparseMatrix_saveMM(const SparseMat Line 409  void SparseMatrix_saveMM(const SparseMat
409    
410  index_t* SparseMatrix_borrowMainDiagonalPointer(const SparseMatrix* A_p)  index_t* SparseMatrix_borrowMainDiagonalPointer(const SparseMatrix* A_p)
411  {  {
412      return Paso_Pattern_borrowMainDiagonalPointer(A_p->pattern);      return Pattern_borrowMainDiagonalPointer(A_p->pattern);
413  }  }
414    
415  dim_t SparseMatrix_getNumColors(const SparseMatrix* A_p)  dim_t SparseMatrix_getNumColors(const SparseMatrix* A_p)
416  {  {
417     return Paso_Pattern_getNumColors(A_p->pattern);     return Pattern_getNumColors(A_p->pattern);
418  }  }
419    
420  index_t* SparseMatrix_borrowColoringPointer(const SparseMatrix* A_p)  index_t* SparseMatrix_borrowColoringPointer(const SparseMatrix* A_p)
421  {  {
422     return Paso_Pattern_borrowColoringPointer(A_p->pattern);     return Pattern_borrowColoringPointer(A_p->pattern);
423  }  }
424    
425  dim_t SparseMatrix_maxDeg(const SparseMatrix* A_p)  dim_t SparseMatrix_maxDeg(const SparseMatrix* A_p)
426  {  {
427     return Paso_Pattern_maxDeg(A_p->pattern);     return Pattern_maxDeg(A_p->pattern);
428  }  }
429    
430  dim_t SparseMatrix_getTotalNumRows(const SparseMatrix* A)  dim_t SparseMatrix_getTotalNumRows(const SparseMatrix* A)

Legend:
Removed from v.4802  
changed lines
  Added in v.4803

  ViewVC Help
Powered by ViewVC 1.1.26