src/GamIO/ML5DA.cc
/* These are the functions which will input a sub-element in MATLAB ".mat"
   binary format, version 5.  Note that in a valid MATLAB MAT file, a 
   "Dimensions Array Sub-Element" is a combination of Tag + Data
 
                Input           ML5DA   : MAT version 5 dim. array (this)
                                fp      : Input file stream
                                warn     : Warning output level
                                                0 = no warnings
                                                1 = warnings
                                               >1 = fatal warnings
                Output          void    : ML5DA is set from values found
                                          in the input stream
                Note                    : No care is taken to insure the
                                          dim. array is read from the top of
 					  a data element (as it should be 
					  in MATLAB)                         */
These are the functions which will input a sub-element in MATLAB ".mat"
binary format, version 5.  Note that in a valid MATLAB MAT file, a
"Dimensions Array Sub-Element" is a combination of Tag + Data

Input           ML5DA   : MAT version 5 dim. array (this)
fp      : Input file stream
warn     : Warning output level
0 = no warnings
1 = warnings
>1 = fatal warnings
Output          void    : ML5DA is set from values found
in the input stream
Note                    : No care is taken to insure the
dim. array is read from the top of
a data element (as it should be
in MATLAB)
These are the functions which will input a sub - element in MATLAB " . mat " binary format version 5 . Note that in a valid MATLAB MAT file a " Dimensions Array Sub - Element " is a combination of Tag + Data Input ML5DA : MAT version 5 dim . array ( this ) fp : Input file stream warn : Warning output level 0 = no warnings 1 = warnings > 1 = fatal warnings Output void : ML5DA is set from values found in the input stream Note : No care is taken to insure the dim . array is read from the top of a data element ( as it should be in MATLAB )
int MatLab5DA::read(std::fstream& fp, int bigend, int warn)
  {
int MaxDims=5;
int MaxDim=524288;
  if(!MatLab5SE::read(fp, bigend, (warn)?1:0))	
    {						
    if(warn)					
      {						
      if(warn==1) MLDA5error(10, 1);
      else        MLDA5fatality(10);
      }
    return 0;
    }
  ND = MLTag.Bytes()/4;				
  if(ND < 2 || ND>MaxDims)
    {
    if(warn)
      {
      MLDA5error(11, 1);
      if(warn > 1) MLDA5fatality(20);
      else         MLDA5error(20);
      }
    }
  if(Sizes) delete [] Sizes;			
  Sizes = new int[ND];				
  longchars LC;					
  int swap = 0;
  if(bigend != int(WeRBigEnd())) swap++;
  for(int i=0; i<ND; i++)
    { 
    LC.chars[0] = MLData[0+4*i];
    LC.chars[1] = MLData[1+4*i];
    LC.chars[2] = MLData[2+4*i];	
    LC.chars[3] = MLData[3+4*i];
    if(swap) Swap(LC.longval);
    Sizes[i] = int(LC.longval);
    if(Sizes[i]<1 || Sizes[i]>MaxDim)
      {
      if(warn)
        {
        MLDA5error(12, 1);
        if(warn > 1) MLDA5fatality(20);
        else         MLDA5error(20);
        }
      }
    } 
  return 1;
  }
int MatLab5DA :: read ( std :: fstream & fp , int bigend , int warn ) { int MaxDims = 5 ; int MaxDim = 524288 ; if ( ! MatLab5SE :: read ( fp , bigend , ( warn ) ? 1 : 0 ) ) { if ( warn ) { if ( warn == 1 ) MLDA5error ( 10 , 1 ) ; else MLDA5fatality ( 10 ) ; } return 0 ; } ND = MLTag . Bytes ( ) / 4 ; if ( ND < 2 || ND > MaxDims ) { if ( warn ) { MLDA5error ( 11 , 1 ) ; if ( warn > 1 ) MLDA5fatality ( 20 ) ; else MLDA5error ( 20 ) ; } } if ( Sizes ) delete [ ] Sizes ; Sizes = new int [ ND ] ; longchars LC ; int swap = 0 ; if ( bigend != int ( WeRBigEnd ( ) ) ) swap ++ ; for ( int i = 0 ; i < ND ; i ++ ) { LC . chars [ 0 ] = MLData [ 0 + 4 * i ] ; LC . chars [ 1 ] = MLData [ 1 + 4 * i ] ; LC . chars [ 2 ] = MLData [ 2 + 4 * i ] ; LC . chars [ 3 ] = MLData [ 3 + 4 * i ] ; if ( swap ) Swap ( LC . longval ) ; Sizes [ i ] = int ( LC . longval ) ; if ( Sizes [ i ] < 1 || Sizes [ i ] > MaxDim ) { if ( warn ) { MLDA5error ( 12 , 1 ) ; if ( warn > 1 ) MLDA5fatality ( 20 ) ; else MLDA5error ( 20 ) ; } } } return 1 ; }
These are the functions which will input a sub-element in MATLAB ".mat"
binary format, version 5.
These are the functions which will input a sub - element in MATLAB " . mat " binary format version 5 .
// Read sub-element // If this has problems, then // we must deal with them // appropriately now // Set number of dimensions // Delete dimensions array // Set new dimensions array // Read long integers