Beispiel #1
0
void AsnBuf::hexDump(std::ostream &os) const
{
   bool done = false;
   int ch;
   
   ResetMode();

   std::hex(os);

   while (! done)
   {
	 
     try
      {
		 ch = GetUByte();
		 os << "0x";
		 os << ch;
		 os << "   ";
	  }
      catch (...)
      {

		 os.unsetf(std::ios_base::hex);
         os.unsetf(std::ios_base::hex);
         done = true;
      }
 
   }

  
}
Beispiel #2
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;
	  }
        }
     }
Beispiel #3
0
	void entry::print(std::ostream& os, int indent) const
	{
		assert(indent >= 0);
		for (int i = 0; i < indent; ++i) os << " ";
		switch (m_type)
		{
		case int_t:
			os << integer() << "\n";
			break;
		case string_t:
			{
				bool binary_string = false;
				for (std::string::const_iterator i = string().begin(); i != string().end(); ++i)
				{
					if (!std::isprint(static_cast<unsigned char>(*i)))
					{
						binary_string = true;
						break;
					}
				}
				if (binary_string)
				{
					os.unsetf(std::ios_base::dec);
					os.setf(std::ios_base::hex);
					for (std::string::const_iterator i = string().begin(); i != string().end(); ++i)
						os << static_cast<unsigned int>((unsigned char)*i);
					os.unsetf(std::ios_base::hex);
					os.setf(std::ios_base::dec);
					os << "\n";
				}
				else
				{
					os << string() << "\n";
				}
			} break;
		case list_t:
			{
				os << "list\n";
				for (list_type::const_iterator i = list().begin(); i != list().end(); ++i)
				{
					i->print(os, indent+1);
				}
			} break;
		case dictionary_t:
			{
				os << "dictionary\n";
				for (dictionary_type::const_iterator i = dict().begin(); i != dict().end(); ++i)
				{
					for (int j = 0; j < indent+1; ++j) os << " ";
					os << "[" << i->first << "]";
					if (i->second.type() != entry::string_t && i->second.type() != entry::int_t) os << "\n";
					else os << " ";
					i->second.print(os, indent+2);
				}
			} break;
		default:
			os << "<uninitialized>\n";
		}
	}
Beispiel #4
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 ExtendedPressureLogarithmicRateExpression::WriteCHEMKINOnASCIIFile(std::ostream& fOutput) const
	{
		fOutput.unsetf(std::ios_base::floatfield);
		fOutput.precision(6);

		for (unsigned int k = 0; k < species_.size(); k++)
		{
			for (int j = 0; j < N_[k]; j++)
			{
				if (species_indices_[k] == -1)
				{
					fOutput << " PLOGMX / ";
				}
				else
				{
					fOutput << " PLOGSP / ";
					fOutput << species_[k] << "  ";
				}

				fOutput << std::showpoint << std::setw(12) << std::left << p_[k][j] / 101325.;
				fOutput << std::showpoint << std::setw(12) << std::left << std::exp(lnA_[k][j]) / conversion_A_;
				fOutput << std::showpoint << std::setw(12) << std::left << Beta_[k][j];
				fOutput << std::showpoint << std::setw(12) << std::left << E_over_R_[k][j] * PhysicalConstants::R_J_kmol / Conversions::J_from_kcal;;

				fOutput << "/" << std::endl;
			}
		}
	}
Beispiel #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();
}
Beispiel #7
0
 void MapWriter::writeFacesToStream(const Model::FaceList& faces, std::ostream& stream) {
     assert(stream.good());
     stream.unsetf(std::ios::floatfield);
     
     for (unsigned int i = 0; i < faces.size(); i++)
         writeFace(*faces[i], stream);
 }
Beispiel #8
0
 void Newton::printIteration(std::ostream &stream) {
   stream << setw(5) << "iter";
   stream << setw(10) << "res";
   stream << setw(10) << "step";
   stream << std::endl;
   stream.unsetf(std::ios::floatfield);
 }
Beispiel #9
0
 bool binary_save(T const& t, std::ostream& os)
 {
     boost::io::ios_flags_saver saver(os);
     os.unsetf(std::ios_base::skipws);
     binary_oarchive<> bo(os);
     bo & t;
     return bo.good() ? true : (bo.clear(), false);
 }
Beispiel #10
0
 void MapWriter::writeToStream(const Model::Map& map, std::ostream& stream) {
     assert(stream.good());
     stream.unsetf(std::ios::floatfield);
     
     const Model::EntityList& entities = map.entities();
     for (unsigned int i = 0; i < entities.size(); i++)
         writeEntity(*entities[i], stream);
 }
Beispiel #11
0
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);
	}
}
Beispiel #12
0
  void Newton::printIteration(std::ostream &stream, int iter, double abstol, double abstolStep) {
    stream << setw(5) << iter;
    stream << setw(10) << scientific << setprecision(2) << abstol;
    stream << setw(10) << scientific << setprecision(2) << abstolStep;

    stream << fixed;
    stream << std::endl;
    stream.unsetf(std::ios::floatfield);
  }
inline
void
arma_ostream::print(std::ostream& o, const SizeCube& S)
  {
  arma_extra_debug_sigprint();
  
  const arma_ostream_state stream_state(o);
  
  o.unsetf(ios::showbase);
  o.unsetf(ios::uppercase);
  o.unsetf(ios::showpos);
  
  o.setf(ios::fixed);
    
  o << S.n_rows << 'x' << S.n_cols << 'x' << S.n_slices;
  
  stream_state.restore(o);
  }
Beispiel #14
0
/*===========================================================================*/
void VolumeObjectBase::print( std::ostream& os, const kvs::Indent& indent ) const
{
    BaseClass::print( os, indent );
    const std::ios_base::fmtflags flags( os.flags() );
    os << indent << "Veclen : " << this->veclen() << std::endl;
    os.setf( std::ios::boolalpha );
    os << indent << "Set of min/max value : " << this->hasMinMaxValues() << std::endl;
    os.unsetf( std::ios::boolalpha );
    os << indent << "Min. value : " << this->minValue() << std::endl;
    os << indent << "Max. value : " << this->maxValue() << std::endl;
    os.flags( flags );
}
Beispiel #15
0
void VectorFunction<value_type>::printDifferenceQuotientSequence(ublas::vector<double> x,
                                                                 std::ostream& os) const
{
	using namespace std;

    for (double delta=.1; delta>1e-9; delta/=10)
    {
        os << scientific << setprecision(1) << "[delta: " << delta << "] ";
        os.unsetf(std::ios::scientific);
        os << setprecision(8) << differenceQuotient(x, delta) << endl;
    }
}
Beispiel #16
0
        void MapWriter::writeObjectsToStream(const Model::EntityList& pointEntities, const Model::BrushList& brushes, std::ostream& stream) {
            assert(stream.good());
            stream.unsetf(std::ios::floatfield);

            Model::Entity* worldspawn = NULL;
            
            // group the brushes by their containing entities
            typedef std::map<Model::Entity*, Model::BrushList> EntityBrushMap;
            EntityBrushMap entityToBrushes;
            
            Model::BrushList::const_iterator brushIt, brushEnd;
            for (brushIt = brushes.begin(), brushEnd = brushes.end(); brushIt != brushEnd; ++brushIt) {
                Model::Brush& brush = **brushIt;
                Model::Entity& entity = *brush.entity();
                entityToBrushes[&entity].push_back(&brush);
                if (entity.worldspawn())
                    worldspawn = &entity;
            }
            
            // write worldspawn first
            if (worldspawn != NULL) {
                Model::BrushList& brushList = entityToBrushes[worldspawn];
                writeEntityHeader(*worldspawn, stream);
                for (brushIt = brushList.begin(), brushEnd = brushList.end(); brushIt != brushEnd; ++brushIt) {
                    writeBrush(**brushIt, stream);
                }
                writeEntityFooter(stream);
            }
            
            // now write the point entities
            Model::EntityList::const_iterator entityIt, entityEnd;
            for (entityIt = pointEntities.begin(), entityEnd = pointEntities.end(); entityIt != entityEnd; ++entityIt) {
                Model::Entity& entity = **entityIt;
                writeEntity(entity, stream);
            }

            // finally write the brush entities
            EntityBrushMap::iterator it, end;
            for (it = entityToBrushes.begin(), end = entityToBrushes.end(); it != end; ++it) {
                Model::Entity* entity = it->first;
                if (entity != worldspawn) {
                    Model::BrushList& brushList = it->second;
                    writeEntityHeader(*entity, stream);
                    for (brushIt = brushList.begin(), brushEnd = brushList.end(); brushIt != brushEnd; ++brushIt) {
                        writeBrush(**brushIt, stream);
                    }
                    writeEntityFooter(stream);
                }
            }
        }
inline
std::streamsize
arma_ostream::modify_stream(std::ostream& o, const std::complex<T>* data, const uword n_elem)
  {
  arma_ignore(data);
  arma_ignore(n_elem);
  
  o.unsetf(ios::showbase);
  o.unsetf(ios::uppercase);
  o.fill(' ');
  
  o.setf(ios::scientific);
  o.setf(ios::showpos);
  o.setf(ios::right);
  o.unsetf(ios::fixed);
  
  std::streamsize cell_width;
  
  o.precision(3);
  cell_width = 2 + 2*(1 + 3 + o.precision() + 5) + 1;
  
  return cell_width;
  }
inline
std::streamsize
arma_ostream::modify_stream(std::ostream& o, typename SpMat<T>::const_iterator begin, const uword n_elem, const typename arma_cx_only<T>::result* junk)
  {
  arma_ignore(begin);
  arma_ignore(n_elem);
  arma_ignore(junk);
  
  o.unsetf(ios::showbase);
  o.unsetf(ios::uppercase);
  o.fill(' ');
  
  o.setf(ios::scientific);
  o.setf(ios::showpos);
  o.setf(ios::right);
  o.unsetf(ios::fixed);
  
  std::streamsize cell_width;
  
  o.precision(3);
  cell_width = 2 + 2*(1 + 3 + o.precision() + 5) + 1;
  
  return cell_width;
  }
Beispiel #19
0
void GlobalStats::showWirxStats(std::ostream & out)
{
    out << "wirxsleep_stats = [" << endl;
    out << "%\tTotal Sleep Cycles (T), antenna BufferRX sleep cycles (ARX), BufferToTile sleep cycles (TTRX) " << endl;
    out << "%\tHUB\tT\tARX\tTTRX\t" << endl;

    std::streamsize p = out.precision();

    int total_cycles = sc_time_stamp().to_double() / GlobalParams::clock_period_ps-GlobalParams::reset_time;

    for (map<int, HubConfig>::iterator it = GlobalParams::hub_configuration.begin();
            it != GlobalParams::hub_configuration.end();
            ++it)
    {

	out.precision(2);


	
	int hub_id = it->first;

	map<int,Hub*>::const_iterator i = noc->hub.find(hub_id);
	Hub * h = i->second;

	out << "\t" << hub_id << "\t" << std::fixed << (double)h->total_sleep_cycles/total_cycles << "\t";

	int s = 0;
	for (map<int,int>::iterator i = h->buffer_rx_sleep_cycles.begin();
		i!=h->buffer_rx_sleep_cycles.end();i++)
	    s+=i->second;
	out << (double)s/h->buffer_rx_sleep_cycles.size()/h->total_sleep_cycles << "\t";

	s = 0;
	for (map<int,int>::iterator i = h->buffer_to_tile_sleep_cycles.begin();
		i!=h->buffer_to_tile_sleep_cycles.end();i++)
	    s+=i->second;
	out << (double)s/h->buffer_to_tile_sleep_cycles.size()/h->total_sleep_cycles << endl;
    }

    out << "];" << endl;

    out.unsetf(std::ios::fixed);

    out.precision(p);

}
static inline void write_object_data_structs(std::ostream &wto) {
  wto << "  objectstruct objs[] = {\n" <<std::fixed;
  int objcount = 0, obmx = 0;
  for (po_i i = parsed_objects.begin(); i != parsed_objects.end(); i++, objcount++)
  {
    wto << "    {"
        << i->second->sprite_index << "," << i->second->solid << ","
        << i->second->visible << "," << i->second->depth << ","
        << i->second->persistent << "," << i->second->mask_index
        << "," << i->second->parent_index << "," << i->second->id
        << "},\n";
    if (i->second->id >= obmx) obmx = i->second->id;
  }
  wto.unsetf(ios_base::floatfield);
  wto << "  };\n";
  wto << "  int objectcount = " << objcount << ";\n";
  wto << "  int obj_idmax = " << obmx+1 << ";\n";
}
Beispiel #21
0
void FullViewBuilder::writeLeastErrorResult(
		std::ostream& out, const SamplesRangeType& samples)
{
	using std::ios_base;
	const std::streamsize oldPrecision = out.precision();

	less<double, &Result::getRelativeError> lessError;
	SamplesType::const_iterator best =
			std::min_element(samples.first, samples.second, lessError);

	out.setf(ios_base::scientific);
	out.precision(10);
	out << std::setw(fieldWidths[10]) << best->getResult();
	out << std::setw(fieldWidths[11]) << best->getAbsoluteErrorEstimate();
	out << std::setw(fieldWidths[12]) << best->getAbsoluteError();
	out << std::setw(fieldWidths[13]) << best->getRelativeError();
	out << std::setw(fieldWidths[14]) << best->classification();
	out.unsetf(ios_base::scientific);
	out.precision(oldPrecision);
}
void
write_nonref_2allele_test(const blt_options& opt,
                          const snp_pos_info& pi,
                          const nonref_test_call& nrc,
                          std::ostream& os) {

    os << nrc.snp_qphred
       << '\t' << NR2TEST::label(static_cast<NR2TEST::index_t>(nrc.max_gt)) << "_" << id_to_base(nrc.nonref_id)
       << '\t' << nrc.max_gt_qphred;

    //if(opt.is_print_used_allele_counts) {
    pi.print_known_counts(os,opt.used_allele_count_min_qscore);
    pi.print_known_qscore(os,opt.used_allele_count_min_qscore);
    //}

#if 0
    if (opt.is_print_all_poly_gt) {
        for (unsigned gt(0); gt<DIGT::SIZE; ++gt) {
#if 1
            // print GT as prob:
            os << '\t' << po.pprob[gt];
#else
            // print GT as qval:
            os << '\t' << error_prob_to_qphred(prob_comp(po.pprob,po.pprob+DIGT::SIZE,gt));
#endif
        }
    }
    const result_set& ge(dgt.genome);
    const result_set& po(dgt.poly);
#endif

#if 0
    if (nrc.is_freq) {
        os << std::setprecision(8) << std::fixed;
        for (unsigned i(0); i<N_BASE; ++i) {
            os << '\t' << nrc.allele_freq[i];
        }
        os.unsetf(std::ios::fixed);
    }
#endif
}
Beispiel #23
0
void BoxLevelStatistics::printBoxStats(
   std::ostream& co,
   const std::string& border) const
{
   co.unsetf(std::ios::fixed | std::ios::scientific);
   co.precision(3);

   /*
    * Smallest surface area possible for the number of cells perfectly
    * distributed in d_mpi.
    */
   const double ideal_width =
      pow(d_sq_sum.d_values[NUMBER_OF_CELLS] / d_mpi.getSize(),
         1.0 / d_dim.getValue());
   const double ideal_surfarea = 2 * d_dim.getValue()
      * pow(ideal_width, double(d_dim.getValue() - 1));

   co << border << "N = " << d_sq_sum.d_values[NUMBER_OF_BOXES]
      << " (global number of boxes)\n"
      << border << "P = " << d_mpi.getSize() << " (number of processes)\n"
      << border << "Ideal width (W) is " << ideal_width
      << ", surface area (A) is " << ideal_surfarea << " for "
      << (d_sq_sum.d_values[NUMBER_OF_CELLS] / d_mpi.getSize()) << " cells\n"
      << border << std::setw(s_longest_length) << std::string()
      << "    local        min               max             sum    sum/N    sum/P\n";

   for (int i = 0; i < NUMBER_OF_QUANTITIES; ++i) {
      co << border << std::setw(s_longest_length) << std::left
         << s_quantity_names[i]
         << ' ' << std::setw(8) << std::right << d_sq.d_values[i]
         << ' ' << std::setw(8) << std::right << d_sq_min.d_values[i] << " @ "
         << std::setw(6) << std::left << d_rank_of_min[i]
         << ' ' << std::setw(8) << std::right << d_sq_max.d_values[i] << " @ "
         << std::setw(6) << std::left << d_rank_of_max[i]
         << ' ' << std::setw(8) << std::right << d_sq_sum.d_values[i]
         << ' ' << std::setw(8)
         << std::right << d_sq_sum.d_values[i] / d_sq_sum.d_values[NUMBER_OF_BOXES]
         << ' ' << std::setw(8)
         << std::right << d_sq_sum.d_values[i] / d_mpi.getSize() << '\n';
   }
}
Beispiel #24
0
void FullViewBuilder::writeCase(std::ostream& out, const SamplesRangeType& samples)
{
	using std::ios_base;
	const std::streamsize oldPrecision = out.precision();

	/* Relative tolerance */
	out.setf(ios_base::scientific);
	out.precision(1);
	writeField(out, 0, samples);
	out.unsetf(ios_base::scientific);
	out.precision(oldPrecision);

	/* Rest up to the best result */
	for(size_t i = 1; i < fieldStatisticsSize; ++i)
	{
		writeField(out, i, samples);
	}

	writeLeastErrorResult(out, samples);
	out << '\n';
}
inline
void
arma_ostream::print_elem_zero(std::ostream& o, const bool modify)
  {
  if(modify == true)
    {
    const ios::fmtflags   save_flags     = o.flags();
    const std::streamsize save_precision = o.precision();
    
    o.unsetf(ios::scientific);
    o.setf(ios::fixed);
    o.precision(0);
    
    o << eT(0);
    
    o.flags(save_flags);
    o.precision(save_precision);
    }
  else
    {
    o << eT(0);
    }
  }
static
void
debug_dump_ddigt_lhood(const blt_float_t* lhood,
                       std::ostream& os) {

    double pprob[DDIGT::SIZE]; //intentionally run at higher float-resolution
    for(unsigned gt(0); gt<DDIGT::SIZE; ++gt) {
        pprob[gt] = lhood[gt];
    }

    unsigned max_gt(0);
    normalize_ln_distro(pprob,pprob+DDIGT::SIZE,max_gt);

    os << std::setprecision(3) << std::fixed;
    for(unsigned ngt(0); ngt<DIGT::SIZE; ++ngt) {
        for(unsigned tgt(0); tgt<DIGT::SIZE; ++tgt) {
            const unsigned dgt(DDIGT::get_state(ngt,tgt));
            os << static_cast<DDIGT::index_t>(dgt) << ": " << -std::log(pprob[dgt]) << " ";
        }
        os << "\n";
    }
    os.unsetf(std::ios::fixed);
}
inline
std::streamsize
arma_ostream::modify_stream(std::ostream& o, const eT* data, const uword n_elem)
  {
  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(uword i=0; i<n_elem; ++i)
    {
    const eT val = data[i];
    
    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)) ) 
        (
        cond_rel< is_signed<eT>::value >::leq(val, eT(-100))
        )
      ||
        (
        cond_rel< is_non_integral<eT>::value >::gt(val,  eT(0))
        &&
        cond_rel< is_non_integral<eT>::value >::leq(val, eT(+1e-4))
        )
      ||
        (
        cond_rel< is_non_integral<eT>::value && is_signed<eT>::value >::lt(val, eT(0))
        &&
        cond_rel< is_non_integral<eT>::value && is_signed<eT>::value >::geq(val, eT(-1e-4))
        )
      )
      {
      use_layout_C = true;
      break;
      }
      
    if(
      // (val >= eT(+10)) || ( (is_signed<eT>::value == true) && (val <= eT(-10)) )
      (val >= eT(+10)) || ( cond_rel< is_signed<eT>::value >::leq(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;
  }
Beispiel #28
0
	void ExtendedFallOff::WriteCHEMKINOnASCIIFile(std::ostream& fOutput) const
	{
		for (unsigned int k = 0; k < species_.size(); k++)
		{
			// Low-pressure kinetic parameters
			{
				if (species_indices_[k] == -1)
					fOutput << "LOWMX/ ";
				else
				{
					fOutput << "LOWSP/ ";
					fOutput << species_[k];
				}

				fOutput.width(11);
				fOutput.unsetf(std::ios_base::floatfield);
				fOutput.precision(6);
				fOutput << std::showpoint << "   " << A0_[k]/conversion_A0_;
				fOutput << std::showpoint << "   " << Beta0_[k];
				fOutput << std::showpoint << "   " << E0_over_R_[k] * PhysicalConstants::R_J_kmol / Conversions::J_from_kcal;

				fOutput << "/" << std::endl;
			}

			// Attitional options
			{
				if (type_[k] == EXTENDED_FALLOFF_TROE)
				{
					if (species_indices_[k] == -1)
						fOutput << "TROEMX/";
					else
					{
						fOutput << "TROESP/";
						fOutput << species_[k];
					}
				}

				else if (type_[k] == EXTENDED_FALLOFF_SRI)
				{
					if (species_indices_[k] == -1)
						fOutput << "SRIMX/ ";
					else
					{
						fOutput << "SRISP/ ";
						fOutput << species_[k];
					}
				}

				if (type_[k] != EXTENDED_FALLOFF_LINDEMANN)
				{
					fOutput.width(11);
					fOutput.unsetf(std::ios_base::floatfield);
					for (unsigned int j = 0; j < teta_[k].size(); j++)
					{
						fOutput.precision(6);
						fOutput << std::showpoint << "   " << teta_[k][j];
					}

					fOutput << "/" << std::endl;
				}
			}
		}
	}
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;
  }
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);
  }