当前位置: 首页>>代码示例>>C++>>正文


C++ ostream::setf方法代码示例

本文整理汇总了C++中std::ostream::setf方法的典型用法代码示例。如果您正苦于以下问题:C++ ostream::setf方法的具体用法?C++ ostream::setf怎么用?C++ ostream::setf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::ostream的用法示例。


在下文中一共展示了ostream::setf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: stream_state

inline
void
arma_ostream::print(std::ostream& o, const SpMat<eT>& m, const bool modify)
  {
  arma_extra_debug_sigprint();
  
  const arma_ostream_state stream_state(o);
  
  o.unsetf(ios::showbase);
  o.unsetf(ios::uppercase);
  o.unsetf(ios::showpos);
  o.unsetf(ios::scientific);
  o.setf(ios::right);
  o.setf(ios::fixed);
  o.precision(2);
  
  const uword m_n_nonzero = m.n_nonzero;
  
  o << "[matrix size: " << m.n_rows << 'x' << m.n_cols << "; n_nonzero: " << m_n_nonzero
    << "; density: " << ((m.n_elem > 0) ? (double(m_n_nonzero) / double(m.n_elem) * double(100)) : double(0))
    << "%]\n\n";
  
  if(modify == false) { stream_state.restore(o); }
  
  if(m_n_nonzero > 0)
    {
    const std::streamsize cell_width = modify ? modify_stream<eT>(o, m.begin(), m_n_nonzero) : o.width();
    
    typename SpMat<eT>::const_iterator begin = m.begin();
    
    while(begin != m.end())
      {
      const uword row = begin.row();
      
      // TODO: change the maximum number of spaces before and after each location to be dependent on n_rows and n_cols
      
           if(row < 10)      { o << "     "; }
      else if(row < 100)     { o << "    ";  }
      else if(row < 1000)    { o << "   ";   }
      else if(row < 10000)   { o << "  ";    }
      else if(row < 100000)  { o << ' ';     }
      
      const uword col = begin.col();
      
      o << '(' << row << ", " << col << ") ";
      
           if(col < 10)      { o << "     "; }
      else if(col < 100)     { o << "    ";  }
      else if(col < 1000)    { o << "   ";   }
      else if(col < 10000)   { o << "  ";    }
      else if(col < 100000)  { o << ' ';     }
      
      if(cell_width > 0) { o.width(cell_width); }
        
      arma_ostream::print_elem(o, eT(*begin), modify);
      o << '\n';
      
      ++begin;
      }
    
    o << '\n';
    }
  
  o.flush();
  stream_state.restore(o);
  }
开发者ID:DASLaboratories,项目名称:Armadillo,代码行数:66,代码来源:arma_ostream_meat.hpp

示例2: eT

inline
std::streamsize
arma_ostream::modify_stream(std::ostream& o, typename SpMat<eT>::const_iterator begin, const uword n_elem, const typename arma_not_cx<eT>::result* junk)
  {
  arma_extra_debug_sigprint();
  arma_ignore(junk);

  o.unsetf(ios::showbase);
  o.unsetf(ios::uppercase);
  o.unsetf(ios::showpos);

  o.fill(' ');

  std::streamsize cell_width;

  bool use_layout_B  = false;
  bool use_layout_C  = false;

  for(typename SpMat<eT>::const_iterator it = begin; it.pos() < n_elem; ++it)
    {
    const eT val = *it;

    if(
      val >= eT(+100) ||
      ( (is_signed<eT>::value == true) && (val <= eT(-100)) ) ||
      ( (is_non_integral<eT>::value == true) && (val > eT(0)) && (val <= eT(+1e-4)) ) ||
      ( (is_non_integral<eT>::value == true) && (is_signed<eT>::value == true) && (val < eT(0)) && (val >= eT(-1e-4)) )
      )
      {
      use_layout_C = true;
      break;
      }

    if(
      (val >= eT(+10)) || ( (is_signed<eT>::value == true) && (val <= eT(-10)) )
      )
      {
      use_layout_B = true;
      }
    }

  if(use_layout_C == true)
    {
    o.setf(ios::scientific);
    o.setf(ios::right);
    o.unsetf(ios::fixed);
    o.precision(4);
    cell_width = 13;
    }
  else
  if(use_layout_B == true)
    {
    o.unsetf(ios::scientific);
    o.setf(ios::right);
    o.setf(ios::fixed);
    o.precision(4);
    cell_width = 10;
    }
  else
    {
    o.unsetf(ios::scientific);
    o.setf(ios::right);
    o.setf(ios::fixed);
    o.precision(4);
    cell_width = 9;
    }
  
  return cell_width;
  }
开发者ID:DASLaboratories,项目名称:Armadillo,代码行数:69,代码来源:arma_ostream_meat.hpp

示例3: fix

void fix(std::ostream& stream) 
{
    stream.setf(std::ios::fixed);
    stream.precision(7);
}
开发者ID:Applied-Language-Solutions,项目名称:mosesdecoder,代码行数:5,代码来源:extract-lex-main.cpp

示例4: FixPrecision

void IOWrapper::FixPrecision(std::ostream &stream, size_t size)
{
  stream.setf(std::ios::fixed);
  stream.precision(size);
}
开发者ID:obo,项目名称:Moses-Extensions-at-UFAL,代码行数:5,代码来源:IOWrapper.cpp

示例5: format_impl


//.........这里部分代码省略.........
			if(need_comma) ostr << ",";
			need_comma = true;
			format_count += format_impl(*iter, ostr, options, level + 1);
		}
		ostr << "]";
		break;
	}

	case LLSD::TypeUndefined:
		ostr << "!";
		break;

	case LLSD::TypeBoolean:
		if(mBoolAlpha ||
#if( LL_WINDOWS || __GNUC__ > 2)
		   (ostr.flags() & std::ios::boolalpha)
#else
		   (ostr.flags() & 0x0100)
#endif
			)
		{
			ostr << (data.asBoolean()
					 ? NOTATION_TRUE_SERIAL : NOTATION_FALSE_SERIAL);
		}
		else
		{
			ostr << (data.asBoolean() ? 1 : 0);
		}
		break;

	case LLSD::TypeInteger:
		ostr << "i" << data.asInteger();
		break;

	case LLSD::TypeReal:
		ostr << "r";
		if(mRealFormat.empty())
		{
			ostr << data.asReal();
		}
		else
		{
			formatReal(data.asReal(), ostr);
		}
		break;

	case LLSD::TypeUUID:
		ostr << "u" << data.asUUID();
		break;

	case LLSD::TypeString:
		ostr << '\'';
		serialize_string(data.asStringRef(), ostr);
		ostr << '\'';
		break;

	case LLSD::TypeDate:
		ostr << "d\"" << data.asDate() << "\"";
		break;

	case LLSD::TypeURI:
		ostr << "l\"";
		serialize_string(data.asString(), ostr);
		ostr << "\"";
		break;

	case LLSD::TypeBinary:
	{
		// *FIX: memory inefficient.
		const std::vector<U8>& buffer = data.asBinary();
		ostr << "b(" << buffer.size() << ")\"";
		if(buffer.size())
		{
			if (options & LLSDFormatter::OPTIONS_PRETTY_BINARY)
			{
				std::ios_base::fmtflags old_flags = ostr.flags();
				ostr.setf( std::ios::hex, std::ios::basefield );
				ostr << "0x";
				for (size_t i = 0; i < buffer.size(); i++)
				{
					ostr << (int) buffer[i];
				}
				ostr.flags(old_flags);
			}
			else
			{
				ostr.write((const char*)&buffer[0], buffer.size());
			}
		}
		ostr << "\"";
		break;
	}

	default:
		// *NOTE: This should never happen.
		ostr << "!";
		break;
	}
	return format_count;
}
开发者ID:AlericInglewood,项目名称:SingularityViewer,代码行数:101,代码来源:llsdserialize.cpp

示例6: printSummary

/**
 * Print the summary of the move.
 *
 * The summary just contains the current value of the tuning parameter.
 * It is printed to the stream that it passed in.
 *
 * \param[in]     o     The stream to which we print the summary.
 */
void MetropolisHastingsMove::printSummary(std::ostream &o) const 
{
    std::streamsize previousPrecision = o.precision();
    std::ios_base::fmtflags previousFlags = o.flags();
    
    o << std::fixed;
    o << std::setprecision(4);
    
    // print the name
    const std::string &n = getMoveName();
    size_t spaces = 40 - (n.length() > 40 ? 40 : n.length());
    o << n;
    for (size_t i = 0; i < spaces; ++i) {
        o << " ";
    }
    o << " ";
    
    // print the DagNode name
    const std::string &dn_name = (*nodes.begin())->getName();
    spaces = 20 - (dn_name.length() > 20 ? 20 : dn_name.length());
    o << dn_name;
    for (size_t i = 0; i < spaces; ++i) {
        o << " ";
    }
    o << " ";
    
    // print the weight
    int w_length = 4 - (int)log10(weight);
    for (int i = 0; i < w_length; ++i) {
        o << " ";
    }
    o << weight;
    o << " ";
    
    // print the number of tries
    int t_length = 9 - (int)log10(numTried);
    for (int i = 0; i < t_length; ++i) {
        o << " ";
    }
    o << numTried;
    o << " ";
    
    // print the number of accepted
    int a_length = 9;
    if (numAccepted > 0) a_length -= (int)log10(numAccepted);
    
    for (int i = 0; i < a_length; ++i) {
        o << " ";
    }
    o << numAccepted;
    o << " ";
    
    // print the acceptance ratio
    double ratio = numAccepted / (double)numTried;
    if (numTried == 0) ratio = 0;
    int r_length = 5;
    
    for (int i = 0; i < r_length; ++i) {
        o << " ";
    }
    o << ratio;
    o << " ";
    
    proposal->printParameterSummary( o );
    
    o << std::endl;
    
    o.setf(previousFlags);
    o.precision(previousPrecision);
    
    
}
开发者ID:vivianaayus,项目名称:revbayes,代码行数:80,代码来源:MetropolisHastingsMove.cpp

示例7: write

void LocalNetworkXML::write(std::ostream& out) const
{ 
  out << "<?xml version=\"1.0\" ?>\n"
      << "<!DOCTYPE gama-local-adjustment SYSTEM \"gama-local-adjustment.dtd\">\n"
      << "\n<gama-local-adjustment version=\"" << VERSION << "\">\n";

  out << "\n<description>" << description << "</description>\n";
  
  {
    {
      using GNU_gama::GNU_gama_version;
      using GNU_gama::GNU_gama_compiler;

      out << "\n<network-general-parameters\n";
    
      out << "   gama-local-version=\""   << GNU_gama_version    << "\"\n";
      out << "   gama-local-algorithm=\"" << netinfo->algorithm()<< "\"\n";
      out << "   gama-local-compiler=\""  << GNU_gama_compiler   << "\"\n";

      out.setf(ios_base::fixed, ios_base::floatfield);
      out.precision(7);
      out << "   epoch=\""<< netinfo->epoch << "\"\n";

      out << "   axes-xy=\""; 
      switch (netinfo->PD.local_coordinate_system)
        {
        case   1: out << "en"; break;
        case   2: out << "nw"; break;
        case   4: out << "se"; break;
        case   8: out << "ws"; break;
        case  16: out << "ne"; break;
        case  32: out << "sw"; break;
        case  64: out << "es"; break;
        case 128: out << "wn"; break;
        default : break;
        }
      out << "\"\n";

      out << "   angles=\"" 
          << (netinfo->PD.right_handed_angles ?
                                "right-handed" : "left-handed") 
          << "\"\n";

      out << "/>\n";
    }

    out.setf(ios_base::scientific, ios_base::floatfield);
    out.precision(7);

    out << "\n<network-processing-summary>\n";

    coordinates_summary(out);
    observations_summary(out);
    equations_summary(out);
    std_dev_summary(out);
    
    out << "\n</network-processing-summary>\n";

   
  }

  coordinates(out);  
  observations(out);
  
  out << "\n</gama-local-adjustment>\n";
}
开发者ID:gizela,项目名称:gizela,代码行数:66,代码来源:localnetwork.cpp

示例8: Report

/**
 * @method Report [void:public]
 * @param out [ostream&] the output stream to which to write the report
 *
 * This function outputs a brief report of the contents of this taxa block.
 * Overrides the abstract virtual function in the base class.
 */
void DistancesBlock::Report( std::ostream& out )
{
   int ntaxTotal = ntax;
   if( ntaxTotal == 0 )
      ntaxTotal = taxa.GetNumTaxonLabels();

	out << endl;
	out << id << " block contains ";
	if( ntaxTotal == 0 ) {
		out << "no taxa" << endl;
	}
	else if( ntaxTotal == 1 )
		out << "one taxon" << endl;
	else
		out << ntaxTotal << " taxa" << endl;

   if( IsLowerTriangular() )
      out << "  Matrix is lower-triangular" << endl;
   else if( IsUpperTriangular() )
      out << "  Matrix is upper-triangular" << endl;
   else
      out << "  Matrix is rectangular" << endl;

   if( IsInterleave() )
      out << "  Matrix is interleaved" << endl;
   else 
      out << "  Matrix is non-interleaved" << endl;

   if( IsLabels() )
      out << "  Taxon labels provided" << endl;
   else
      out << "  No taxon labels provided" << endl;

   if( IsDiagonal() )
      out << "  Diagonal elements specified" << endl;
   else 
      out << "  Diagonal elements not specified" << endl;

   out << "  Missing data symbol is " << missing << endl;

	if( ntax == 0 ) return;

   out.setf( ios::floatfield, ios::fixed );
   out.setf( ios::showpoint );
	for( int i = 0; i < ntax; i++ )
   {
      if( labels )
         out << setw(20) << taxa.GetTaxonLabel(i);
      else
         out << "\t\t";
      for( int j = 0; j < ntax; j++ )
      {
         if( triangle==upper && j < i ) {
            out << setw(12) << " ";
         }
         else if( triangle==lower && j > i )
            continue;
         else if( !diagonal && i == j ) {
            out << setw(12) << " ";
         }
         else if( IsMissing( i, j ) )
            out << setw(12) << missing;
         else
            out << setw(12) << setprecision(5) << GetDistance( i, j );
      }
      out << endl;
   }
}
开发者ID:bomeara,项目名称:omearatenure,代码行数:75,代码来源:distancesblock.cpp

示例9: coordinates

void LocalNetworkXML::coordinates(std::ostream& out) const
{
  const int y_sign = GaMaConsistent(netinfo->PD) ? +1 : -1;
  
  out << "\n<coordinates>\n";

  out.setf(ios_base::fixed, ios_base::floatfield);
  out.precision(6);
  
  const GaMaLib::Vec& X = netinfo->solve();
  std::vector<Index> ind(netinfo->sum_unknowns() + 1);
  Index dim = 0;
  
  
  out << "\n<fixed>\n";
    
  for (PointData::const_iterator
         i=netinfo->PD.begin(); i!=netinfo->PD.end(); ++i)
    {
      const LocalPoint& p = (*i).second;
      if (!p.active_xy() && !p.active_z()) continue;
      bool bxy = p.active_xy() && p.index_x() == 0;
      bool bz  = p.active_z () && p.index_z() == 0;
      if (!bxy && !bz) continue;
      out << "   <point> ";
      tagsp(out, "id", (*i).first);
      if (bxy)
        {
          const double x = (p.x()+X(p.index_x())/1000);
          const double y = (p.y()+X(p.index_y())/1000)*y_sign;
          tagsp(out, "x", x);
          tagsp(out, "y", y);
        }
      if (bz)
        {
          const double z = (p.z()+X(p.index_z())/1000);
          tagsp(out, "z", z);
        }
      out << "</point>\n";
    }
  
  out << "</fixed>\n";
  

  out << "\n<approximate>\n";
    
  for (PointData::const_iterator
         i=netinfo->PD.begin(); i!=netinfo->PD.end(); ++i)
    {
      const LocalPoint& p = (*i).second;
      if (!p.active_xy() && !p.active_z()) continue;
      bool bxy = p.active_xy() && p.index_x() != 0;
      bool bz  = p.active_z () && p.index_z() != 0;
      if (!bxy && !bz) continue;
      out << "   <point> ";
      tagsp(out, "id", (*i).first);
      if (bxy)
        {
          const char* cx = "x";
          const char* cy = "y";
          if (p.constrained_xy())
            {
              cx = "X";
              cy = "Y";
            }
          const double x = p.x();
          const double y = p.y()*y_sign;
          tagsp(out, cx, x);
          tagsp(out, cy, y);
        }
      if (bz)
        {
          const char* cz = "z";
          if (p.constrained_z())
            {
              cz = "Z";
            }
          const double z = p.z();
          tagsp(out, cz, z);
        }
      out << "</point>\n";
    }
  out << "</approximate>\n";
  
  
  out << "\n<!-- capital X,Y,Z denote constrained coordinates -->\n"
      << "<adjusted>\n";
    
  for (PointData::const_iterator
         i=netinfo->PD.begin(); i!=netinfo->PD.end(); ++i)
    {
      const LocalPoint& p = (*i).second;
      if (!p.active_xy() && !p.active_z()) continue;
      bool bxy = p.active_xy() && p.index_x() != 0;
      bool bz  = p.active_z () && p.index_z() != 0;
      if (!bxy && !bz) continue;
      out << "   <point> ";
      tagsp(out, "id", (*i).first);
      if (bxy)
        {
//.........这里部分代码省略.........
开发者ID:gizela,项目名称:gizela,代码行数:101,代码来源:localnetwork.cpp

示例10: observations

void LocalNetworkXML::observations(std::ostream& out) const
{
  out << "\n<observations>\n\n";

   using namespace std;
   // using namespace GaMaLib;

   const int      y_sign = GaMaConsistent(netinfo->PD) ? +1 : -1;
   const GaMaLib::Vec& v = netinfo->residuals();
   const int      pocmer = netinfo->sum_observations();
   const double   scale  = netinfo->gons() ? 1.0 : 0.324;
   const double   kki    = netinfo->conf_int_coef();

   PointID predcs = "";   // provious standpoint ID
   for (int i=1; i<=pocmer; i++)
     {
       Observation* pm = netinfo->ptr_obs(i);
       // bool isangle    = false;

       Angle* u = 0;
       bool xyz = false;
       const char* tag = 0;
       ostringstream ostr;
       ostr.setf(ios_base::fixed, ios_base::floatfield);

       const int linear  =  6;    // output precision 
       const int angular =  7;    // output precision 

       if (Distance* d = dynamic_cast<Distance*>(pm))
         {
           out << "<" << (tag="distance") << ">";
           ostr.precision(linear);
           double m = d->value();
           ostr << " <obs>" << m << "</obs>";
           m += v(i)/1000;
           ostr << " <adj>" << m << "</adj>";
         }
       else if (Direction* s = dynamic_cast<Direction*>(pm))
         {
           out << "<" << (tag="direction") << ">";
           ostr.precision(angular);
           double m = R2G*(s->value());
           ostr << " <obs>" << m << "</obs>";
           m += v(i)/10000;
           if (m < 0) m += 400;
           if (m >= 400) m -= 400;
           ostr << " <adj>" <<  m << "</adj>";
         }
       else if ( (u = dynamic_cast<Angle*>(pm)) )
         {
           out << "<" << (tag="angle") << ">";
           ostr.precision(angular);
           double m = R2G*(u->value());
           ostr << " <obs>" << m << "</obs>";
           m += v(i)/10000;
           if (m < 0) m += 400;
           if (m >= 400) m -= 400;
           ostr << "<adj>" << m << "</adj>";
         }
       else if (S_Distance* sd = dynamic_cast<S_Distance*>(pm))
         {
           out << "<" << (tag="slope-distance") << ">"; 
           ostr.precision(linear);
           double m = sd->value();
           ostr << " <obs>" << m << "</obs>";
           m += v(i)/1000;
           ostr << " <adj>" << m << "</adj>";
         }
       else if (Z_Angle* za = dynamic_cast<Z_Angle*>(pm))
         {
           out << "<" << (tag="zenith-angle") << ">";
           ostr.precision(angular);
           double m = R2G*(za->value());
           ostr << " <obs>" << m << "</obs>";
           m += v(i)/10000;
           ostr << "<adj>" << m << "</adj>";
         }
       else if (X* x = dynamic_cast<X*>(pm))
         {
           xyz = true;
           out << "<" << (tag="coordinate-x") << ">";
           ostr.precision(linear);
           double m = x->value();
           ostr << " <obs>" << m << "</obs>";
           m += v(i)/1000;
           ostr << "<adj>" << m << "</adj>";
         }
       else if (Y* y = dynamic_cast<Y*>(pm))
         {
           xyz = true;
           out << "<" << (tag="coordinate-y") << ">";
           ostr.precision(linear);
           double m = y->value();
           ostr << " <obs>" << y_sign*m << "</obs>";
           m += v(i)/1000;
           ostr << " <adj>" << y_sign*m << "</adj>";
         }
       else if (Z* z = dynamic_cast<Z*>(pm))
         {
           xyz = true;
//.........这里部分代码省略.........
开发者ID:gizela,项目名称:gizela,代码行数:101,代码来源:localnetwork.cpp

示例11: DumpTracker

bool ARCStringTracker::DumpTracker(std::ostream& os)
{
	bool bNoError = true;

	os.setf(std::ios::hex);

	os << "Dumping ARCStringTracker tracker..." << std::endl;

	//------------------------------------------------------------
	// 
	try
	{
		os << "\t" << "The tracker is (" << convHex((unsigned long)&m_whoami) << " -> " << convHex((unsigned long)m_whoami) << ")\"" << readStringCarefully(m_whoami) << "\"." << std::endl;
	}
	catch (std::string& e)
	{
		os << std::endl << "Dumping failed(" << e << ")." << std::endl;
		bNoError = false;
	}
	//------------------------------------------------------------


	//------------------------------------------------------------
	// 
	try
	{
		os << "\t" << "The last track string is (" << convHex((unsigned long)m_lastStringTrackerName) << ")\"" << readStringCarefully(m_lastStringTrackerName) << "\"." << std::endl;
	}
	catch (std::string& e)
	{
		os << std::endl << "Dumping failed(" << e << ")." << std::endl;
		bNoError = false;
	}
	//------------------------------------------------------------


	//------------------------------------------------------------
	// 
#	ifdef _USE_CLASS_METHOD_TRACK_INCLUDE_STACK_
	os << "Dumping stack tracker..." << std::endl;
	try
	{
		ARCStringTracker* pTracker = m_lastStringTracker;
		while (pTracker)
		{
			if (checkReadable(pTracker, sizeof(ARCStringTracker)))
				throw std::string("ARCStringTracker corrupted");

			os << "\t(" << convHex((unsigned long)pTracker) << " -> " << convHex((unsigned long)pTracker->m_pTrackString) << ")" << readStringCarefully(pTracker->m_pTrackString) << std::endl;
			pTracker = pTracker->m_preStringTracker;
		}
	}
	catch (std::string& e)
	{
		os << std::endl << "Dumping failed(" << e << ")." << std::endl;
		bNoError = false;
	}
	os << "Dumping stack tracker finished." << std::endl;

	os << "Dumping stack tracker stored image..." << std::endl;
	std::vector<TrackRecord>::iterator ite = m_recs.begin();
	std::vector<TrackRecord>::iterator iteEn = m_recs.end();
	for (;ite!=iteEn;ite++)
	{
		const TrackRecord& rec = *ite;
		os << "\t(" << convHex((unsigned long)rec.pTracker) << " -> " << convHex((unsigned long)rec.pString) << ")" << readStringCarefully(rec.pString) << std::endl;
	}
	os << "Dumping stack tracker stored image finished." << std::endl;

#	endif // _USE_CLASS_METHOD_TRACK_INCLUDE_STACK_
	//------------------------------------------------------------

	os << std::endl << "All dumps finished." << std::endl << std::endl;

	__time64_t now;
	_time64( &now );
	os << "UTC time:   " << asctime( _gmtime64( &now ) )    << std::endl;
	os << "Local time: " << asctime( _localtime64( &now ) ) << std::endl;
	return bNoError;
}
开发者ID:chenbk85,项目名称:tphProjects,代码行数:80,代码来源:ARCTracker.cpp

示例12: write_xml

void Point::write_xml(std::ostream& ostr)
{
  const double n = N();
  const double e = E();
  const double u = U();

  X_.set_correction(x_transform(n, e, u));
  Y_.set_correction(y_transform(n, e, u));
  Z_.set_correction(z_transform(n, e, u));

  ostr << "\n<point> ";
  ostr << "<id> " << name << " </id>\n\n";

  ostr.setf(std::ios_base::fixed, std::ios_base::floatfield);
  ostr.precision(3);

  ostr << "        ";
  if (N.fixed())
    ostr << "<n-fixed/>  ";
  else if (N.constr())
    ostr << "<n-constr/> ";
  else if (N.free())
    ostr << "<n-free/>   ";
  else
    ostr << "<n-unused/> ";
  if (N.index())
    {
      ostr << "<dn>"  << setw(8) << N()*1000  << " </dn> "
           << "<ind>" << N.index() << "</ind> ";
    }
  ostr << "\n";

  ostr << "        ";
  if (E.fixed())
    ostr << "<e-fixed/>  ";
  else if (E.constr())
    ostr << "<e-constr/> ";
  else if (E.free())
    ostr << "<e-free/>   ";
  else
    ostr << "<e-unused/> ";
  if (E.index())
    {
      ostr << "<de>"  << setw(8) << E()*1000  << " </de> "
           << "<ind>" << E.index() << "</ind> ";
    }
  ostr << "\n";

  ostr << "        ";
  if (U.fixed())
    ostr << "<u-fixed/>  ";
  else if (U.constr())
    ostr << "<u-constr/> ";
  else if (U.free())
    ostr << "<u-free/>   ";
  else
    ostr << "<unused/> ";
  if (U.index())
    {
      ostr << "<du>"  << setw(8) << U()*1000  << " </du> "
           << "<ind>" << U.index() << "</ind> ";
    }
  ostr << "\n";

  if (!fixed_position())
    {
      set_cov_neu();

      ostr.setf(std::ios_base::scientific, std::ios_base::floatfield);
      ostr.precision(7);
      ostr << "\n";
      ostr << "        ";
      ostr << "<cnn> " << cnn << " </cnn> ";
      ostr << "<cne> " << setw(14) << cne << " </cne> ";
      ostr << "\n                                   ";
      ostr << "<cnu> " << setw(14) << cnu << " </cnu>\n";
      ostr << "        "; 
      ostr << "<cee> " << cee << " </cee> ";
      ostr << "<ceu> " << setw(14) << ceu << " </ceu>\n";
      ostr << "        "; 
      ostr << "<cuu> " << cuu << " </cuu>\n";
    }

  if (has_position())
    {
      ostr.setf(std::ios_base::fixed, std::ios_base::floatfield);
      ostr.precision(5);
      ostr << "\n";
      ostr << "        <x-given     >";
      ostr << setw(19) << X.init_value();
      ostr << " </x-given>\n";
      if (!fixed_position())
        {
          ostr << "        <x-correction>";
          ostr << setw(19) << X.correction();
          ostr << " </x-correction>\n";
          ostr << "        <x-adjusted  >";
          ostr << setw(19) << X();
          ostr << " </x-adjusted>\n";
          ostr << "\n";
//.........这里部分代码省略.........
开发者ID:gizela,项目名称:gizela,代码行数:101,代码来源:g3_point.cpp

示例13: writeFullGraphToTextStream

void CommGraphWriter::writeFullGraphToTextStream(
   size_t record_number,
   std::ostream& os) const
{
   /*
    * Gather graph data on d_root_rank and write out.
    */
   TBOX_ASSERT(record_number < d_records.size());

   const Record& record = d_records[record_number];

   MessageStream ostr;

   for (size_t inodev = 0; inodev < record.d_node_values.size(); ++inodev) {
      const NodeValue& nodev = record.d_node_values[inodev];
      ostr << nodev.d_value;
   }
   for (size_t iedge = 0; iedge < record.d_edges.size(); ++iedge) {
      const Edge& edge = record.d_edges[iedge];
      ostr << edge.d_value << edge.d_dir << edge.d_other_node;
   }

   std::vector<char> tmpbuf(record.d_mpi.getRank() == d_root_rank ?
                            ostr.getCurrentSize() * record.d_mpi.getSize() : 0);

   if (ostr.getCurrentSize() > 0) {
      record.d_mpi.Gather(
         (void *)ostr.getBufferStart(),
         int(ostr.getCurrentSize()),
         MPI_CHAR,
         (record.d_mpi.getRank() == d_root_rank ? &tmpbuf[0] : 0),
         int(record.d_mpi.getRank() == d_root_rank ? ostr.getCurrentSize() : 0),
         MPI_CHAR,
         d_root_rank);
   }

   os.setf(std::ios_base::fmtflags(0), std::ios_base::floatfield);
   os.precision(8);

   std::vector<NodeValue> max_nodev(record.d_node_values.size());
   std::vector<Edge> max_edge(record.d_edges.size());

   if (record.d_mpi.getRank() == d_root_rank) {

      os << "\nCommGraphWriter begin record number " << record_number << '\n';
      os << "# proc" << '\t' << "dir" << '\t' << "remote" << '\t' << "value" << '\t' << "label\n";

      if (!tmpbuf.empty()) {
         MessageStream istr(tmpbuf.size(),
                                  MessageStream::Read,
                                  &tmpbuf[0],
                                  false);

         for (int src_rank = 0; src_rank < record.d_mpi.getSize(); ++src_rank) {

            NodeValue tmpnodev;
            for (size_t inodev = 0; inodev < record.d_node_values.size(); ++inodev) {
               istr >> tmpnodev.d_value;
               os << src_rank
                  << '\t' << tmpnodev.d_value
                  << '\t' << record.d_node_values[inodev].d_label
                  << '\n';
               if (max_nodev[inodev].d_value < tmpnodev.d_value) {
                  max_nodev[inodev] = tmpnodev;
               }
            }

            Edge tmpedge;
            for (size_t iedge = 0; iedge < record.d_edges.size(); ++iedge) {
               istr >> tmpedge.d_value >> tmpedge.d_dir >> tmpedge.d_other_node;
               os << src_rank
                  << '\t' << (tmpedge.d_dir == FROM ? "<-" : "->")
                  << '\t' << tmpedge.d_other_node
                  << '\t' << tmpedge.d_value
                  << '\t' << record.d_edges[iedge].d_label
                  << '\n';
               if (max_edge[iedge].d_value < tmpedge.d_value) {
                  max_edge[iedge] = tmpedge;
               }
            }

         }
      }
开发者ID:00liujj,项目名称:SAMRAI,代码行数:83,代码来源:CommGraphWriter.C

示例14: Write

 void LocalFileFormat::Write(const Baker & baker,
                             const std::string & formatName,
                             std::ostream & ostream) const
 {
     
     static const int DEFAULT_CUBE_SIZE = 32;
     
     if(formatName != "iridas_cube")
     {
         std::ostringstream os;
         os << "Unknown cube format name, '";
         os << formatName << "'.";
         throw Exception(os.str().c_str());
     }
     
     ConstConfigRcPtr config = baker.getConfig();
     
     int cubeSize = baker.getCubeSize();
     if(cubeSize==-1) cubeSize = DEFAULT_CUBE_SIZE;
     cubeSize = std::max(2, cubeSize); // smallest cube is 2x2x2
     
     std::vector<float> cubeData;
     cubeData.resize(cubeSize*cubeSize*cubeSize*3);
     GenerateIdentityLut3D(&cubeData[0], cubeSize, 3, LUT3DORDER_FAST_RED);
     PackedImageDesc cubeImg(&cubeData[0], cubeSize*cubeSize*cubeSize, 1, 3);
     
     // Apply our conversion from the input space to the output space.
     ConstProcessorRcPtr inputToTarget;
     std::string looks = baker.getLooks();
     if(!looks.empty())
     {
         LookTransformRcPtr transform = LookTransform::Create();
         transform->setLooks(looks.c_str());
         transform->setSrc(baker.getInputSpace());
         transform->setDst(baker.getTargetSpace());
         inputToTarget = config->getProcessor(transform, TRANSFORM_DIR_FORWARD);
     }
     else
     {
         inputToTarget = config->getProcessor(baker.getInputSpace(), baker.getTargetSpace());
     }
     inputToTarget->apply(cubeImg);
     
     if(baker.getMetadata() != NULL)
     {
         std::string metadata = baker.getMetadata();
         std::vector<std::string> metadatavec;
         pystring::split(pystring::strip(metadata), metadatavec, "\n");
         if(metadatavec.size() > 0)
         {
             for(size_t i = 0; i < metadatavec.size(); ++i)
             {
                 ostream << "# " << metadatavec[i] << "\n";
             }
             ostream << "\n";
         }
     }
     ostream << "LUT_3D_SIZE " << cubeSize << "\n";
     if(cubeSize < 2)
     {
         throw Exception("Internal cube size exception");
     }
     
     // Set to a fixed 6 decimal precision
     ostream.setf(std::ios::fixed, std::ios::floatfield);
     ostream.precision(6);
     for(int i=0; i<cubeSize*cubeSize*cubeSize; ++i)
     {
         ostream << cubeData[3*i+0] << " "
                 << cubeData[3*i+1] << " "
                 << cubeData[3*i+2] << "\n";
     }
 }
开发者ID:JGoldstone,项目名称:OpenColorIO,代码行数:73,代码来源:FileFormatIridasCube.cpp

示例15: printMessage


//.........这里部分代码省略.........

   const google::protobuf::Message& root = *msg;
   std::string msgName = descriptor->name();

   int fieldCount = descriptor->field_count();

   const google::protobuf::FieldDescriptor* fieldDescriptor = nullptr;

   std::string msgDivider = ";   ";
   std::string fieldDivider = ", ";

   bool lastField = false;

   if (fieldCount > 0) {
      for (int i = 0; i < fieldCount; i++) {
         if ((i+1) == fieldCount) lastField = true;

         // Get field descriptor (includes messages)
         fieldDescriptor = descriptor->field(i);

         // what type is this field?
         google::protobuf::FieldDescriptor::CppType cppType = fieldDescriptor->cpp_type();

         if (cppType == google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE) {

            // do the same again for this message, etc.
            const google::protobuf::Message& sub_message = reflection->GetMessage(root, fieldDescriptor);
            printMessage(soutFields, soutVals, &sub_message);
         }
         else {
            // not a message: Print the field
            if (reflection->HasField(root, fieldDescriptor)) {
               soutFields <<  std::left << std::setw(12) << fieldDescriptor->name(); // Field name

               // get the value
               switch (cppType) {
                  case google::protobuf::FieldDescriptor::CPPTYPE_STRING: {
                     soutVals <<  std::left << std::setw(12)<<  reflection->GetString(root, fieldDescriptor);
                     break;
                  }
                  case google::protobuf::FieldDescriptor::CPPTYPE_INT32: {
                     soutVals <<  std::left << std::setw(12)<<  reflection->GetInt32(root, fieldDescriptor);
                     break;
                  }
                  case google::protobuf::FieldDescriptor::CPPTYPE_INT64: {
                     soutVals <<  std::left << std::setw(12)<< reflection->GetInt64(root, fieldDescriptor);
                     break;
                  }
                  case google::protobuf::FieldDescriptor::CPPTYPE_UINT32: {
                     soutVals <<  std::left << std::setw(12)<< reflection->GetUInt32(root, fieldDescriptor);
                     break;
                  }
                  case google::protobuf::FieldDescriptor::CPPTYPE_UINT64: {
                     soutVals <<  std::left << std::setw(12)<< reflection->GetUInt64(root, fieldDescriptor);
                     break;
                  }
                  case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE: {
                     soutVals  <<  std::left << std::setw(12)<< reflection->GetDouble(root, fieldDescriptor);
                     break;
                  }
                  case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT: {
                     soutVals  <<  std::left << std::setw(12)<< reflection->GetFloat(root, fieldDescriptor);
                     break;
                  }
                  case google::protobuf::FieldDescriptor::CPPTYPE_BOOL: {
                     soutVals <<  std::left << std::setw(12)<< reflection->GetBool(root, fieldDescriptor);
                     break;
                  }
                  case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: {
                     const google::protobuf::EnumValueDescriptor* enumVal = reflection->GetEnum(root, fieldDescriptor);
                     int enumIndex = enumVal->index();
                     soutVals <<  std::left << std::setw(12)<<  enumIndex;
                     break;
                  }
                  default: {
                     soutVals << "   \t";
                     break;
                  }
               }
            }  // end if has field
            else {
               // This field had no data. We should skip it
            }
            if (lastField) {
               // print message divider
               soutFields << msgDivider;
               soutVals << msgDivider;
            }
            else {
               // print field Divider
               soutFields << fieldDivider;
               soutVals << fieldDivider;
            }
         }
      }
   }

   soutFields.width( oldWidth );
   soutFields.setf( oldFlags );
}
开发者ID:doughodson,项目名称:OpenEaagles,代码行数:101,代码来源:PrintSelected.cpp


注:本文中的std::ostream::setf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。