/[escript]/trunk/paso/src/SystemMatrix_saveMM.c
ViewVC logotype

Diff of /trunk/paso/src/SystemMatrix_saveMM.c

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

revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC revision 415 by gross, Wed Jan 4 05:37:33 2006 UTC
# Line 18  Line 18 
18  void Paso_SystemMatrix_saveMM(Paso_SystemMatrix * A_p, char * fileName_p) {  void Paso_SystemMatrix_saveMM(Paso_SystemMatrix * A_p, char * fileName_p) {
19    
20    int iRow, iCol, iPtr,ir,ic;    int iRow, iCol, iPtr,ir,ic;
21      index_t index_offset=(A_p->type & MATRIX_FORMAT_OFFSET1 ? 1:0);
22    
23      if (A_p->type & MATRIX_FORMAT_SYM) {
24        Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM does not support symmetric storage scheme");
25        return;
26      }
27    /* open the file */    /* open the file */
28    FILE * fileHandle_p = fopen(fileName_p, "w");    FILE * fileHandle_p = fopen(fileName_p, "w");
29    if (fileHandle_p==NULL) {    if (fileHandle_p==NULL) {
# Line 36  void Paso_SystemMatrix_saveMM(Paso_Syste Line 41  void Paso_SystemMatrix_saveMM(Paso_Syste
41    mm_write_banner(fileHandle_p, matrixCode);    mm_write_banner(fileHandle_p, matrixCode);
42    mm_write_mtx_crd_size(fileHandle_p, A_p->num_rows*A_p->row_block_size, A_p->num_cols*A_p->col_block_size,A_p->len);    mm_write_mtx_crd_size(fileHandle_p, A_p->num_rows*A_p->row_block_size, A_p->num_cols*A_p->col_block_size,A_p->len);
43    
44    switch(A_p->type) {    if (A_p->type & MATRIX_FORMAT_CSC) {
45    case CSR:        for (iCol = 0; iCol< A_p->pattern->n_ptr; iCol++) {
46        for (iRow = 0; iRow< A_p->pattern->n_ptr; iRow++) {           for (ic = 0; ic< A_p->col_block_size; ic++) {
47           for (ir = 0; ir< A_p->row_block_size; ir++) {          for (iPtr = A_p->pattern->ptr[iCol] - index_offset;iPtr < A_p->pattern->ptr[iCol+1] - index_offset; iPtr++) {
48          for (iPtr = A_p->pattern->ptr[iRow] - PTR_OFFSET;iPtr < A_p->pattern->ptr[iRow+1] - PTR_OFFSET; iPtr++) {                 for (ir = 0; ir< A_p->row_block_size; ir++) {
                for (ic = 0; ic< A_p->col_block_size; ic++) {  
49                fprintf(fileHandle_p, "%12d %12d %e\n",                fprintf(fileHandle_p, "%12d %12d %e\n",
50                    iRow*A_p->row_block_size+ir+ 1,                    (A_p->pattern->index[iPtr]-index_offset)*A_p->row_block_size+ir+1,
51                    (A_p->pattern->index[iPtr]-INDEX_OFFSET)*A_p->col_block_size+ic+1,                    iCol*A_p->col_block_size+ic+ 1,
52                    A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);                    A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
53                 }                 }
54              }              }
55           }           }
56        }        }
57        break;    } else {
58    case CSC:        for (iRow = 0; iRow< A_p->pattern->n_ptr; iRow++) {
59        for (iCol = 0; iCol< A_p->pattern->n_ptr; iCol++) {           for (ir = 0; ir< A_p->row_block_size; ir++) {
60           for (ic = 0; ic< A_p->col_block_size; ic++) {          for (iPtr = A_p->pattern->ptr[iRow] - index_offset;iPtr < A_p->pattern->ptr[iRow+1] - index_offset; iPtr++) {
61          for (iPtr = A_p->pattern->ptr[iCol] - PTR_OFFSET;iPtr < A_p->pattern->ptr[iCol+1] - PTR_OFFSET; iPtr++) {                 for (ic = 0; ic< A_p->col_block_size; ic++) {
                for (ir = 0; ir< A_p->row_block_size; ir++) {  
62                fprintf(fileHandle_p, "%12d %12d %e\n",                fprintf(fileHandle_p, "%12d %12d %e\n",
63                    (A_p->pattern->index[iPtr]-INDEX_OFFSET)*A_p->row_block_size+ir+1,                    iRow*A_p->row_block_size+ir+ 1,
64                    iCol*A_p->col_block_size+ic+ 1,                    (A_p->pattern->index[iPtr]-index_offset)*A_p->col_block_size+ic+1,
65                    A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);                    A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
66                 }                 }
67              }              }

Legend:
Removed from v.155  
changed lines
  Added in v.415

  ViewVC Help
Powered by ViewVC 1.1.26