src/Matrix/n_matrix.cc
/* These functions perform both ASCII and Binary input/output operations on a
   complex matrix.

    Function  Arguments                           Result
   ---------- ---------   -----------------------------------------------------
   print      ostream     Writes array elements in ASCII to output stream
   picture    ostream     Writes array elements pictorically to output stream
   write      ofstream    Writes array elements 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 complex matrix from user 
    
   The binary format of n_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.)                                              */
These functions perform both ASCII and Binary input/output operations on a
complex matrix.

Function  Arguments                           Result

print      ostream     Writes array elements in ASCII to output stream
picture    ostream     Writes array elements pictorically to output stream
write      ofstream    Writes array elements 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 complex matrix from user

The binary format of n_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
These functions perform both ASCII and Binary input / output operations on a complex matrix . Function Arguments Result print ostream Writes array elements in ASCII to output stream picture ostream Writes array elements pictorically to output stream write ofstream Writes array elements 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 complex matrix from user The binary format of n_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
std::vector<std::string> n_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 pline;
  std::string efmt = complex::dformat();        
  int i,j,pos;
  for(i=0,pos=0; i<rows_; i++ )                 
    {
    pline = std::string("");
    if(ptype==1)				
      for(j=0; j<cols_; j++) 
        pline += MxModform(efmt.c_str(),Re(data[pos++]));
    else if(ptype==2)                           
      for(j=0; j<cols_; j++) 
        pline += MxModform(efmt.c_str(),Im(data[pos++]));
    else                                        
      for(j=0; j<cols_; j++)
        pline += (data[pos++]).printString();
    PStrings.push_back(pline);				
    }
  return PStrings;
  }
std :: vector < std :: string > n_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 pline ; std :: string efmt = complex :: dformat ( ) ; int i , j , pos ; for ( i = 0 , pos = 0 ; i < rows_ ; i ++ ) { pline = std :: string ( " " ) ; if ( ptype == 1 ) for ( j = 0 ; j < cols_ ; j ++ ) pline += MxModform ( efmt . c_str ( ) , Re ( data [ pos ++ ] ) ) ; else if ( ptype == 2 ) for ( j = 0 ; j < cols_ ; j ++ ) pline += MxModform ( efmt . c_str ( ) , Im ( data [ pos ++ ] ) ) ; else for ( j = 0 ; j < cols_ ; j ++ ) pline += ( data [ pos ++ ] ) . printString ( ) ; PStrings . push_back ( pline ) ; } return PStrings ; }
These functions perform both ASCII and Binary input/output operations on a
complex matrix.
These functions perform both ASCII and Binary input / output operations on a complex matrix .
// 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 // Real/Imag element format // Loop array rows // Output real elems only // Output imag elems only // Output complex elems // Go to next line