/[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 971 by ksteube, Wed Feb 14 04:40:49 2007 UTC revision 1028 by gross, Wed Mar 14 00:15:24 2007 UTC
# Line 97  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 97  Paso_SystemMatrix* Paso_SystemMatrix_loa
97  {  {
98      int i, curr_row;      int i, curr_row;
99      MM_typecode matrixCode;      MM_typecode matrixCode;
         Paso_resetError();  
   
100      index_t *col_ind = NULL;      index_t *col_ind = NULL;
101      index_t *row_ind = NULL;      index_t *row_ind = NULL;
102      index_t *row_ptr = NULL;      index_t *row_ptr = NULL;
103      double *val = NULL;      double *val = NULL;
104        FILE *fileHandle_p = NULL;
105      Paso_SystemMatrixPattern *loc_pattern = NULL;      Paso_SystemMatrixPattern *loc_pattern = NULL;
106      Paso_SystemMatrix *out = NULL;      Paso_SystemMatrix *out = NULL;
107    
108            Paso_resetError();
109      /* open the file */      /* open the file */
110      FILE *fileHandle_p = fopen( fileName_p, "r" );      fileHandle_p = fopen( fileName_p, "r" );
111      if( fileHandle_p == NULL )      if( fileHandle_p == NULL )
112      {      {
113          Paso_setError(IO_ERROR, "Paso_SystemMatrix_loadMM_toCSR: Cannot read file for reading.");          Paso_setError(IO_ERROR, "Paso_SystemMatrix_loadMM_toCSR: Cannot read file for reading.");
# Line 197  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 196  Paso_SystemMatrix* Paso_SystemMatrix_loa
196  Paso_SystemMatrix* Paso_SystemMatrix_loadMM_toCSC( char *fileName_p )  Paso_SystemMatrix* Paso_SystemMatrix_loadMM_toCSC( char *fileName_p )
197  {  {
198      int i;      int i;
199  //  int curr_row;  /*  int curr_row; */
200      int curr_col;      int curr_col;
201      MM_typecode matrixCode;      MM_typecode matrixCode;
202    
203        FILE *fileHandle_p = NULL;
204      index_t *col_ind = NULL;      index_t *col_ind = NULL;
205      index_t *row_ind = NULL;      index_t *row_ind = NULL;
206  //  index_t *row_ptr = NULL;  /*  index_t *row_ptr = NULL; */
207      index_t *col_ptr = NULL;      index_t *col_ptr = NULL;
208      double *val = NULL;      double *val = NULL;
209    
# Line 213  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 213  Paso_SystemMatrix* Paso_SystemMatrix_loa
213      Paso_resetError();      Paso_resetError();
214    
215      /* open the file */      /* open the file */
216      FILE *fileHandle_p = fopen( fileName_p, "r" );      fileHandle_p = fopen( fileName_p, "r" );
217      if( fileHandle_p == NULL )      if( fileHandle_p == NULL )
218      {      {
219          Paso_setError(IO_ERROR,"Paso_SystemMatrix_loadMM_toCSC: File could not be opened for reading");          Paso_setError(IO_ERROR,"Paso_SystemMatrix_loadMM_toCSC: File could not be opened for reading");
# Line 247  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 247  Paso_SystemMatrix* Paso_SystemMatrix_loa
247      row_ind = MEMALLOC( nz, index_t );      row_ind = MEMALLOC( nz, index_t );
248      val = MEMALLOC( nz, double );      val = MEMALLOC( nz, double );
249    
250  //  row_ptr = MEMALLOC( (M+1), index_t );  /*  row_ptr = MEMALLOC( (M+1), index_t ); */
251      col_ptr = MEMALLOC( (N+1), index_t );      col_ptr = MEMALLOC( (N+1), index_t );
252    
253    
254  //  if( col_ind == NULL || row_ind == NULL || val == NULL || row_ptr == NULL )  /*  if( col_ind == NULL || row_ind == NULL || val == NULL || row_ptr == NULL )
255      if( col_ind == NULL || row_ind == NULL || val == NULL || col_ptr == NULL )      if( col_ind == NULL || row_ind == NULL || val == NULL || col_ptr == NULL )
256      {      {
257          Paso_setError(MEMORY_ERROR,"Could not allocate memory" );          Paso_setError(MEMORY_ERROR,"Could not allocate memory" );
# Line 269  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 269  Paso_SystemMatrix* Paso_SystemMatrix_loa
269      fclose( fileHandle_p );      fclose( fileHandle_p );
270    
271      /* sort the entries */      /* sort the entries */
272  //  q_sort( row_ind, col_ind, val, 0, nz );  /*  q_sort( row_ind, col_ind, val, 0, nz ); */
273      q_sort( col_ind, row_ind, val, 0, nz );      q_sort( col_ind, row_ind, val, 0, nz );
274    
275      /* setup row_ptr */      /* setup row_ptr */
276  //  curr_row = 0;  /*  curr_row = 0;
277      curr_col = 0;      curr_col = 0;
278  //  for( i=0; (i<nz && curr_row<M); curr_row++ )  /*  for( i=0; (i<nz && curr_row<M); curr_row++ ) */
279      for( i=0; (i<nz && curr_col<N); curr_col++ )      for( i=0; (i<nz && curr_col<N); curr_col++ )
280      {      {
281  //      while( row_ind[i] != curr_row )  /*      while( row_ind[i] != curr_row ) */
282          while( col_ind[i] != curr_col )          while( col_ind[i] != curr_col )
283              i++;              i++;
284  //      row_ptr[curr_row] = i;  /*      row_ptr[curr_row] = i; */
285          col_ptr[curr_col] = i;          col_ptr[curr_col] = i;
286      }      }
287  //  row_ptr[M] = nz;  /*  row_ptr[M] = nz; */
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(PATTERN_FORMAT_DEFAULT, M, row_ptr, col_ind );  /*  loc_pattern = Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT, M, row_ptr, col_ind ); */
292      loc_pattern = Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT, 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  //      out = Paso_SystemMatrix_alloc( MATRIX_FORMAT_DEFAULT, loc_pattern, 1, 1 );  /*      out = Paso_SystemMatrix_alloc( MATRIX_FORMAT_DEFAULT, loc_pattern, 1, 1 ); */
297      out = Paso_SystemMatrix_alloc(  MATRIX_FORMAT_CSC, loc_pattern, 1, 1 );      out = Paso_SystemMatrix_alloc(  MATRIX_FORMAT_CSC, loc_pattern, 1, 1 );
298      if(! Paso_noError() )      if(! Paso_noError() )
299          return NULL;          return NULL;
# Line 303  Paso_SystemMatrix* Paso_SystemMatrix_loa Line 303  Paso_SystemMatrix* Paso_SystemMatrix_loa
303          out->val[i] = val[i];          out->val[i] = val[i];
304    
305      MEMFREE( val );      MEMFREE( val );
306  //  MEMFREE( row_ind );  /*  MEMFREE( row_ind ); */
307      MEMFREE( col_ind );      MEMFREE( col_ind );
308    
309      return out;      return out;

Legend:
Removed from v.971  
changed lines
  Added in v.1028

  ViewVC Help
Powered by ViewVC 1.1.26