/[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 633 - (hide annotations)
Thu Mar 23 05:37:00 2006 UTC (13 years, 7 months ago) by dhawcroft
File MIME type: text/plain
File size: 3615 byte(s)


1 jgs 150 /* $Id$ */
2    
3 dhawcroft 631 /*
4     ********************************************************************************
5 dhawcroft 633 * Copyright 2006 by ACcESS MNRF *
6 dhawcroft 631 * *
7     * http://www.access.edu.au *
8     * Primary Business: Queensland, Australia *
9     * Licensed under the Open Software License version 3.0 *
10     * http://www.opensource.org/licenses/osl-3.0.php *
11     ********************************************************************************
12     */
13    
14 jgs 150 /**************************************************************/
15    
16     /* Paso: SystemMatrix is saved to Matrix Market format */
17    
18     /**************************************************************/
19    
20     /* Copyrights by ACcESS Australia 2003,2004 */
21     /* Author: davies@access.edu.au */
22    
23     /**************************************************************/
24    
25     #include "Paso.h"
26     #include "mmio.h"
27     #include "SystemMatrix.h"
28    
29     void Paso_SystemMatrix_saveMM(Paso_SystemMatrix * A_p, char * fileName_p) {
30    
31     int iRow, iCol, iPtr,ir,ic;
32 gross 415 index_t index_offset=(A_p->type & MATRIX_FORMAT_OFFSET1 ? 1:0);
33 jgs 150
34 gross 415 if (A_p->type & MATRIX_FORMAT_SYM) {
35     Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM does not support symmetric storage scheme");
36     return;
37     }
38 jgs 150 /* open the file */
39     FILE * fileHandle_p = fopen(fileName_p, "w");
40     if (fileHandle_p==NULL) {
41     Paso_setError(IO_ERROR,"file could not be opened for writing");
42     return;
43     }
44    
45     /* set the matrix code */
46     MM_typecode matrixCode;
47     mm_initialize_typecode(&matrixCode);
48     mm_set_matrix(&matrixCode);
49     mm_set_coordinate(&matrixCode);
50     mm_set_real(&matrixCode);
51    
52     mm_write_banner(fileHandle_p, matrixCode);
53     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);
54    
55 gross 415 if (A_p->type & MATRIX_FORMAT_CSC) {
56     for (iCol = 0; iCol< A_p->pattern->n_ptr; iCol++) {
57     for (ic = 0; ic< A_p->col_block_size; ic++) {
58     for (iPtr = A_p->pattern->ptr[iCol] - index_offset;iPtr < A_p->pattern->ptr[iCol+1] - index_offset; iPtr++) {
59     for (ir = 0; ir< A_p->row_block_size; ir++) {
60 jgs 150 fprintf(fileHandle_p, "%12d %12d %e\n",
61 gross 415 (A_p->pattern->index[iPtr]-index_offset)*A_p->row_block_size+ir+1,
62     iCol*A_p->col_block_size+ic+ 1,
63 jgs 150 A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
64     }
65     }
66     }
67     }
68 gross 415 } else {
69     for (iRow = 0; iRow< A_p->pattern->n_ptr; iRow++) {
70     for (ir = 0; ir< A_p->row_block_size; ir++) {
71     for (iPtr = A_p->pattern->ptr[iRow] - index_offset;iPtr < A_p->pattern->ptr[iRow+1] - index_offset; iPtr++) {
72     for (ic = 0; ic< A_p->col_block_size; ic++) {
73 jgs 150 fprintf(fileHandle_p, "%12d %12d %e\n",
74 gross 415 iRow*A_p->row_block_size+ir+ 1,
75     (A_p->pattern->index[iPtr]-index_offset)*A_p->col_block_size+ic+1,
76 jgs 150 A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
77     }
78     }
79     }
80     }
81     }
82    
83     /* close the file */
84     fclose(fileHandle_p);
85    
86     return;
87     }
88    
89     /*
90     * $Log$
91     * Revision 1.2 2005/09/15 03:44:39 jgs
92     * Merge of development branch dev-02 back to main trunk on 2005-09-15
93     *
94     * Revision 1.1.2.1 2005/09/05 06:29:48 gross
95     * These files have been extracted from finley to define a stand alone libray for iterative
96     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
97     * has not been tested yet.
98     *
99     *
100     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26