/[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 1028 - (hide annotations)
Wed Mar 14 00:15:24 2007 UTC (12 years, 7 months ago) by gross
File MIME type: text/plain
File size: 3638 byte(s)
modifications to be compliant with _WIN32. The substitutes for asinh, acosh, atanh are still missing (erf will through an exception)
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 gross 1028 FILE * fileHandle_p = NULL;
34     MM_typecode matrixCode;
35 jgs 150
36 gross 415 if (A_p->type & MATRIX_FORMAT_SYM) {
37     Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM does not support symmetric storage scheme");
38     return;
39     }
40 jgs 150 /* open the file */
41 gross 1028 fileHandle_p = fopen(fileName_p, "w");
42 jgs 150 if (fileHandle_p==NULL) {
43     Paso_setError(IO_ERROR,"file could not be opened for writing");
44     return;
45     }
46    
47     /* set the matrix code */
48     mm_initialize_typecode(&matrixCode);
49     mm_set_matrix(&matrixCode);
50     mm_set_coordinate(&matrixCode);
51     mm_set_real(&matrixCode);
52    
53     mm_write_banner(fileHandle_p, matrixCode);
54     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);
55    
56 gross 415 if (A_p->type & MATRIX_FORMAT_CSC) {
57     for (iCol = 0; iCol< A_p->pattern->n_ptr; iCol++) {
58     for (ic = 0; ic< A_p->col_block_size; ic++) {
59     for (iPtr = A_p->pattern->ptr[iCol] - index_offset;iPtr < A_p->pattern->ptr[iCol+1] - index_offset; iPtr++) {
60     for (ir = 0; ir< A_p->row_block_size; ir++) {
61 jgs 150 fprintf(fileHandle_p, "%12d %12d %e\n",
62 gross 415 (A_p->pattern->index[iPtr]-index_offset)*A_p->row_block_size+ir+1,
63     iCol*A_p->col_block_size+ic+ 1,
64 jgs 150 A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
65     }
66     }
67     }
68     }
69 gross 415 } else {
70     for (iRow = 0; iRow< A_p->pattern->n_ptr; iRow++) {
71     for (ir = 0; ir< A_p->row_block_size; ir++) {
72     for (iPtr = A_p->pattern->ptr[iRow] - index_offset;iPtr < A_p->pattern->ptr[iRow+1] - index_offset; iPtr++) {
73     for (ic = 0; ic< A_p->col_block_size; ic++) {
74 jgs 150 fprintf(fileHandle_p, "%12d %12d %e\n",
75 gross 415 iRow*A_p->row_block_size+ir+ 1,
76     (A_p->pattern->index[iPtr]-index_offset)*A_p->col_block_size+ic+1,
77 jgs 150 A_p->val[iPtr*A_p->block_size+ir+A_p->row_block_size*ic]);
78     }
79     }
80     }
81     }
82     }
83    
84     /* close the file */
85     fclose(fileHandle_p);
86    
87     return;
88     }
89    
90     /*
91     * $Log$
92     * Revision 1.2 2005/09/15 03:44:39 jgs
93     * Merge of development branch dev-02 back to main trunk on 2005-09-15
94     *
95     * Revision 1.1.2.1 2005/09/05 06:29:48 gross
96     * These files have been extracted from finley to define a stand alone libray for iterative
97     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
98     * has not been tested yet.
99     *
100     *
101     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26