src/Matrix/h_matrix.cc
/* These functions perform both ASCII and Binary input/output operations on a
   Hermitian matrix.
 
    Function  Arguments                           Result
   ---------- ---------   -----------------------------------------------------
   print      ostream     Writes array elemnts in ASCII to output stream
   write      ofstream    Writes array elemnts in Binary to output file stream
   read       ifstream    Read in array from Binary input file stream
   readASC    istream     Read in array from an input stream
   ask          ----      Interactively requests Hermitian matrix from user
   
   The binary format of h_matrix has data only, not size information.  The size
   is taken care of in classes matrix/_matrix and should done prior to use of
   these functions.  The data ordering is Re(<i|hmx|j>, Im(<i|hmx|j> columns
   then rows (i.e. row by row.)  If the flag=0 then only the diagonals are
   output (GAMMA format) whereas a non-zero flag will force all elements
   (diagonals and zero off-diagonals) to be output.                          */
These functions perform both ASCII and Binary input/output operations on a
Hermitian matrix.

Function  Arguments                           Result

print      ostream     Writes array elemnts in ASCII to output stream
write      ofstream    Writes array elemnts in Binary to output file stream
read       ifstream    Read in array from Binary input file stream
readASC    istream     Read in array from an input stream
ask          ----      Interactively requests Hermitian matrix from user

The binary format of h_matrix has data only, not size information.  The size
is taken care of in classes matrix/_matrix and should done prior to use of
these functions.  The data ordering is Re(, Im( columns
then rows   If the flag=0 then only the diagonals are
output (GAMMA format) whereas a non-zero flag will force all elements
(diagonals and zero off-diagonals) to be output.
These functions perform both ASCII and Binary input / output operations on a Hermitian matrix . Function Arguments Result print ostream Writes array elemnts in ASCII to output stream write ofstream Writes array elemnts in Binary to output file stream read ifstream Read in array from Binary input file stream readASC istream Read in array from an input stream ask ---- Interactively requests Hermitian matrix from user The binary format of h_matrix has data only not size information . The size is taken care of in classes matrix / _matrix and should done prior to use of these functions . The data ordering is Re ( Im ( columns then rows If the flag = 0 then only the diagonals are output ( GAMMA format ) whereas a non - zero flag will force all elements ( diagonals and zero off - diagonals ) to be output .
std::vector<std::string> h_matrix::printStrings(const MxPrint& PFlgs) const
  {
  std::vector<std::string> PStrings;		
  int ptype = 0;                                
  if(PFlgs.MxRIPrnt)                            
    {                                           
    if(is_real())           ptype = 1;          
    else if(is_imaginary()) ptype = 2;          
    }
  int    elen;                                  
  switch(ptype)                                 
    {                                           
    default:                                    
    case 0: elen = complex::zlength(); break;   
    case 1:
    case 2: elen = complex::dlength(); break;
    }
  std::string ezer("");				
  if(!PFlgs.MxAll)				
    ezer = std::string(elen, ' ');		
  std::string pline;
  std::string efmt = complex::dformat();        
  int i,j, pos;
  for(i=0,pos=0; i<rows_; i++ )                 
    {
    pline = std::string("");			
    if(!PFlgs.MxAll)				 elems
      for(j=0; j<i; j++) pline += ezer;		
    else if(ptype==1)                           
      for(j=0; j<i; j++) 			
        pline += MxModform(efmt.c_str(),Re(get(i,j)));
    else if(ptype==2)                           
      for(j=0; j<i; j++) 			
        pline += MxModform(efmt.c_str(),Im(get(i,j)));
    else                                        
      for(j=0; j<i; j++)			
        pline +=  get(i,j).printString();
    if(ptype==1)                                
      for(j=i; j<cols_; j++, pos++) 		
        pline += MxModform(efmt.c_str(),Re(data[pos]));
    else if(ptype==2)                           
      for(j=i; j<cols_; j++, pos++) 		
        pline += MxModform(efmt.c_str(),Im(data[pos]));
    else 					
      for(j=i; j<cols_; j++, pos++) 		
        pline +=  data[pos].printString();
    PStrings.push_back(pline);
    }
  return PStrings;
  }
std :: vector < std :: string > h_matrix :: printStrings ( const MxPrint & PFlgs ) const { std :: vector < std :: string > PStrings ; int ptype = 0 ; if ( PFlgs . MxRIPrnt ) { if ( is_real ( ) ) ptype = 1 ; else if ( is_imaginary ( ) ) ptype = 2 ; } int elen ; switch ( ptype ) { default : case 0 : elen = complex :: zlength ( ) ; break ; case 1 : case 2 : elen = complex :: dlength ( ) ; break ; } std :: string ezer ( " " ) ; if ( ! PFlgs . MxAll ) ezer = std :: string ( elen , ' ' ) ; std :: string pline ; std :: string efmt = complex :: dformat ( ) ; int i , j , pos ; for ( i = 0 , pos = 0 ; i < rows_ ; i ++ ) { pline = std :: string ( " " ) ; if ( ! PFlgs . MxAll ) for ( j = 0 ; j < i ; j ++ ) pline += ezer ; else if ( ptype == 1 ) for ( j = 0 ; j < i ; j ++ ) pline += MxModform ( efmt . c_str ( ) , Re ( get ( i , j ) ) ) ; else if ( ptype == 2 ) for ( j = 0 ; j < i ; j ++ ) pline += MxModform ( efmt . c_str ( ) , Im ( get ( i , j ) ) ) ; else for ( j = 0 ; j < i ; j ++ ) pline += get ( i , j ) . printString ( ) ; if ( ptype == 1 ) for ( j = i ; j < cols_ ; j ++ , pos ++ ) pline += MxModform ( efmt . c_str ( ) , Re ( data [ pos ] ) ) ; else if ( ptype == 2 ) for ( j = i ; j < cols_ ; j ++ , pos ++ ) pline += MxModform ( efmt . c_str ( ) , Im ( data [ pos ] ) ) ; else for ( j = i ; j < cols_ ; j ++ , pos ++ ) pline += data [ pos ] . printString ( ) ; PStrings . push_back ( pline ) ; } return PStrings ; }
These functions perform both ASCII and Binary input/output operations on a
Hermitian matrix.
These functions perform both ASCII and Binary input / output operations on a Hermitian matrix .
// What to return // Complex elements output // If we want just reals // or just imags, check // Real elements output // Imag elements output // A single element length // Get the element length // from class complex. This  // depends on the output // format // String for "hidden" element // If not printing all // elems, this is invisible // Real/Imag element format // Loop array rows // Empty row string // If not printing all elems // put blanks left of diag // Output left of diag // as real elements // Output left of diag // as imaginary elements // Output left of diag // as complex elements // Output rest as // real elements // Output rest as // imaginary elements // Output rest as // complex elements