/[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 414 by jgs, Wed Nov 9 02:02:19 2005 UTC revision 415 by gross, Wed Jan 4 05:37:33 2006 UTC
# Line 93  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 93  Paso_SystemMatrix* Paso_SystemMatrix_loa
93      double *val = NULL;      double *val = NULL;
94    
95      Paso_SystemMatrixPattern *loc_pattern = NULL;      Paso_SystemMatrixPattern *loc_pattern = NULL;
     Paso_SystemMatrixType type = UNKNOWN;  
96      Paso_SystemMatrix *out = NULL;      Paso_SystemMatrix *out = NULL;
97    
98      /* open the file */      /* open the file */
99      FILE *fileHandle_p = fopen( fileName_p, "r" );      FILE *fileHandle_p = fopen( fileName_p, "r" );
100      if( fileHandle_p == NULL )      if( fileHandle_p == NULL )
101      {      {
102          Paso_setError(IO_ERROR, "__FILE__: Cannot read file for reading.");          Paso_setError(IO_ERROR, "Paso_SystemMatrix_loadMM_toCSR: Cannot read file for reading.");
103          return NULL;          return NULL;
104      }      }
105    
106      /* process banner */      /* process banner */
107      if( mm_read_banner(fileHandle_p, &matrixCode) != 0 )      if( mm_read_banner(fileHandle_p, &matrixCode) != 0 )
108      {      {
109          Paso_setError(IO_ERROR, "__FILE__: Error processing MM banner.");          Paso_setError(IO_ERROR, "Paso_SystemMatrix_loadMM_toCSR: Error processing MM banner.");
110          fclose( fileHandle_p );          fclose( fileHandle_p );
111          return NULL;          return NULL;
112      }      }
113      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)) )
114      {      {
115          Paso_setError(TYPE_ERROR,"__FILE__: found Matrix Market type is not supported.");  
116            Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_loadMM_toCSR: found Matrix Market type is not supported.");
117          fclose( fileHandle_p );          fclose( fileHandle_p );
118          return NULL;          return NULL;
119      }      }
# Line 121  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 121  Paso_SystemMatrix* Paso_SystemMatrix_loa
121      /* get matrix size */      /* get matrix size */
122      if( mm_read_mtx_crd_size(fileHandle_p, &M, &N, &nz) != 0 )      if( mm_read_mtx_crd_size(fileHandle_p, &M, &N, &nz) != 0 )
123      {      {
124          Paso_setError(IO_ERROR, "__FILE__: Could not parse matrix size");          Paso_setError(IO_ERROR, "Paso_SystemMatrix_loadMM_toCSR: Could not parse matrix size");
125          fclose( fileHandle_p );          fclose( fileHandle_p );
126          return NULL;          return NULL;
127      }      }
# Line 135  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 135  Paso_SystemMatrix* Paso_SystemMatrix_loa
135    
136      if( col_ind == NULL || row_ind == NULL || val == NULL || row_ptr == NULL )      if( col_ind == NULL || row_ind == NULL || val == NULL || row_ptr == NULL )
137      {      {
138          Paso_setError(MEMORY_ERROR, "__FILE__: Could not allocate memory" );          Paso_setError(MEMORY_ERROR, "Paso_SystemMatrix_loadMM_toCSR: Could not allocate memory" );
139    
140          fclose( fileHandle_p );          fclose( fileHandle_p );
141          return NULL;          return NULL;
# Line 164  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 164  Paso_SystemMatrix* Paso_SystemMatrix_loa
164      row_ptr[M] = nz;      row_ptr[M] = nz;
165    
166      /* create F_SMP and F_SM */      /* create F_SMP and F_SM */
167      loc_pattern = Paso_SystemMatrixPattern_alloc( M, row_ptr, col_ind );      loc_pattern = Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT, M, row_ptr, col_ind );
168      if(! Paso_noError() )      if(! Paso_noError() )
169          return NULL;          return NULL;
170    
171      type = CSR;      out = Paso_SystemMatrix_alloc(MATRIX_FORMAT_DEFAULT, loc_pattern, 1, 1 );
     out = Paso_SystemMatrix_alloc( type, loc_pattern, 1, 1 );  
172      if(! Paso_noError() )      if(! Paso_noError() )
173          return NULL;          return NULL;
174    
# Line 197  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 196  Paso_SystemMatrix* Paso_SystemMatrix_loa
196      double *val = NULL;      double *val = NULL;
197    
198      Paso_SystemMatrixPattern *loc_pattern = NULL;      Paso_SystemMatrixPattern *loc_pattern = NULL;
     Paso_SystemMatrixType type = UNKNOWN;  
199      Paso_SystemMatrix *out = NULL;      Paso_SystemMatrix *out = NULL;
200    
201      Paso_resetError();      Paso_resetError();
# Line 206  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 204  Paso_SystemMatrix* Paso_SystemMatrix_loa
204      FILE *fileHandle_p = fopen( fileName_p, "r" );      FILE *fileHandle_p = fopen( fileName_p, "r" );
205      if( fileHandle_p == NULL )      if( fileHandle_p == NULL )
206      {      {
207          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");
208          return NULL;          return NULL;
209      }      }
210    
211      /* process banner */      /* process banner */
212      if( mm_read_banner(fileHandle_p, &matrixCode) != 0 )      if( mm_read_banner(fileHandle_p, &matrixCode) != 0 )
213      {      {
214          Paso_setError(IO_ERROR,"__FILE__: Error processing MM banner");          Paso_setError(IO_ERROR,"Paso_SystemMatrix_loadMM_toCSC: Error processing MM banner");
215          fclose( fileHandle_p );          fclose( fileHandle_p );
216          return NULL;          return NULL;
217      }      }
218      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)) )
219      {      {
220          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.");
221          fclose( fileHandle_p );          fclose( fileHandle_p );
222          return NULL;          return NULL;
223      }      }
# Line 227  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 225  Paso_SystemMatrix* Paso_SystemMatrix_loa
225      /* get matrix size */      /* get matrix size */
226      if( mm_read_mtx_crd_size(fileHandle_p, &M, &N, &nz) != 0 )      if( mm_read_mtx_crd_size(fileHandle_p, &M, &N, &nz) != 0 )
227      {      {
228          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.");
229          fclose( fileHandle_p );          fclose( fileHandle_p );
230          return NULL;          return NULL;
231      }      }
# Line 278  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 276  Paso_SystemMatrix* Paso_SystemMatrix_loa
276      col_ptr[N] = nz;      col_ptr[N] = nz;
277    
278      /* create F_SMP and F_SM */      /* create F_SMP and F_SM */
279  //  loc_pattern = Paso_SystemMatrixPattern_alloc( M, row_ptr, col_ind );  //  loc_pattern = Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT, M, row_ptr, col_ind );
280      loc_pattern = Paso_SystemMatrixPattern_alloc( N, col_ptr, row_ind );      loc_pattern = Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT, N, col_ptr, row_ind );
281      if(! Paso_noError() )      if(! Paso_noError() )
282          return NULL;          return NULL;
283    
284  //  type = CSR;  //      out = Paso_SystemMatrix_alloc( MATRIX_FORMAT_DEFAULT, loc_pattern, 1, 1 );
285      type = CSC;      out = Paso_SystemMatrix_alloc(  MATRIX_FORMAT_CSC, loc_pattern, 1, 1 );
     out = Paso_SystemMatrix_alloc( type, loc_pattern, 1, 1 );  
286      if(! Paso_noError() )      if(! Paso_noError() )
287          return NULL;          return NULL;
288    

Legend:
Removed from v.414  
changed lines
  Added in v.415

  ViewVC Help
Powered by ViewVC 1.1.26