src/Matrix/col_vector.cc
/* The column vector is placed into an array of strings, each string having
   equal length. If the number of vector elements exceeds the number of rows
   we allow for simplistic printing, then we begin an new column of vector
   elements. The number of rows before additonal columns are begun is set
   by PFlgs.VxRows. The max # of columns per line is set by PFlgs.VxCols.    */
The column vector is placed into an array of strings, each string having
equal length. If the number of vector elements exceeds the number of rows
we allow for simplistic printing, then we begin an new column of vector
elements. The number of rows before additonal columns are begun is set
by PFlgs.VxRows. The max # of columns per line is set by PFlgs.VxCols.
The column vector is placed into an array of strings each string having equal length . If the number of vector elements exceeds the number of rows we allow for simplistic printing then we begin an new column of vector elements . The number of rows before additonal columns are begun is set by PFlgs . VxRows . The max # of columns per line is set by PFlgs . VxCols .
std::vector<std::string> col_vector::printStrings(const MxPrint& PFlgs) const
  {
  std::vector<std::string> PStrings;
  int npts = size();
  if(!npts) return 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 = std::string(elen, ' ');	
  std::string efmt = complex::dformat();	
  std::string vline;				
  int nrow = PFlgs.VxRows;			
  if(npts <= nrow)				
    {						
    for(int pos=0; pos<npts; pos++ )
      {
      if(ptype==1)					
        vline = MxModform(efmt.c_str(),getRe(pos)); 	
      else if(ptype==2)					
        vline = MxModform(efmt.c_str(),getIm(pos)); 	
      else  vline = get(pos).printString();         	complex   
      PStrings.push_back(vline);
      }
    return PStrings;
    }
  int ncol = PFlgs.VxCols;			
  if(ptype) ncol *=2;				
  int row=0, col=0;				
  for(int pos=0; pos<npts; pos++ )
    {
    if(col == 0) vline = "";
    if(ptype==1)					
      vline += MxModform(efmt.c_str(),getRe(pos)); 	
    else if(ptype==2)					
      vline += MxModform(efmt.c_str(),getIm(pos)); 	
    else  vline += get(pos).printString();         	complex
    col++;
    if(col < ncol)  vline += " ";
    else          { PStrings.push_back(vline); col=0; row++; }
    }
  if(col)					
    {						
    if(row)					
      while(col < ncol)				
       { vline += ezer + " "; col++; }
    PStrings.push_back(vline);			
    }
  return PStrings;
  }
std :: vector < std :: string > col_vector :: printStrings ( const MxPrint & PFlgs ) const { std :: vector < std :: string > PStrings ; int npts = size ( ) ; if ( ! npts ) return 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 = std :: string ( elen , ' ' ) ; std :: string efmt = complex :: dformat ( ) ; std :: string vline ; int nrow = PFlgs . VxRows ; if ( npts <= nrow ) { for ( int pos = 0 ; pos < npts ; pos ++ ) { if ( ptype == 1 ) vline = MxModform ( efmt . c_str ( ) , getRe ( pos ) ) ; else if ( ptype == 2 ) vline = MxModform ( efmt . c_str ( ) , getIm ( pos ) ) ; else vline = get ( pos ) . printString ( ) ; PStrings . push_back ( vline ) ; } return PStrings ; } int ncol = PFlgs . VxCols ; if ( ptype ) ncol *= 2 ; int row = 0 , col = 0 ; for ( int pos = 0 ; pos < npts ; pos ++ ) { if ( col == 0 ) vline = " " ; if ( ptype == 1 ) vline += MxModform ( efmt . c_str ( ) , getRe ( pos ) ) ; else if ( ptype == 2 ) vline += MxModform ( efmt . c_str ( ) , getIm ( pos ) ) ; else vline += get ( pos ) . printString ( ) ; col ++ ; if ( col < ncol ) vline += " " ; else { PStrings . push_back ( vline ) ; col = 0 ; row ++ ; } } if ( col ) { if ( row ) while ( col < ncol ) { vline += ezer + " " ; col ++ ; } PStrings . push_back ( vline ) ; } return PStrings ; }
The column vector is placed into an array of strings, each string having
equal length.
The column vector is placed into an array of strings each string having equal length .
// Assume complex elements // See if we want just reals // or just imags printed //   Real elements output //   Imag elements output // A single element length // Get the element length from // class complex. Depend on  // complex class settings //   Element length if complex //   Element length if real //   Element length if imaginary // Invisible element // Real/Imag element format // String for printed line //                    Print If Single Element Per Row // Rows in output // If less points than rows // no need for multiple columns // Output as  // a real element // Output as // an imaginary element // Output as complex    //               Print If Mulitple Elements Per Row // Columns in output // Twice as many if real/imag // Column index // Output as  // a real element // Output as // an imaginary element // Output as complex // If we have not output all // columns yet //    Fill with blanks if //    previous rows output //    Output last row