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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 415 - (hide annotations)
Wed Jan 4 05:37:33 2006 UTC (13 years, 9 months ago) by gross
File MIME type: text/plain
File size: 2970 byte(s)
a better way of representing the matrix format type is introduced. this is needed for the Paradiso and UMFPACK interface
1 jgs 150 /* $Id$ */
2    
3     /**************************************************************/
4    
5     /* Paso: SystemMatrix is saved to Matrix Market format */
6    
7     /**************************************************************/
8    
9     /* Copyrights by ACcESS Australia 2003,2004 */
10     /* Author: davies@access.edu.au */
11    
12     /**************************************************************/
13    
14     #include "Paso.h"
15     #include "mmio.h"
16     #include "SystemMatrix.h"
17    
18     void Paso_SystemMatrix_saveMM(Paso_SystemMatrix * A_p, char * fileName_p) {
19    
20     int iRow, iCol, iPtr,ir,ic;
21 gross 415 index_t index_offset=(A_p->type & MATRIX_FORMAT_OFFSET1 ? 1:0);
22 jgs 150
23 gross 415 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 jgs 150 /* open the file */
28     FILE * fileHandle_p = fopen(fileName_p, "w");
29     if (fileHandle_p==NULL) {
30     Paso_setError(IO_ERROR,"file could not be opened for writing");
31     return;
32     }
33    
34     /* set the matrix code */
35     MM_typecode matrixCode;
36     mm_initialize_typecode(&matrixCode);
37     mm_set_matrix(&matrixCode);
38     mm_set_coordinate(&matrixCode);
39     mm_set_real(&matrixCode);
40    
41     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);
43    
44 gross 415 if (A_p->type & MATRIX_FORMAT_CSC) {
45     for (iCol = 0; iCol< A_p->pattern->n_ptr; iCol++) {
46     for (ic = 0; ic< A_p->col_block_size; ic++) {
47     for (iPtr = A_p->pattern->ptr[iCol] - index_offset;iPtr < A_p->pattern->ptr[iCol+1] - index_offset; iPtr++) {
48     for (ir = 0; ir< A_p->row_block_size; ir++) {
49 jgs 150 fprintf(fileHandle_p, "%12d %12d %e\n",
50 gross 415 (A_p->pattern->index[iPtr]-index_offset)*A_p->row_block_size+ir+1,
51     iCol*A_p->col_block_size+ic+ 1,
52 jgs 150 A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
53     }
54     }
55     }
56     }
57 gross 415 } else {
58     for (iRow = 0; iRow< A_p->pattern->n_ptr; iRow++) {
59     for (ir = 0; ir< A_p->row_block_size; ir++) {
60     for (iPtr = A_p->pattern->ptr[iRow] - index_offset;iPtr < A_p->pattern->ptr[iRow+1] - index_offset; iPtr++) {
61     for (ic = 0; ic< A_p->col_block_size; ic++) {
62 jgs 150 fprintf(fileHandle_p, "%12d %12d %e\n",
63 gross 415 iRow*A_p->row_block_size+ir+ 1,
64     (A_p->pattern->index[iPtr]-index_offset)*A_p->col_block_size+ic+1,
65 jgs 150 A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
66     }
67     }
68     }
69     }
70     }
71    
72     /* close the file */
73     fclose(fileHandle_p);
74    
75     return;
76     }
77    
78     /*
79     * $Log$
80     * Revision 1.2 2005/09/15 03:44:39 jgs
81     * Merge of development branch dev-02 back to main trunk on 2005-09-15
82     *
83     * Revision 1.1.2.1 2005/09/05 06:29:48 gross
84     * These files have been extracted from finley to define a stand alone libray for iterative
85     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
86     * has not been tested yet.
87     *
88     *
89     */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26