Department of Scientific Computing   
Institute for Numerical Simulation   
University of Bonn   
Documentation
Download
Programming References
Bug Reports / Suggestions
FAQ
Authors
Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SparseMatrixIO.cc

00001 #include "SparseMatrixIO.hpp"
00002 
00003 void ReadMATLABSparseHeader(FILE *fid, int DIM,
00004                             int *header, int *anz, int *jmax, int *NumberOfComponents, 
00005                             double *XA , double *XE, 
00006                             bool *CastToFloat, bool *do_swap) 
00007 {
00008   int i ;
00009 
00010   *do_swap = UDF_CPUisBigEndian() > 0 ;
00011 
00012   fread(header    , sizeof(int), 1          , fid) ;
00013   if (*do_swap) UDF_swap(header,sizeof(int),1) ;
00014 
00015   fread(&header[1], sizeof(int), header[0]-1, fid) ;
00016   if (*do_swap) UDF_swap(&header[1],sizeof(int),header[0]-1) ;
00017 
00018   // decode header
00019   if (header[1]!=DIM) { 
00020     std::cout << "header="<<header[1]<<" DIM="<<DIM<<'\n' ;
00021     exit(-1) ;
00022   }
00023 
00024   *anz =header[2] ;
00025   *jmax=header[3] ;
00026 
00027   // XA/E
00028   float *p=(float *)(&header[4]) ;
00029   for (i=0; i<DIM; i++) {
00030     float xa,xe ;
00031     xa=(*p) ; p++ ;
00032     xe=(*p) ; p++ ;
00033    
00034     // xa,xe resonable ?
00035     if ((xe > xa) && (xa > -1000) && (xe < 1000)) { 
00036       XA[i]=xa  ; XE[i]=xe ;
00037     }
00038     else {
00039       XA[i]=0.0 ; XE[i]=1.0 ;
00040     }
00041   }
00042 
00043   //
00044   *NumberOfComponents=header[4+2*DIM] ;
00045   if (*NumberOfComponents==0) {
00046     *NumberOfComponents=1 ;
00047    }
00048   *CastToFloat = header[5+2*DIM] > 0 ;
00049   
00050 }
00051 

Generated at Mon Aug 19 10:02:32 2002 for AWFD by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001