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

Diff of /trunk/paso/src/SystemMatrix_loadMM.c

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

revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC revision 633 by dhawcroft, Thu Mar 23 05:37:00 2006 UTC
# Line 1  Line 1 
1  /* $Id$ */  /* $Id$ */
2    
3    
4    /*
5    ********************************************************************************
6    *               Copyright   2006 by ACcESS MNRF                                *
7    *                                                                              *
8    *                 http://www.access.edu.au                                     *
9    *           Primary Business: Queensland, Australia                            *
10    *     Licensed under the Open Software License version 3.0             *
11    *        http://www.opensource.org/licenses/osl-3.0.php                        *
12    ********************************************************************************
13    */
14    
15  /**************************************************************/  /**************************************************************/
16    
17  /* Paso: Matrix Market format is loaded to a SystemMatrix   */  /* Paso: Matrix Market format is loaded to a SystemMatrix   */
# Line 93  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 105  Paso_SystemMatrix* Paso_SystemMatrix_loa
105      double *val = NULL;      double *val = NULL;
106    
107      Paso_SystemMatrixPattern *loc_pattern = NULL;      Paso_SystemMatrixPattern *loc_pattern = NULL;
     Paso_SystemMatrixType type = UNKNOWN;  
108      Paso_SystemMatrix *out = NULL;      Paso_SystemMatrix *out = NULL;
109    
110      /* open the file */      /* open the file */
111      FILE *fileHandle_p = fopen( fileName_p, "r" );      FILE *fileHandle_p = fopen( fileName_p, "r" );
112      if( fileHandle_p == NULL )      if( fileHandle_p == NULL )
113      {      {
114          Paso_setError(IO_ERROR, "__FILE__: Cannot read file for reading.");          Paso_setError(IO_ERROR, "Paso_SystemMatrix_loadMM_toCSR: Cannot read file for reading.");
115          return NULL;          return NULL;
116      }      }
117    
118      /* process banner */      /* process banner */
119      if( mm_read_banner(fileHandle_p, &matrixCode) != 0 )      if( mm_read_banner(fileHandle_p, &matrixCode) != 0 )
120      {      {
121          Paso_setError(IO_ERROR, "__FILE__: Error processing MM banner.");          Paso_setError(IO_ERROR, "Paso_SystemMatrix_loadMM_toCSR: Error processing MM banner.");
122          fclose( fileHandle_p );          fclose( fileHandle_p );
123          return NULL;          return NULL;
124      }      }
125      if( !(mm_is_real(matrixCode) && mm_is_sparse(matrixCode) && mm_is_general(matrixCode)) )      if( !(mm_is_real(matrixCode) && mm_is_sparse(matrixCode) && mm_is_general(matrixCode)) )
126      {      {
127          Paso_setError(TYPE_ERROR,"__FILE__: found Matrix Market type is not supported.");  
128            Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_loadMM_toCSR: found Matrix Market type is not supported.");
129          fclose( fileHandle_p );          fclose( fileHandle_p );
130          return NULL;          return NULL;
131      }      }
# Line 121  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 133  Paso_SystemMatrix* Paso_SystemMatrix_loa
133      /* get matrix size */      /* get matrix size */
134      if( mm_read_mtx_crd_size(fileHandle_p, &M, &N, &nz) != 0 )      if( mm_read_mtx_crd_size(fileHandle_p, &M, &N, &nz) != 0 )
135      {      {
136          Paso_setError(IO_ERROR, "__FILE__: Could not parse matrix size");          Paso_setError(IO_ERROR, "Paso_SystemMatrix_loadMM_toCSR: Could not parse matrix size");
137          fclose( fileHandle_p );          fclose( fileHandle_p );
138          return NULL;          return NULL;
139      }      }
# Line 135  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 147  Paso_SystemMatrix* Paso_SystemMatrix_loa
147    
148      if( col_ind == NULL || row_ind == NULL || val == NULL || row_ptr == NULL )      if( col_ind == NULL || row_ind == NULL || val == NULL || row_ptr == NULL )
149      {      {
150          Paso_setError(MEMORY_ERROR, "__FILE__: Could not allocate memory" );          Paso_setError(MEMORY_ERROR, "Paso_SystemMatrix_loadMM_toCSR: Could not allocate memory" );
151    
152          fclose( fileHandle_p );          fclose( fileHandle_p );
153          return NULL;          return NULL;
# Line 164  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 176  Paso_SystemMatrix* Paso_SystemMatrix_loa
176      row_ptr[M] = nz;      row_ptr[M] = nz;
177    
178      /* create F_SMP and F_SM */      /* create F_SMP and F_SM */
179      loc_pattern = Paso_SystemMatrixPattern_alloc( M, row_ptr, col_ind );      loc_pattern = Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT, M, row_ptr, col_ind );
180      if(! Paso_noError() )      if(! Paso_noError() )
181          return NULL;          return NULL;
182    
183      type = CSR;      out = Paso_SystemMatrix_alloc(MATRIX_FORMAT_DEFAULT, loc_pattern, 1, 1 );
     out = Paso_SystemMatrix_alloc( type, loc_pattern, 1, 1 );  
184      if(! Paso_noError() )      if(! Paso_noError() )
185          return NULL;          return NULL;
186    
# Line 197  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 208  Paso_SystemMatrix* Paso_SystemMatrix_loa
208      double *val = NULL;      double *val = NULL;
209    
210      Paso_SystemMatrixPattern *loc_pattern = NULL;      Paso_SystemMatrixPattern *loc_pattern = NULL;
     Paso_SystemMatrixType type = UNKNOWN;  
211      Paso_SystemMatrix *out = NULL;      Paso_SystemMatrix *out = NULL;
212    
213      Paso_resetError();      Paso_resetError();
# Line 206  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 216  Paso_SystemMatrix* Paso_SystemMatrix_loa
216      FILE *fileHandle_p = fopen( fileName_p, "r" );      FILE *fileHandle_p = fopen( fileName_p, "r" );
217      if( fileHandle_p == NULL )      if( fileHandle_p == NULL )
218      {      {
219          Paso_setError(IO_ERROR,"__FILE__: File could not be opened for reading");          Paso_setError(IO_ERROR,"Paso_SystemMatrix_loadMM_toCSC: File could not be opened for reading");
220          return NULL;          return NULL;
221      }      }
222    
223      /* process banner */      /* process banner */
224      if( mm_read_banner(fileHandle_p, &matrixCode) != 0 )      if( mm_read_banner(fileHandle_p, &matrixCode) != 0 )
225      {      {
226          Paso_setError(IO_ERROR,"__FILE__: Error processing MM banner");          Paso_setError(IO_ERROR,"Paso_SystemMatrix_loadMM_toCSC: Error processing MM banner");
227          fclose( fileHandle_p );          fclose( fileHandle_p );
228          return NULL;          return NULL;
229      }      }
230      if( !(mm_is_real(matrixCode) && mm_is_sparse(matrixCode) && mm_is_general(matrixCode)) )      if( !(mm_is_real(matrixCode) && mm_is_sparse(matrixCode) && mm_is_general(matrixCode)) )
231      {      {
232          Paso_setError(TYPE_ERROR,"__FILE__: found Matrix Market type is not supported.");          Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_loadMM_toCSC: found Matrix Market type is not supported.");
233          fclose( fileHandle_p );          fclose( fileHandle_p );
234          return NULL;          return NULL;
235      }      }
# Line 227  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 237  Paso_SystemMatrix* Paso_SystemMatrix_loa
237      /* get matrix size */      /* get matrix size */
238      if( mm_read_mtx_crd_size(fileHandle_p, &M, &N, &nz) != 0 )      if( mm_read_mtx_crd_size(fileHandle_p, &M, &N, &nz) != 0 )
239      {      {
240          Paso_setError(TYPE_ERROR,"__FILE__: found Matrix Market type is not supported.");          Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_loadMM_toCSC: found Matrix Market type is not supported.");
241          fclose( fileHandle_p );          fclose( fileHandle_p );
242          return NULL;          return NULL;
243      }      }
# Line 278  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 288  Paso_SystemMatrix* Paso_SystemMatrix_loa
288      col_ptr[N] = nz;      col_ptr[N] = nz;
289    
290      /* create F_SMP and F_SM */      /* create F_SMP and F_SM */
291  //  loc_pattern = Paso_SystemMatrixPattern_alloc( M, row_ptr, col_ind );  //  loc_pattern = Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT, M, row_ptr, col_ind );
292      loc_pattern = Paso_SystemMatrixPattern_alloc( N, col_ptr, row_ind );      loc_pattern = Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT, N, col_ptr, row_ind );
293      if(! Paso_noError() )      if(! Paso_noError() )
294          return NULL;          return NULL;
295    
296  //  type = CSR;  //      out = Paso_SystemMatrix_alloc( MATRIX_FORMAT_DEFAULT, loc_pattern, 1, 1 );
297      type = CSC;      out = Paso_SystemMatrix_alloc(  MATRIX_FORMAT_CSC, loc_pattern, 1, 1 );
     out = Paso_SystemMatrix_alloc( type, loc_pattern, 1, 1 );  
298      if(! Paso_noError() )      if(! Paso_noError() )
299          return NULL;          return NULL;
300    

Legend:
Removed from v.155  
changed lines
  Added in v.633

  ViewVC Help
Powered by ViewVC 1.1.26