void doWriteBrushFace(std::ostream& stream, Model::BrushFace* face) {
     const String& textureName = face->textureName().empty() ? Model::BrushFace::NoTextureName : face->textureName();
     const Model::BrushFace::Points& points = face->points();
     
     stream.precision(FloatPrecision);
     stream <<
     "( " <<
     points[0].x() << " " <<
     points[0].y() << " " <<
     points[0].z() <<
     " ) ( "           <<
     points[1].x() << " " <<
     points[1].y() << " " <<
     points[1].z() <<
     " ) ( "           <<
     points[2].x() << " " <<
     points[2].y() << " " <<
     points[2].z() <<
     " ) ";
     
     stream.precision(6);
     stream <<
     textureName             << " " <<
     face->xOffset()          << " " <<
     face->yOffset()          << " " <<
     face->rotation()         << " " <<
     face->xScale()           << " " <<
     face->yScale()           << "\n";
 }
Exemple #2
0
 static void reportVolumes(std::ostream &os, double satvol[2], double tot_porevol_init,
                           double tot_injected[2], double tot_produced[2],
                           double injected[2], double produced[2],
                           double init_satvol[2])
 {
     os.precision(5);
     const int width = 18;
     os << "\nVolume balance report (all numbers relative to total pore volume).\n";
     os << "    Saturated volumes:     "
        << std::setw(width) << satvol[0]/tot_porevol_init
        << std::setw(width) << satvol[1]/tot_porevol_init << std::endl;
     os << "    Injected volumes:      "
        << std::setw(width) << injected[0]/tot_porevol_init
        << std::setw(width) << injected[1]/tot_porevol_init << std::endl;
     os << "    Produced volumes:      "
        << std::setw(width) << produced[0]/tot_porevol_init
        << std::setw(width) << produced[1]/tot_porevol_init << std::endl;
     os << "    Total inj volumes:     "
        << std::setw(width) << tot_injected[0]/tot_porevol_init
        << std::setw(width) << tot_injected[1]/tot_porevol_init << std::endl;
     os << "    Total prod volumes:    "
        << std::setw(width) << tot_produced[0]/tot_porevol_init
        << std::setw(width) << tot_produced[1]/tot_porevol_init << std::endl;
     os << "    In-place + prod - inj: "
        << std::setw(width) << (satvol[0] + tot_produced[0] - tot_injected[0])/tot_porevol_init
        << std::setw(width) << (satvol[1] + tot_produced[1] - tot_injected[1])/tot_porevol_init << std::endl;
     os << "    Init - now - pr + inj: "
        << std::setw(width) << (init_satvol[0] - satvol[0] - tot_produced[0] + tot_injected[0])/tot_porevol_init
        << std::setw(width) << (init_satvol[1] - satvol[1] - tot_produced[1] + tot_injected[1])/tot_porevol_init
        << std::endl;
     os.precision(8);
 }
Exemple #3
0
//===========================================================================
void Torus::write(std::ostream& os) const
//===========================================================================
{
    // Note on the data format: See comments for read().

    streamsize prev = os.precision(15);
    os << dimension() << endl
       << major_radius_ << endl
       << minor_radius_ << endl
       << location_ << endl
       << z_axis_ << endl
       << x_axis_ << endl;
    if (select_outer_)
	os << "1" << endl;
    else
	os << "0" << endl;

    // NB: Mind the parameter sequence!
    os << parbound_.umin() << " " << parbound_.umax() << endl
       << parbound_.vmin() << " " << parbound_.vmax() << endl;

    if (!isSwapped()) {
        os << "10" << endl;
    }
    else {
        os << "11" << endl;
    }
    os << domain_.umin() << " " << domain_.umax() << endl
       << domain_.vmin() << " " << domain_.vmax() << endl;

    os.precision(prev);   // Reset precision to it's previous value
}
Exemple #4
0
        void MapWriter::writeFace(const Model::Face& face, std::ostream& stream) {
            const String textureName = Utility::isBlank(face.textureName()) ? Model::Texture::Empty : face.textureName();
            
            stream.precision(FloatPrecision);
            stream <<
            "( " <<
            face.point(0).x() << " " <<
            face.point(0).y() << " " <<
            face.point(0).z() <<
            " ) ( "           <<
            face.point(1).x() << " " <<
            face.point(1).y() << " " <<
            face.point(1).z() <<
            " ) ( "           <<
            face.point(2).x() << " " <<
            face.point(2).y() << " " <<
            face.point(2).z() <<
            " ) ";

            stream.precision(6);
            stream <<
            textureName     << " " <<
            face.xOffset()  << " " <<
            face.yOffset()  << " " <<
            face.rotation() << " " <<
            face.xScale()   << " " <<
            face.yScale()   << "\n";
        }
Exemple #5
0
/////////////WRITE////////////////////////////////////////
//
void
SpatialConstraint::write(std::ostream &out) const {
  size_t p = out.precision();
  out.precision(16);
  out << a_ << ' ' << d_ << "\n";
  out.precision(p);
}
Exemple #6
0
//-----------------------------------------------------------------------------
bool ConicModel::Write(std::ostream& out) const
{
    int prec = out.precision(3);						// Sauvegarde des parametres du flux
    std::ios::fmtflags flags = out.setf(std::ios::fixed);

    out << "  <intrinseque>" << std::endl;

    out << "   <sensor>" << std::endl;
    out << "    <image_size> " << std::endl;
    out << "     <width> " <<  m_width << " </width>" << std::endl;
    out << "     <height> " <<  m_height << " </height>" << std::endl;
    out << "    </image_size>" << std::endl;

    out.precision(3);

    out << "    <ppa>" << std::endl;
    out << "     <c> " <<  m_cPPA << " </c>" << std::endl;
    out << "     <l> " <<  m_lPPA  << " </l>" << std::endl;
    out << "     <focale> " <<  m_focal << " </focale>" << std::endl;
    out << "    </ppa>" << std::endl;

    if(m_distortion) m_distortion->Write(out);

    out << "   </sensor>" << std::endl;

    out << "  </intrinseque>" << std::endl;

    out.precision(prec);		// Restauration des parametres du flux
    out.unsetf(std::ios::fixed);
    out.setf(flags);

    return out.good();
}
Exemple #7
0
void sumlines(std::istream &in, std::ostream &out) {
	boost::io::ios_all_saver io_all(out);
	std::string line;
	out.setf(std::ios::fixed, std::ios::floatfield);
	boost::regex re_float("-?\\d+([.]\\d{2})?");
	while (std::getline(in, line)) {
		try {
			double sum = 0.0;
			std::istringstream iss(line);
			std::string item;
			while (iss >> item) {
				if (!boost::regex_match(item, re_float))
					throw nullptr;
				sum += std::stod(item);
			}
			if (static_cast<long long>(sum) == sum)
				out.precision(0);
			else
				out.precision(2);
			out << sum << '\n';
		}
		catch (std::nullptr_t) {
			out << "EFMT: " << line << '\n';
		}
	}
}
Exemple #8
0
void BinaryFormatter::writePosition(std::ostream& into, const Position& val) {
    if (val.z() != 0.) {
        if (into.precision() == 2 && val.x() < 2e7 && val.x() > -2e7 &&
                val.y() < 2e7 && val.y() > -2e7 && val.z() < 2e7 && val.z() > -2e7) { // 2e7 is roughly INT_MAX/100
            FileHelpers::writeByte(into, BF_SCALED2INT_POSITION_3D);
            FileHelpers::writeInt(into, int(val.x() * 100. + .5));
            FileHelpers::writeInt(into, int(val.y() * 100. + .5));
            FileHelpers::writeInt(into, int(val.z() * 100. + .5));
        } else {
            FileHelpers::writeByte(into, BF_POSITION_3D);
            FileHelpers::writeFloat(into, val.x());
            FileHelpers::writeFloat(into, val.y());
            FileHelpers::writeFloat(into, val.z());
        }
    } else {
        if (into.precision() == 2 && val.x() < 2e7 && val.x() > -2e7 &&
                val.y() < 2e7 && val.y() > -2e7) { // 2e7 is roughly INT_MAX/100
            FileHelpers::writeByte(into, BF_SCALED2INT_POSITION_2D);
            FileHelpers::writeInt(into, int(val.x() * 100. + .5));
            FileHelpers::writeInt(into, int(val.y() * 100. + .5));
        } else {
            FileHelpers::writeByte(into, BF_POSITION_2D);
            FileHelpers::writeFloat(into, val.x());
            FileHelpers::writeFloat(into, val.y());
        }
    }
}
Exemple #9
0
void report_list(
    std::ostream& o,
    const Vector& list,
    const char* prefix = "  "
) {
    if (!list.empty()) {
        typename Vector::value_type min_value, max_value;
        min_value = *std::min_element(list.begin(), list.end());
        max_value = *std::max_element(list.begin(), list.end());
        if (min_value == max_value) {
            o << prefix << "\t" << min_value << "\n";
        } else {
            o << std::endl;
            o << prefix << "min:\t" << min_value << "\n";
            o << prefix << "median:\t" << median_element(list) << "\n";
            std::streamsize precision = o.precision();
            o.setf(std::ios::fixed, std::ios_base::floatfield);
            o.precision(2);
            o << prefix << "avg:\t" << avg_element_double(list) << "\n";
            o.precision(precision);
            o.unsetf(std::ios_base::floatfield);
            o << prefix << "max:\t" << max_value << "\n";
        }
    }
    o << std::endl;
}
void CarmenLogWriter::writeRawLaser(std::ostream& _stream, const LaserReading* _reading) const{
    _stream << std::fixed;
    _stream << _reading->getName() << " " << "0 ";
    
    const std::vector<double>& rho = _reading->getRho();
    const std::vector<double>& phi = _reading->getPhi();

    _stream.precision(6);
    _stream << phi.front() << " " << phi.back() - phi.front() << " " << (phi[1] - phi[0]) << " " << _reading->getMaxRange() << " " << "0.010000 "<< "0 ";
    
    _stream << rho.size() << " ";
    
    _stream.precision(3);
    for(uint i = 0; i < rho.size(); i++){
	_stream << rho[i] << " ";
    }
    
    const std::vector<double>& remission = _reading->getRemission();
    _stream << remission.size() << " ";
    
    for(uint i = 0; i < remission.size(); i++){
	_stream << remission[i] << " ";
    }
        
    _stream << _reading->getTime() << " " << _reading->getRobot() << " " << _reading->getTime() << std::endl;
}
Exemple #11
0
    void writeSpeciesData(std::ostream& log, const Species& spec) {
        
        if (!spec.id.empty()) 
            log << endl << "   id/date: " << spec.id << endl;
        else 
            log << " ... " << endl;
        
        log << "   phase: " 
            << spec.phase << endl 
            << "   composition: (";
        
        for (size_t ie = 0; ie < spec.elements.size(); ie++) {
	  if (!spec.elements[ie].name.empty()) {
	    log.flags(ios::fixed);
	    log.precision(0);
	    if (ie > 0) log << ", ";
	    log << spec.elements[ie].number << " " 
		<< spec.elements[ie].name;
	  }
        } 
        log << ")";
	
	if (spec.thermoFormatType == 0) {
	  log.flags(ios::showpoint | ios::fixed);
	  log.precision(2);
	  log << endl << "   Tlow, Tmid, Thigh: (" << spec.tlow << ", " << 
            spec.tmid << ", " << spec.thigh << ")" << endl << endl;
	  log << "   coefficients (low, high):" << endl;
	  log.flags(ios::scientific | ios::uppercase | ios::internal );
	 log.precision(8);
	 for (int j = 0; j < 7; j++) { 
	   log << "   a" << j + 1;
	   log.setf(ios::showpos);
	   log << "  \t" << spec.lowCoeffs[j] 
	       << "  \t" << spec.highCoeffs[j] << endl;
	   log.unsetf(ios::showpos);
	 }
	 log << endl;
	} else if (spec.thermoFormatType == 1) {
	  log.flags(ios::showpoint | ios::fixed);
	  log.precision(2);
	  log << endl;
	  log << "Number of temp regions = " << spec.nTempRegions << endl;
	  for (int i = 0; i < spec.nTempRegions; i++) {
	    log << "   Tlow, Thigh: (" << spec.minTemps[i] << ", " 
		<< spec.maxTemps[i] << ")" << endl << endl;
	    log << "   coefficients :" << endl;
	    log.flags( ios::scientific | ios::uppercase | ios::internal);
            log.precision(8);
	    vector_fp &cc = *spec.region_coeffs[i];
	    for (int j = 0; j < 9; j++) { 
	      log << "   a" << j + 1;
	      log.setf(ios::showpos);
	      log << "  \t" << cc[j]  << endl;
	      log.unsetf(ios::showpos);
	    }
	    log << endl;
	  }
        }
     }
Exemple #12
0
void MpiWrapper::writeResults(std::ostream& strm) const {
    
    if( myRank != 0 || !data ) return;
    
    streamsize oldPrec = strm.precision(8);
    
    strm << "# (partially) corrected Zernikes: " << efficiencies.size() << "   efficiencies=[";
    for(unsigned int i=0; i<efficiencies.size(); ++i) { strm << (i?", ":" ") << freq[i]; }
    strm << "]\n# spatial frequency\n";
    for(unsigned int i=0; i<freq.size(); ++i) strm << freq[i] << endl;
    strm << "# seeing alpha\n";
    for(unsigned int i=0; i<alpha.size(); ++i) strm << alpha[i] << endl;
    strm << "# functions\n";
    double* ptr = data.get();
    double sr, sr_sigma;

    for( unsigned int i = 0; i < alpha.size(); ++i ) {
        strm << "letf           s_letf         stf            s_stf          sr             s_sr\n";
        for( unsigned int j = 0; j < freq.size(); ++j ) {
            if(ptr[0] > 0 && ptr[2] && finite(ptr[1]) && finite(ptr[3]) ) {
                sr = ptr[0]*ptr[0]/ptr[2];
                sr_sigma = sr*sqrt(ptr[1] * ptr[1] / (ptr[0] * ptr[0]) + ptr[3] * ptr[3] / (ptr[2] * ptr[2]));
            } else sr = sr_sigma = 0;
            strm << setw(15) << left << ptr[0];             // LTF
            strm << setw(15) << left << ptr[1];             // LTF sigma
            strm << setw(15) << left << ptr[2];             // STF
            strm << setw(15) << left << ptr[3];             // STF sigma
            strm << setw(15) << left << sr;                 // Spectral ratio
            strm << setw(15) << left << sr_sigma << endl;     // Spectral ratio sigma
            ptr += 4;
        }
    }
    strm.precision(oldPrec);

}
Exemple #13
0
void
GslVector::print(std::ostream& os) const
{
  //std::cout << "In GslVector::print(): before sizelocal()"
  //          << std::endl;
  unsigned int size = this->sizeLocal();
  //std::cout << "In GslVector::print(): after sizelocal()"
  //          << std::endl;

  //std::cout << "In GslVector::print(): before os.flags()"
  //          << std::endl;
  std::ostream::fmtflags curr_fmt = os.flags();
  //std::cout << "In GslVector::print(): after os.flags()"
  //          << std::endl;

  if (m_printScientific) {
    unsigned int savedPrecision = os.precision();
    os.precision(16);

    if (m_printHorizontally) {
      for (unsigned int i = 0; i < size; ++i) {
        os << std::scientific << (*this)[i]
           << " ";
      }
    }
    else {
      for (unsigned int i = 0; i < size; ++i) {
        os << std::scientific << (*this)[i]
           << std::endl;
      }
    }

    os.precision(savedPrecision);
  }
  else {
    if (m_printHorizontally) {
      //std::cout << "In GslVector::print(): where expected"
      //          << std::endl;
      for (unsigned int i = 0; i < size; ++i) {
        os << std::dec << (*this)[i]
           << " ";
      }
    }
    else {
      for (unsigned int i = 0; i < size; ++i) {
        os << std::dec << (*this)[i]
           << std::endl;
      }
    }
  }

  //std::cout << "In GslVector::print(): before os.flags(curr_fmt)"
  //          << std::endl;
  os.flags(curr_fmt);
  //std::cout << "In GslVector::print(): after os.flags(curr_fmt)"
  //          << std::endl;

  return;
}
void OutputMaterials(std::ostream &ofs, SModel* model)
{
	ofs << "METERIALS" << std::endl;
	ofs << "NumMaterials= " << model->numMaterials << std::endl;

	if ( model->numMaterials == 0 )
	{
		model->materials = NULL;
		return;
	}

	for ( uint i = 0; i < model->numMaterials; i++ )
	{
		SMaterial* mat = &model->materials[ i ];
		ofs << "\t" << "MaterialType= " << mat->type << std::endl;
		ofs << "\t" << SMatNames[mat->type] << " " << mat->name << "\n";
		ofs << "\t\t" << "materialID= " << mat->materialID << std::endl;

		// set float format
		std::streamsize oldPrec = ofs.precision(5);
		ofs.setf(std::ios::fixed,std::ios::floatfield);	// floatfield set to fixed

		OutputAttribute(ofs, "ambient       ", mat->ambient);
		OutputAttribute(ofs, "diffuse       ", mat->diffuse);
		OutputAttribute(ofs, "incandescence ", mat->incandescence);
		OutputAttribute(ofs, "transparency  ", mat->transparency);

		ofs << "\t\t" << "normalmap      tex= " << mat->normalmapTex << "\n";

		switch(mat->type) 
		{
			case MATERIAL_PHONG:
				{
					OutputAttribute(ofs, "specular      ", mat->specular);
					ofs	<< "\t\t" << "shininess      " << mat->shininess << std::endl; 
				}
				break;
			case MATERIAL_BLINN:
				{
					OutputAttribute(ofs, "specular      ", mat->specular);
					ofs	<< "\t\t" << "eccentricity   " << mat->eccentricity << std::endl; 
					ofs	<< "\t\t" << "specularRollOff " << mat->specularRollOff << std::endl; 
				}
				break;
			case MATERIAL_LAMBERT:
				{
					// nothing
				}
				break;
			default:
				assert(0); exit(1);
		}
	
		// unset float format
		ofs.precision(oldPrec);
		ofs.unsetf(std::ios::floatfield);
	}
}
Exemple #15
0
void YAPCAReduce<eltype>::save_map(std::ostream &out) const {
  ya_sizet precision=out.precision();
  out.precision(16);
  this->write_header(out);
  write(out,eigen_vectors);
  write(out,this->eigen_values);
  write(out,column_means);
  out.precision(precision);
}
Exemple #16
0
void Double::writeXml(std::ostream& out) const
{
    std::streamsize old = out.precision();

    out << std::setprecision(std::numeric_limits < double >::digits10)
        << "<double>" << m_value << "</double>";

    out.precision(old);
}
Exemple #17
0
  BOOST_CHRONO_INLINE
  void show_time( const boost::chrono::process_times & times,
                  const char * format, int places, std::ostream & os )
  //  NOTE WELL: Will truncate least-significant digits to LDBL_DIG, which may
  //  be as low as 10, although will be 15 for many common platforms.
  {
    if ( times.real < nanoseconds(0) ) return;
    if ( places > 9 )
      places = 9;  // sanity check
    else if ( places < 0 )
      places = 0;

    boost::io::ios_flags_saver ifs( os );
    os.setf( std::ios_base::fixed, std::ios_base::floatfield );
    boost::io::ios_precision_saver ips( os );
    os.precision( places );

    nanoseconds total = times.system + times.user;

    for ( ; *format; ++format )
    {
      if ( *format != '%' || !*(format+1) || !std::strchr("rcpus", *(format+1)) )
        os << *format;
      else
      {
        ++format;
        switch ( *format )
        {
        case 'r':
          os << duration<double>(times.real).count();
          break;
        case 'u':
          os << duration<double>(times.user).count();
          break;
        case 's':
          os << duration<double>(times.system).count();
          break;
        case 'c':
          os << duration<double>(total).count();
          break;
        case 'p':
          {
            boost::io::ios_precision_saver ips( os );
            os.precision( 1 );
            if ( times.real.count() && total.count() )
              os << duration<double>(total).count()
                   /duration<double>(times.real).count() * 100.0;
            else
              os << 0.0;
          }
          break;
        default:
          BOOST_ASSERT(0 && "run_timer internal logic error");
        }
      }
    }
  }
Exemple #18
0
void
Integer::writeString(std::ostream& out) const
{
    std::streamsize old = out.precision();

    out << std::setprecision(std::numeric_limits<int32_t>::digits10)
        << m_value;

    out.precision(old);
}
Exemple #19
0
void gnuplot_print_polygon(std::ostream& out, const Polygon_2& P, int z)
{
    int prec = out.precision();
    out << std::setprecision(pp_precision);
    Polygon_2::Vertex_const_iterator  vit;
    for (vit = P.vertices_begin(); vit != P.vertices_end(); ++vit)
        out << *vit << " " << z << std::endl;
    out << *(P.vertices_begin()) << " " << z << std::endl;
    out.precision(prec);
}
Exemple #20
0
void gnuplot_print_polygon(std::ostream& out, const Polygon_2& P)
{
    int prec = out.precision();
    out << std::setprecision(pp_precision);
    Polygon_2::Vertex_const_iterator  vit;
    for (vit = P.vertices_begin(); vit != P.vertices_end(); ++vit)
        vit->insert(out) << std::endl;//" " << vit->z() << std::endl;
    P.vertices_begin()->insert(out) << std::endl;//" " << P.vertices_begin()->z() << std::endl;
    out.precision(prec);
}
Exemple #21
0
void gnuplot_print_polygon(std::ostream& out, const Untiled_region& poly)
{
    int prec = out.precision();
    out << std::setprecision(pp_precision);
    Untiled_region::const_iterator vit = poly.begin();
    for (; vit != poly.end(); ++vit)
        out << *vit << std::endl;
    out << *(poly.begin()) << std::endl << std::endl << std::endl;
    out.precision(prec);
}
Exemple #22
0
//===========================================================================
void DirectionCone::write(std::ostream& os) const
//===========================================================================
{
    ALWAYS_ERROR_IF(greater_than_pi_ < 0,
                    "Not initialized - cannot write.");

    streamsize prev = os.precision(15);
    os << centre_ << endl << angle_;
    os.precision(prev);   // Reset precision to it's previous value
    return;
}
inline
void
arma_ostream::print_elem_zero(std::ostream& o)
  {
  const std::streamsize orig_precision = o.precision();
  
  o.precision(0);
  
  o << eT(0);
  
  o.precision(orig_precision);
  }
Exemple #24
0
/** Print value for user */
void Real::printValue(std::ostream &o) const {

    long previousPrecision = o.precision();
    std::ios_base::fmtflags previousFlags = o.flags();

    std::fixed( o );
    o.precision( 3 );
    o << dagNode->getValue();

    o.setf( previousFlags );
    o.precision( previousPrecision );
}
/** Print value for user */
void MatrixRealSymmetric::printValue(std::ostream &o) const {
    
    long previousPrecision = o.precision();
    std::ios_base::fmtflags previousFlags = o.flags();
    
    std::fixed( o );
    o.precision( 3 );

    dagNode->printValue( o );
    
    o.setf( previousFlags );
    o.precision( previousPrecision );
}
void planning_models::KinematicState::printStateInfo(std::ostream &out) const
{
  out << "Complete model state dimension = " << getDimension() << std::endl;
    
  std::ios_base::fmtflags old_flags = out.flags();    
  out.setf(std::ios::fixed, std::ios::floatfield);
  std::streamsize old_prec = out.precision();
  out.precision(5);
  out << "State bounds: ";
  for(unsigned int i = 0; i < joint_state_vector_.size(); i++) {
    for(std::map<std::string, std::pair<double, double> >::const_iterator it = joint_state_vector_[i]->getAllJointValueBounds().begin();
        it != joint_state_vector_[i]->getAllJointValueBounds().end();
        it++) {
      if(it->second.first == -DBL_MAX) {
        out << "[-DBL_MAX, ";
      } else {
        out << "[" << it->second.first << ", ";
      }
      if(it->second.second == DBL_MAX) {
        out << "DBL_MAX] ";
      } else {
        out << it->second.second << "] ";  
      }
    }
  }
    
  out << std::endl;
  out.precision(old_prec);    
  out.flags(old_flags);
        
  out << "Root joint : ";
  out << kinematic_model_->getRoot()->getName() << " ";
  out << std::endl;
    
  out << "Available groups: ";
  std::vector<std::string> l;
  getJointStateGroupNames(l);
  for (unsigned int i = 0 ; i < l.size() ; ++i)
    out << l[i] << " ";
  out << std::endl;
    
  for (unsigned int i = 0 ; i < l.size() ; ++i)
  {
    const JointStateGroup *g = getJointStateGroup(l[i]);
    out << "Group " << l[i] << " has " << g->getJointRoots().size() << " roots: ";
    for (unsigned int j = 0 ; j < g->getJointRoots().size() ; ++j)
      out << g->getJointRoots()[j]->getName() << " ";
    out << std::endl;
  }
}
/** Print value for user */
void MultivariateRealNodeValTree::printValue(std::ostream &o) const {

    long previousPrecision = o.precision();
    std::ios_base::fmtflags previousFlags = o.flags();
    
    std::fixed( o );
    o.precision( 3 );
    
    dagNode->printValue( o );
    
    o.setf( previousFlags );
    o.precision( previousPrecision );

}
Exemple #28
0
void printStatsIncremental(std::ostream& out,
                           const std::string& prvsStatsString,
                           const std::string& curStatsString)
{
  if(prvsStatsString == "") {
    out << curStatsString;
    return;
  }

  // read each line
  // if a number, subtract and add that to parentheses
  std::istringstream issPrvs(prvsStatsString);
  std::istringstream issCur(curStatsString);

  std::string prvsStatName, prvsStatValue, curStatName, curStatValue;

  std::getline(issPrvs, prvsStatName, ',');
  std::getline(issCur, curStatName, ',');

  /**
   * Stat are assumed to one-per line: "<statName>, <statValue>"
   *   e.g. "sat::decisions, 100"
   * Output is of the form: "<statName>, <statValue> (<statDiffFromPrvs>)"
   *   e.g. "sat::decisions, 100 (20)"
   * If the value is not numeric, no change is made.
   */
  while( !issCur.eof() ) {

    std::getline(issCur, curStatValue, '\n');

    if(curStatName == prvsStatName) {
      std::getline(issPrvs, prvsStatValue, '\n');

      double prvsFloat, curFloat;
      bool isFloat =
        (std::istringstream(prvsStatValue) >> prvsFloat) &&
        (std::istringstream(curStatValue) >> curFloat);

      if(isFloat) {
        const std::streamsize old_precision = out.precision();
        out << curStatName << ", " << curStatValue << " "
            << "(" << std::setprecision(8) << (curFloat-prvsFloat) << ")"
            << std::endl;
        out.precision(old_precision);
      } else {
        out << curStatName << ", " << curStatValue << std::endl;
      }

      std::getline(issPrvs, prvsStatName, ',');
    } else {
Exemple #29
0
void LocalNetworkXML::std_dev_summary(std::ostream& out) const
{
    out << "\n<standard-deviation>\n";

    tagnl(out, "apriori", netinfo->apriori_m_0());
    tagnl(out, "aposteriori",
        (netinfo->degrees_of_freedom() > 0 ?
         sqrt(netinfo->trans_VWV()/netinfo->degrees_of_freedom()) : 0));
    tagnl(out, "used",
        (netinfo->m_0_aposteriori() ?
         string("aposteriori") : 
         string("apriori") ));

    out << "\n";

    out.setf(ios_base::fixed, ios_base::floatfield);
    out.precision(3);
    tagnl(out, "probability", netinfo->conf_pr());

    const int dof = netinfo->degrees_of_freedom();
    float test=0, lower=0, upper=0; 

    test  = netinfo->m_0() / netinfo->apriori_m_0();
    if (dof)
      if (netinfo->m_0_aposteriori())
        {
          const double alfa_pul = (1 - netinfo->conf_pr())/2;
          lower = sqrt(GNU_gama::Chi_square(1-alfa_pul,dof)/dof);
          upper = sqrt(GNU_gama::Chi_square(  alfa_pul,dof)/dof);
        }
      else
        {
          out << "   <!-- no test for apriori standard deviation -->\n";
        }

    tagnl(out, "ratio",  test);
    tagnl(out, "lower",  lower);
    tagnl(out, "upper",  upper);
    if (lower < test && test < upper || netinfo->m_0_apriori())
      out << "   <passed/>\n\n";
    else
      out << "   <failed/>\n\n";
    
    out.setf(ios_base::scientific, ios_base::floatfield);
    out.precision(7);
    tagnl(out, "confidence-scale",  netinfo->conf_int_coef());

    out << "</standard-deviation>\n";
}
void NonparametricRatioHMM::printInfo(size_t iter_n, log_likelihood logP, std::ostream &os,
                                      const double cutoff) const {
    std::ostream::fmtflags original_flgs = os.flags();
    int prob_pre = 4, logP_pre = ceil(-log(log_likelihood_tol) / log(10.0));
    logP_pre = (logP_pre > 0) ? (logP_pre + 2) : 2;
    int original_pre = os.precision(prob_pre);
    os << std::fixed << std::showpoint;
    
    if (iter_n == 0) os << "Initialization:" << endl;
    else os << "\n================================================================================\n"
            << "After iteration step " << iter_n << ":" << endl;
    
    os << "\nInitial state probability distribution:\npi:";
    for (log_prob_dist::const_iterator iter = log_pi.begin();
         iter != log_pi.end(); ++iter) {
        os << "\t" << ((*iter >= cutoff) ? 0.0 : exp(*iter));
    }
    os << endl;
    
    os << "\nTransition matrix:\nTrans";
    for (size_t i = 0; i != N; ++i) os << "\tstate" << i;
    os << endl;
    for (size_t i = 0; i != N; ++i) {
        os << "state" << i;
        for (log_prob_dist::const_iterator iter = log_trans[i].begin();
             iter != log_trans[i].end(); ++iter) {
            os << "\t" << ((*iter >= cutoff) ? 0.0 : exp(*iter));
        }
        os << endl;
    }
    
    os << "\nEmission matrix:\nRatio";
    for (size_t i = 0; i <= nbins; ++i) os << "\t" << static_cast<double>(i) / nbins;
    os << endl;
    for (size_t i = 0; i != N; ++i) {
        os << "state" << i;
        for (log_prob_dist::const_iterator iter = log_emission[i].begin();
             iter != log_emission[i].end(); ++iter) {
            os << "\t" << ((*iter >= cutoff) ? 0.0 : exp(*iter));
        }
        os << endl;
    }
    
    os.precision(logP_pre);
    os << "\nOverall log likelihood:\n" << logP << endl;
    
    os.flags(original_flgs);
    os.precision(original_pre);
}