本文整理汇总了C++中ofstream::precision方法的典型用法代码示例。如果您正苦于以下问题:C++ ofstream::precision方法的具体用法?C++ ofstream::precision怎么用?C++ ofstream::precision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofstream
的用法示例。
在下文中一共展示了ofstream::precision方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: percentDiff
void percentDiff(double valA, double valB, ofstream& foutA)
{
double result;
result = ( fabs(valA - valB) / ( (valA + valB) / 2) ) * 100;
foutA.setf(ios::fixed);
foutA.setf(ios::showpoint);
foutA.precision(2);
foutA << setw(15) << result << " %" << endl;
foutA.precision(6);
} // end of percent diff
示例2: PosMidBead
void chain::PosMidBead(ofstream &o)//Speichert die Position des mittleren beads
{
//cout << "PushmidBead" << endl;
//vektor<double> x=vektor<double>(Beads.at(N/2).ort.x,Beads.at(N/2).ort.y,Beads.at(N/2).ort.z);
o.precision(100);
vektor<double> S= vektor<double>(0,0,0);
for(int i=0;i<N;i++)
{
S.x+=Beads.at(i).ort.x+Beads.at(i).xtimes*XMAX;
S.y+=Beads.at(i).ort.y+Beads.at(i).ytimes*YMAX;
S.z+=Beads.at(i).ort.z+Beads.at(i).ztimes*ZMAX;
}
o << (S.x/N) << "\t"<< (S.y/N) << "\t"<< (S.z/N) << "\n";
vektor<double> x=vektor<double>(Beads.at(N/2).ort.x+Beads.at(N/2).xtimes*XMAX,Beads.at(N/2).ort.y+Beads.at(N/2).ytimes*YMAX,Beads.at(N/2).ort.z+Beads.at(N/2).ztimes*ZMAX);
//midBead.push_back(x);
o << x.x << "\t"<< x.y << "\t"<< x.z << "\n";
x=vektor<double>(Beads.at(0).ort.x+Beads.at(0).xtimes*XMAX,Beads.at(0).ort.y+Beads.at(0).ytimes*YMAX,Beads.at(0).ort.z+Beads.at(0).ztimes*ZMAX);
//firstBead.push_back(x);
o << x.x << "\t"<< x.y << "\t"<< x.z<< "\n";
x=vektor<double>(Beads.at(N-1).ort.x+Beads.at(N-1).xtimes*XMAX,Beads.at(N-1).ort.y+Beads.at(N-1).ytimes*YMAX,Beads.at(N-1).ort.z+Beads.at(N-1).ztimes*ZMAX);
//lastBead.push_back(x);
o << x.x << "\t"<< x.y << "\t"<< x.z<< "\n";
}
示例3: advanceTrial
void advanceTrial()
{
beepOk(0);
double timeElapsed = timer.getElapsedTimeInMilliSec();
responseFile.precision(3); // max three decimal positions
responseFile << fixed <<
parameters.find("SubjectName") << "\t" <<
interoculardistance << "\t" <<
trialNumber << "\t" <<
trial.getCurrent()["AbsDepth"] << "\t" <<
objwidth << "\t" <<
adjDz << "\t" <<
timeElapsed
<< endl;
trialNumber++;
if(trial.hasNext())
{
trial.next();
initTrial();
} else
{
isStimulusDrawn=false;
drawGLScene();
responseFile.close();
expFinished = true;
}
}
示例4: writeOutput
void powercrust::writeOutput(ofstream& outFile) {
cout<<"Writing output..\n";
outFile<<"OFF\n";
outFile<<verts.size()<<"\t"<<faces.size()<<"\t0\n";
outFile.precision(12);
for(int i=0;i<verts.size();i++)
outFile<<verts[i].x<<"\t"<<verts[i].y<<"\t"<<verts[i].z<<"\n";
for(int i=0;i<faces.size();i++) {
if(faces[i].orientation==CORRECT) {
outFile<<faces[i].nodes.size()<<"\t";
for(int j=0;j<faces[i].nodes.size();j++)
outFile<<faces[i].nodes[j]<<"\t";
outFile<<"\n";
}
else {
if(!reverseFaces)
cout<<"Reversing..\n";
outFile<<faces[i].nodes.size()<<"\t";
for(int j=faces[i].nodes.size()-1;j>=0;j--)
outFile<<faces[i].nodes[j]<<"\t";
outFile<<"\n";
}
}
}
示例5: setPrintPrecision
void setPrintPrecision(int print_precision, ofstream& out) {
cout.setf(std::ios::scientific);
cout.precision(print_precision);
out.setf(std::ios::fixed);
out.precision(print_precision);
out.setf(ios::showpoint);
}
示例6: advanceTrial
void advanceTrial(bool response)
{
beepOk(0);
double timeElapsed = timer.getElapsedTimeInMilliSec();
responseFile.precision(3);
responseFile <<
parameters.find("SubjectName") << "\t" <<
interoculardistance << "\t" <<
trialNumber << "\t" <<
trial.getCurrent().first["RelDepthObj"] <<"\t" <<
trial.getCurrent().second->getCurrentStaircase()->getID() << "\t" <<
trial.getCurrent().second->getCurrentStaircase()->getState() << "\t" <<
trial.getCurrent().second->getCurrentStaircase()->getInversions() << "\t" <<
trial.getCurrent().second->getCurrentStaircase()->getAscending()<< "\t" <<
responsekey << "\t" <<
response << "\t" <<
jitter << "\t"<<
timer.getElapsedTimeInMilliSec() << "\t" <<
trial.getCurrent().second->getCurrentStaircase()->getStepsDone() << "\t" <<
trial.getCurrent().second->getCurrentStaircase()->getState()+trial.getCurrent().first["RelDepthObj"] << "\t" <<
endl;
resp=response;
if( !trial.isEmpty() )
initTrial();
else
{
exit(0);
}
trial.next(response);
trialNumber++;
}
示例7: genRollingMedians
/*========================================================================*
* VGraphServer::genRollingMedians *
* function: generate rolling medians from transaction *
* event stream and writes into output file stream *
* intput: fin - transaction event stream *
* fout - rolling median output stream *
* return: none *
*=========================================================================*/
void VGraphServer::genRollingMedians(ifstream& fin, ofstream& fout)
{
m_edgeWindow.clear();
m_vertexTree.clear();
m_nameBook.clear();
fout.precision(2);
float fLastMedian = 0;
VGraphEdge edge;
while(fin >> edge)
{
if (!edge.isValid())
continue;
//update median if edge added to window
if (_insertEdge2Window(edge))
fLastMedian = _getCurrentMedian();
//uncomment to check graph info
//_dumpGraphInfo();
fout << fixed << fLastMedian << endl;
}
}
示例8: PrintStats
static void PrintStats(MaskStats* stats)
{
UINT64 vectorInstructions = stats->mask_8_count + stats->mask_16_count;
OutFile << "Instruction count: " << dec << stats->icount << endl;
OutFile << "Prefetch instructions: " << stats->masked_prefetch_count << endl;
OutFile << "Vector instructions: " << vectorInstructions << endl;
double vectorPercentage = (0 == vectorInstructions) ? 0 : (double)vectorInstructions / (double)stats->icount * 100;
OutFile.precision(2);
OutFile << "Percentage of vector instructions: " << vectorPercentage << "%" << endl;
double utilization8bit = ((double)stats->mask_8_bits / (double)(stats->mask_8_count*MASK_8)) * 100;
double utilization16bit = ((double)stats->mask_16_bits / (double)(stats->mask_16_count*MASK_16)) * 100;
double idle8bit = ((double)stats->mask_8_idle_count / (double)stats->mask_8_count) * 100;
double idle16bit = ((double)stats->mask_16_idle_count / (double)stats->mask_16_count) * 100;
double part8 = (double)stats->mask_8_count / (double)vectorInstructions;
double part16 = (double)stats->mask_16_count / (double)vectorInstructions;
OutFile << "Percentage of double-precision vector instructions: " << part8 * 100 << "%, utilization: " <<
utilization8bit << "%" << endl;
OutFile << "Percentage of idle instructions within the double-precision vector instructions: " <<
idle8bit << "%" << endl;
OutFile << "Percentage of single-precision vector instructions: " << part16 * 100 << "%, utilization: " <<
utilization16bit << "%" << endl;
OutFile << "Percentage of idle instructions within the single-precision vector instructions: " <<
idle16bit << "%" << endl;
double totalUtilization = (utilization8bit * part8) + (utilization16bit * part16);
double totalIdle = (idle8bit * part8) + (idle16bit * part16);
OutFile << "Total vector utilization percentage: " << totalUtilization << "%" << endl;
OutFile << "Total percentage of idle vector instructions: " << totalIdle << "%" << endl;
OutFile << "Errors encountered: " << stats->error_count << endl;
}
示例9: PutTable
/** Put a table of node values. This table is as compact
as possible while still maintaining readability
*/
void NodeList::PutTable( ofstream& s )
{
s.precision(4);
s.setf( ios::right, ios::adjustfield );
s << GNU_COMMENT << " NodeList\n"
<< GNU_COMMENT << "=========\n";
s << GNU_COMMENT << ' '
<< setw( 6) << "Id(1) "
<< setw(13) << "x(2) "
<< setw(13) << "fluxS(3) "
<< setw(13) << "fluxD(4) "
<< setw(13) << "fluxE(5) "
<< setw(13) << "left id(6) "
<< setw(13) << "right id(6) "
<< '\n';
SetLineStyle( '-' );
PutLine( s, 106 );
for( int i=0; i<n; i++ ){
node[i].PutTable( s );
}
s.flush();
}
示例10: outputPoles
void powershape::outputPoles(ofstream& outFile) {
outFile.precision(12);
int numverts=0;
for(int i=0;i<verts.size();i++)
if(verts[i].status!=REMOVED &&
(verts[i].label!=UNLABELED || outputUnlabeled))
numverts++;
outFile<<numverts<<"\n";
for(int i=0;i<verts.size();i++)
if(verts[i].status!=REMOVED &&
(verts[i].label!=UNLABELED || outputUnlabeled))
outFile<<verts[i].x<<"\t"
<<verts[i].y<<"\t"
<<verts[i].z<<"\t"
<<verts[i].radius<<"\t"
<<verts[i].label<<"\t"
<<verts[i].distance<<"\n";
}
示例11: outputNet
//Output values for neural network
void outputNet(neuNet network, ofstream &output) {
output.setf(ios::fixed,ios::floatfield);
output.precision(3);
output << network.input.size() << " "; //output number of inputs
output << network.hidden.size() << " "; //output number of hidden nodes
output << network.output.size() << endl; //output number of outputs
//output weights of input-hidden node edges
for (int i = 0; i < network.hid_in.size(); ++i) {
for (int j = 0; j < network.hid_in[i].size(); ++j) {
//if-else to prevent placing space at end of line
if (j != network.hid_in[i].size()-1)
output << "input hidden: " << network.hid_in[i][j] << " ";
else
output << "input hidden: " << network.hid_in[i][j];
}
output << endl;
}
//output weights of hidden node-output edges
for (int i = 0; i < network.out_hid.size(); ++i) {
for (int j = 0; j < network.out_hid[i].size(); ++j) {
//if-else to prevent placing space at end of line
if (j != network.out_hid[i].size()-1)
output << "output weight: " << network.out_hid[i][j] << " ";
else
output << "output weight: " << network.out_hid[i][j];
}
output << endl;
}
}
示例12: advanceTrial
void advanceTrial()
{
double timeElapsed = timer.getElapsedTimeInMilliSec();
responseFile.precision(3);
responseFile <<
parameters.find("SubjectName") << "\t" <<
//interoculardistance << "\t" <<
trialNumber << "\t" <<
stimPosn << "\t" <<
"-420" << "\t" <<//trial.getCurrent()["AbsDepth"] <<"\t" <<
"50" << "\t" <<//trial.getCurrent()["ObjHeight"] <<"\t" <<
timer.getElapsedTimeInMilliSec() << "\t" <<
//trial.getCurrent()["HapticFB"] << "\t" <<
//randCond << "\t" <<
//randIncrement << "\t" <<
stimCond << "\t" <<
pulsingColors << "\t" <<
endl;
trialFile.close();
trialNumber++;
if( !trial.isEmpty() )
{
trial.next();
initTrial();
}
else
{
exit(0);
}
}
示例13: main
int main()
{
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
int i,j,t;
double tmp;
cin>>t;
while(t > 0)
{
cin>>n>>tmp;
m = tmp * 100.00000000 + 0.5;
for( i = 1 ; i <= n ; ++ i)
{
cin>>w[ i ]>>v[ i ];
v[ i ] = v[ i ] * 100 + 0.5;
}
for( i = 1 ; i <= n ; ++ i)
for( j = int( m ) ;j >= int(v[ i ]) ; -- j)
if( f[ j ] < f[ j - int(v[ i ]) ] + w[ i ] )
f[ j ] = f[ j - int(v[ i ]) ] + w[ i ];
cout<<f[ int(m) ]<<"\n";
for( i = int( m ) ; i >= 0 ; -- i ) f[ i ] = 0;
--t;
}
return 0;
}
示例14: SaveOBJ
bool SaveOBJ(ofstream& fout, const double* const& points, const int* const& triangles, const unsigned int& nPoints,
const unsigned int& nTriangles, const Material& material, IVHACD::IUserLogger& logger, int convexPart, int vertexOffset)
{
if (fout.is_open()) {
fout.setf(std::ios::fixed, std::ios::floatfield);
fout.setf(std::ios::showpoint);
fout.precision(6);
size_t nV = nPoints * 3;
size_t nT = nTriangles * 3;
fout << "o convex_" << convexPart << std::endl;
if (nV > 0) {
for (size_t v = 0; v < nV; v += 3) {
fout << "v " << points[v + 0] << " " << points[v + 1] << " " << points[v + 2] << std::endl;
}
}
if (nT > 0) {
for (size_t f = 0; f < nT; f += 3) {
fout << "f "
<< triangles[f + 0]+vertexOffset << " "
<< triangles[f + 1]+vertexOffset << " "
<< triangles[f + 2]+vertexOffset << " " << std::endl;
}
}
return true;
}
else {
logger.Log("Can't open file\n");
return false;
}
}
示例15: Fini
static VOID Fini(INT32 code, VOID *v)
{
OutFile << "Total instruction count: " << dec << icount << endl;
OutFile << "Vector Instructions: " << vcount << endl;
OutFile.precision(2);
OutFile << "Percentage of vector instructions: " << ((double)vcount / (double)icount * 100) << "%" << endl;
OutFile.close();
}