/[escript]/trunk/esys2/finley/src/finleyC/System_saveMM.c
ViewVC logotype

Diff of /trunk/esys2/finley/src/finleyC/System_saveMM.c

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

revision 97 by jgs, Tue Dec 14 05:39:33 2004 UTC revision 100 by jgs, Wed Dec 15 03:48:48 2004 UTC
# Line 17  Line 17 
17    
18  void Finley_SystemMatrix_saveMM(Finley_SystemMatrix * A_p, char * fileName_p) {  void Finley_SystemMatrix_saveMM(Finley_SystemMatrix * A_p, char * fileName_p) {
19    
20    int iRow, iCol, iPtr,ir,ic;    int iRow, iCol, iPtr;
21    
22    /* open the file */    /* open the file */
23    FILE * fileHandle_p = fopen(fileName_p, "w");    FILE * fileHandle_p = fopen(fileName_p, "w");
# Line 35  void Finley_SystemMatrix_saveMM(Finley_S Line 35  void Finley_SystemMatrix_saveMM(Finley_S
35    mm_set_real(&matrixCode);    mm_set_real(&matrixCode);
36        
37    mm_write_banner(fileHandle_p, matrixCode);    mm_write_banner(fileHandle_p, matrixCode);
38    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->num_cols, A_p->ptr[A_p->num_cols] - PTR_OFFSET);
39    
40    switch(A_p->type) {    switch(A_p->type) {
41    case CSR:    case CSR:
42        for (iRow = 0; iRow< A_p->pattern->n_ptr; iRow++) {      #if INDEX_OFFSET==0
43           for (ir = 0; ir< A_p->row_block_size; ir++) {        /* add 1 for 1-based indexing */
44          for (iPtr = A_p->pattern->ptr[iRow] - PTR_OFFSET;iPtr < A_p->pattern->ptr[iRow+1] - PTR_OFFSET; iPtr++) {        for (iRow = 0; iRow < A_p->num_rows; iRow++)
45                 for (ic = 0; ic< A_p->col_block_size; ic++) {      for (iPtr = A_p->ptr[iRow] - PTR_OFFSET;
46                fprintf(fileHandle_p, "%12d %12d %22.15g\n",           iPtr < A_p->ptr[iRow+1] - PTR_OFFSET; iPtr++)
47                    iRow*A_p->row_block_size+ir+ 1,        fprintf(fileHandle_p, "%12d %12d %22.15g\n",
48                    (A_p->pattern->index[iPtr]-INDEX_OFFSET)*A_p->col_block_size+ic+1,            iRow + 1,  A_p->index[iPtr] + 1, A_p->val[iPtr]);
49                    A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);      #else
50                 }        /* matrix market uses 1-based indexing */
51              }        for (iRow = 0; iRow< A_p->num_rows; iRow++)
52           }      for (iPtr = A_p->ptr[iRow] - PTR_OFFSET;
53        }           iPtr < A_p->ptr[iRow+1] - PTR_OFFSET; iPtr++)
54        break;        fprintf(fileHandle_p, "%12d %12d %22.15g\n",
55              iRow + INDEX_OFFSET, A_p->index[iPtr], A_p->val[iPtr]);
56        #endif
57        break;
58    case CSC:    case CSC:
59        for (iCol = 0; iCol< A_p->pattern->n_ptr; iCol++) {      #if INDEX_OFFSET==0
60           for (ic = 0; ic< A_p->col_block_size; ic++) {        /* add 1 for 1-based indexing */
61          for (iPtr = A_p->pattern->ptr[iCol] - PTR_OFFSET;iPtr < A_p->pattern->ptr[iCol+1] - PTR_OFFSET; iPtr++) {        for (iCol = 0; iCol < A_p->num_cols; iCol++)
62                 for (ir = 0; ir< A_p->row_block_size; ir++) {      for (iPtr = A_p->ptr[iCol] - PTR_OFFSET;
63                fprintf(fileHandle_p, "%12d %12d %22.15g\n",           iPtr < A_p->ptr[iCol+1] - PTR_OFFSET; iPtr++)
64                    (A_p->pattern->index[iPtr]-INDEX_OFFSET)*A_p->row_block_size+ir+1,        fprintf(fileHandle_p, "%12d %12d %22.15g\n", A_p->index[iPtr] + 1, iCol + 1, A_p->val[iPtr]);
65                    iCol*A_p->col_block_size+ic+ 1,      #else
66                    A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);        /* matrix market uses 1-based indexing */
67                 }        for (iCol = 0; iCol< A_p->num_cols; iCol++)
68              }      for (iPtr = A_p->ptr[iCol] - PTR_OFFSET;
69           }           iPtr < A_p->ptr[iCol+1] - PTR_OFFSET; iPtr++)
70        }        fprintf(fileHandle_p, "%12d %12d %22.15g\n", A_p->index[iPtr],
71              iCol + INDEX_OFFSET, A_p->val[iPtr]);
72        #endif
73    }    }
74    
75    /* close the file */    /* close the file */
# Line 74  void Finley_SystemMatrix_saveMM(Finley_S Line 79  void Finley_SystemMatrix_saveMM(Finley_S
79  }  }
80  /*  /*
81   * $Log$   * $Log$
82   * Revision 1.2  2004/12/14 05:39:31  jgs   * Revision 1.3  2004/12/15 03:48:47  jgs
83   * *** empty log message ***   * *** empty log message ***
84   *   *
  * Revision 1.1.1.1.2.1  2004/11/12 06:58:19  gross  
  * a lot of changes to get the linearPDE class running: most important change is that there is no matrix format exposed to the user anymore. the format is chosen by the Domain according to the solver and symmetry  
  *  
85   * Revision 1.1.1.1  2004/10/26 06:53:57  jgs   * Revision 1.1.1.1  2004/10/26 06:53:57  jgs
86   * initial import of project esys2   * initial import of project esys2
87   *   *

Legend:
Removed from v.97  
changed lines
  Added in v.100

  ViewVC Help
Powered by ViewVC 1.1.26