src/GamIO/ML4DElem.cc
/* These functons perform binary I/O of the "data" components of an MATLAB
   MAT version 4 data element. There are two components in each element, a
   name (series of characters ending in \0) followed by data.  The functions
   below will read/write these directly from a file.  They do NOT have any
   regard over file positioning and utilize the Tag/Header information.  Thus
   the Tag values should be proper and the name/data will be related to the
   string Name and the matrix Data.  Upon read, the data elements will 
   perform the required conversion(s) as needed.                             
 
           Input                fp       : A file stream
           Output               void/int : The data array and array name
                                           are written/read to/from the file
                                           stream in MATLAB MAT V4 format    */
These functons perform binary I/O of the "data" components of an MATLAB
MAT version 4 data element. There are two components in each element, a
name (series of characters ending in \0) followed by data.  The functions
below will read/write these directly from a file.  They do NOT have any
regard over file positioning and utilize the Tag/Header information.  Thus
the Tag values should be proper and the name/data will be related to the
string Name and the matrix Data.  Upon read, the data elements will
perform the required conversion(s) as needed.

Input                fp       : A file stream
Output               void/int : The data array and array name
are written/read to/from the file
stream in MATLAB MAT V4 format
These functons perform binary I / O of the " data " components of an MATLAB MAT version 4 data element . There are two components in each element a name ( series of characters ending in \ 0 ) followed by data . The functions below will read / write these directly from a file . They do NOT have any regard over file positioning and utilize the Tag / Header information . Thus the Tag values should be proper and the name / data will be related to the string Name and the matrix Data . Upon read the data elements will perform the required conversion ( s ) as needed . Input fp : A file stream Output void / int : The data array and array name are written / read to / from the file stream in MATLAB MAT V4 format
int MatLab4DE::WriteMx(std::fstream& fp) const
  {
  double d;
  int i,j;
  for(j=0; j<Tag.ncols; j++)		
    for(i=0; i<Tag.mrows; i++) 		
      { 				
      d = Data.getRe(i,j);
      fp.write((char*)&d, sizeof(double));
      } 
  if(Tag.cmplxf)			
    {					
    for(j=0; j<Tag.ncols; j++) 		
      for(i=0; i<Tag.mrows; i++)	
        {
        d = Data.getIm(i,j);
        fp.write((char*)&d, sizeof(double));
        } 
    }
  return 1;
  }
int MatLab4DE :: WriteMx ( std :: fstream & fp ) const { double d ; int i , j ; for ( j = 0 ; j < Tag . ncols ; j ++ ) for ( i = 0 ; i < Tag . mrows ; i ++ ) { d = Data . getRe ( i , j ) ; fp . write ( ( char * ) & d , sizeof ( double ) ) ; } if ( Tag . cmplxf ) { for ( j = 0 ; j < Tag . ncols ; j ++ ) for ( i = 0 ; i < Tag . mrows ; i ++ ) { d = Data . getIm ( i , j ) ; fp . write ( ( char * ) & d , sizeof ( double ) ) ; } } return 1 ; }
These functons perform binary I/O of the "data" components of an MATLAB
MAT version 4 data element.
These functons perform binary I / O of the " data " components of an MATLAB MAT version 4 data element .
// First output the real part // We output the matrix reals // column by column // Next output the imaginary part // if they are desired // We output the matrix imaginaries // column by column