src/GamIO/ML5Imags.cc
/* These are the functions which will output the sub-element in MATLAB ".mat" 
   binary format, version 5.  This is done with a pair {tag,data}.  Both the
   tag & data will be written directly from these functions, bypassing the 
   associated class structures which have no knowledge of GAMMA array types. 
  
   Remember, the MATLAB MAT version 5 tag for this sub-element contains 
   8-bytes with two important settings: 1.) data type & 2.) # of bytes. 
   The data type is placed in the first 4 bytes and the number of bytes 
   placed into the last 4 bytes (for non-compressed data elements which we 
   will always output...).  In this case, we output the elements as doubles
   so that the data type should be MATLAB type miDOUBLE, i.e. value 9. 
  
                Input           ML5Im   : MAT version 5 imags SE (this)
                                fp      : Output file stream 
                                mx      : GAMMA matrix 
                                rv      : GAMMA row vector 
                                cv      : GAMMA column vector 
                Output          void    : Output file stream is modified 
                                          by having the ML5Im written to it 
                Note                    : No care taken herein to insure the 
                                          sub-element is properly written.   */
These are the functions which will output the sub-element in MATLAB ".mat"
binary format, version 5.  This is done with a pair {tag,data}.  Both the
tag & data will be written directly from these functions, bypassing the
associated class structures which have no knowledge of GAMMA array types.

Remember, the MATLAB MAT version 5 tag for this sub-element contains
8-bytes with two important settings: 1.) data type & 2.) # of bytes.
The data type is placed in the first 4 bytes and the number of bytes
placed into the last 4 bytes (for non-compressed data elements which we
will always output...).  In this case, we output the elements as doubles
so that the data type should be MATLAB type miDOUBLE, i.e. value 9.


These are the functions which will output the sub - element in MATLAB " . mat " binary format version 5 . This is done with a pair { tag data } . Both the tag & data will be written directly from these functions bypassing the associated class structures which have no knowledge of GAMMA array types . Remember the MATLAB MAT version 5 tag for this sub - element contains 8 - bytes with two important settings : 1 . ) data type & 2 . ) # of bytes . The data type is placed in the first 4 bytes and the number of bytes placed into the last 4 bytes ( for non - compressed data elements which we will always output ... ) . In this case we output the elements as doubles so that the data type should be MATLAB type miDOUBLE i . e . value 9 .
int MatLab5Im::write(std::fstream& fp, const matrix& mx) const
  {
  int32_t TB = 9;                                  
  fp.write((char*)&TB, sizeof(int32_t));                  
  TB = mx.rows()*mx.cols()*sizeof(double);      
  fp.write((char*)&TB, sizeof(int32_t));                  
  int i,j;
  double d;
  for(j=0; j<mx.cols(); j++)                    
    for(i=0; i<mx.rows(); i++)                  
      {
      d = mx.getIm(i,j);
      fp.write((char*)&d, sizeof(double));
      }
  return 1;
  }
int MatLab5Im :: write ( std :: fstream & fp , const matrix & mx ) const { int32_t TB = 9 ; fp . write ( ( char * ) & TB , sizeof ( int32_t ) ) ; TB = mx . rows ( ) * mx . cols ( ) * sizeof ( double ) ; fp . write ( ( char * ) & TB , sizeof ( int32_t ) ) ; int i , j ; double d ; for ( j = 0 ; j < mx . cols ( ) ; j ++ ) for ( i = 0 ; i < mx . rows ( ) ; i ++ ) { d = mx . getIm ( i , j ) ; fp . write ( ( char * ) & d , sizeof ( double ) ) ; } return 1 ; }
These are the functions which will output the sub-element in MATLAB ".mat"
binary format, version 5.
These are the functions which will output the sub - element in MATLAB " . mat " binary format version 5 .
// MATLAB data type miDOUBLE // Output the data type  (TAG) // Number of bytes to output // Output the # of bytes (TAG) // Output the imag elements of // the matrix column by column