/[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 96 by jgs, Tue Oct 26 06:53:54 2004 UTC revision 97 by jgs, Tue Dec 14 05:39:33 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;    int iRow, iCol, iPtr,ir,ic;
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->num_cols, A_p->ptr[A_p->num_cols] - PTR_OFFSET);    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);
39    
40    switch(A_p->type) {    switch(A_p->type) {
41    case CSR:    case CSR:
42      #if INDEX_OFFSET==0        for (iRow = 0; iRow< A_p->pattern->n_ptr; iRow++) {
43        /* add 1 for 1-based indexing */           for (ir = 0; ir< A_p->row_block_size; ir++) {
44        for (iRow = 0; iRow < A_p->num_rows; iRow++)          for (iPtr = A_p->pattern->ptr[iRow] - PTR_OFFSET;iPtr < A_p->pattern->ptr[iRow+1] - PTR_OFFSET; iPtr++) {
45      for (iPtr = A_p->ptr[iRow] - PTR_OFFSET;                 for (ic = 0; ic< A_p->col_block_size; ic++) {
46           iPtr < A_p->ptr[iRow+1] - PTR_OFFSET; iPtr++)                fprintf(fileHandle_p, "%12d %12d %22.15g\n",
47        fprintf(fileHandle_p, "%12d %12d %22.15g\n",                    iRow*A_p->row_block_size+ir+ 1,
48            iRow + 1,  A_p->index[iPtr] + 1, A_p->val[iPtr]);                    (A_p->pattern->index[iPtr]-INDEX_OFFSET)*A_p->col_block_size+ic+1,
49      #else                    A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
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        fprintf(fileHandle_p, "%12d %12d %22.15g\n",        break;
           iRow + INDEX_OFFSET, A_p->index[iPtr], A_p->val[iPtr]);  
     #endif  
     break;  
55    case CSC:    case CSC:
56      #if INDEX_OFFSET==0        for (iCol = 0; iCol< A_p->pattern->n_ptr; iCol++) {
57        /* add 1 for 1-based indexing */           for (ic = 0; ic< A_p->col_block_size; ic++) {
58        for (iCol = 0; iCol < A_p->num_cols; iCol++)          for (iPtr = A_p->pattern->ptr[iCol] - PTR_OFFSET;iPtr < A_p->pattern->ptr[iCol+1] - PTR_OFFSET; iPtr++) {
59      for (iPtr = A_p->ptr[iCol] - PTR_OFFSET;                 for (ir = 0; ir< A_p->row_block_size; ir++) {
60           iPtr < A_p->ptr[iCol+1] - PTR_OFFSET; iPtr++)                fprintf(fileHandle_p, "%12d %12d %22.15g\n",
61        fprintf(fileHandle_p, "%12d %12d %22.15g\n", A_p->index[iPtr] + 1, iCol + 1, A_p->val[iPtr]);                    (A_p->pattern->index[iPtr]-INDEX_OFFSET)*A_p->row_block_size+ir+1,
62      #else                    iCol*A_p->col_block_size+ic+ 1,
63        /* matrix market uses 1-based indexing */                    A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
64        for (iCol = 0; iCol< A_p->num_cols; iCol++)                 }
65      for (iPtr = A_p->ptr[iCol] - PTR_OFFSET;              }
66           iPtr < A_p->ptr[iCol+1] - PTR_OFFSET; iPtr++)           }
67        fprintf(fileHandle_p, "%12d %12d %22.15g\n", A_p->index[iPtr],        }
           iCol + INDEX_OFFSET, A_p->val[iPtr]);  
     #endif  
68    }    }
69    
70    /* close the file */    /* close the file */
# Line 79  void Finley_SystemMatrix_saveMM(Finley_S Line 74  void Finley_SystemMatrix_saveMM(Finley_S
74  }  }
75  /*  /*
76   * $Log$   * $Log$
77   * Revision 1.1  2004/10/26 06:53:57  jgs   * Revision 1.2  2004/12/14 05:39:31  jgs
78   * Initial revision   * *** empty log message ***
79     *
80     * Revision 1.1.1.1.2.1  2004/11/12 06:58:19  gross
81     * 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
82     *
83     * Revision 1.1.1.1  2004/10/26 06:53:57  jgs
84     * initial import of project esys2
85   *   *
86   * Revision 1.1  2004/07/02 04:21:13  gross   * Revision 1.1  2004/07/02 04:21:13  gross
87   * Finley C code has been included   * Finley C code has been included

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

  ViewVC Help
Powered by ViewVC 1.1.26