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
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"; }
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; } }
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"; } } }
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); }
void advanceTrial() { beepOk(0); double timeElapsed = timer.getElapsedTimeInMilliSec(); double stimPresentation = stimTimer.getElapsedTimeInMilliSec(); responseFile.precision(3); responseFile << fixed << trialNumber << "\t" << interoculardistance << "\t" << estsize << "\t" << estdepth << "\t" << factors["AbsDepth"] << "\t" << timeElapsed << "\t" << stimPresentation << endl; trialNumber++; if( trial.getRemainingTrials() != 0) { initTrial(); } else { cleanup(); // shut down Optotrak exit(0); } }
void advanceTrial() { beepOk(0); double timeElapsed = timer.getElapsedTimeInMilliSec(); responseFile.precision(3); responseFile << fixed << parameters.find("SubjectName") << "\t" << (eyeLeft-eyeRight).norm() << "\t" << trialNumber << "\t" << trial.getCurrent()["AbsDepth"] << "\t" << trial.getCurrent()["RelDepthObj"] << "\t" << xedge << "\t" << xedge + jitter << "\t" << zedge << "\t" << zedge + (jitter/2) << "\t" << jitter << "\t" << jitterX << "\t" << theta << "\t" << trial.getCurrent()["Orientation"] << "\t" << timeElapsed << endl; trialNumber++; if(trial.getRemainingTrials() != 0) initTrial(); else { cleanup(); // shut down Optotrak exit(0); } }
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++; }
/*========================================================================* * 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; } }
void advanceTrial() { double timeElapsed = globalTimer.getElapsedTimeInMilliSec(); responseFile.precision(3); // max three decimal positions responseFile << fixed << parameters.find("SubjectName") << "\t" << trialNumber << "\t" << repetitions << "\t" << starting_theta << "\t" << final_theta << "\t" << trial.getCurrent()["Tilt_sign"] << "\t" << timeElapsed << "\t" << endl; trialNumber++; if(trial.hasNext()) { trial.next(); initTrial(); } else if (repetitions < max_repetitions) { repetitions++; initVariables(); trial.next(); initTrial(); } else { responseFile.close(); expFinished = true; beepOk(4); } }
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; }
/** 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(); }
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"; }
//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; } }
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); } }
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; }
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; } }
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(); }
void SpinAdapted::OneElectronArray::DumpToFile(ofstream& dumpFile) const { dumpFile.precision(20); dumpFile << dim << endl; for (int i=0; i<dim; ++i) for (int j=0; j<dim; ++j) { if (fabs((*this)(i, j)) > 1.e-20) dumpFile << i << " " << j << " " << (*this)(i, j) << endl; } }
string _main(){ string R=""; long x1,x2,y1,y2,px,py; int N,M; fin>>N>>M; int i,j,k; fin>>x1>>y1>>x2>>y2; double beta,alpha1,alpha2; double r1,r2; double area,a1,a2; beta=atan2(double(y2-y1),double(x2-x1)); if(beta>PI/2 || beta <-PI/2){ long temp; temp=x1;x1=x2;x2=temp; temp=y1;y1=y2;y2=temp; beta=atan2(double(y2-y1),double(x2-x1)); } for(i=0;i<M;i++){ fin>>px>>py; alpha1=atan2(double(py-y1),double(px-x1)); alpha2=atan2(double(py-y2),double(px-x2)); r1=sqrt(double((px-x1)*(px-x1)+(py-y1)*(py-y1))); r2=sqrt(double((px-x2)*(px-x2)+(py-y2)*(py-y2))); if ((alpha1>beta-PI/2 && alpha1<beta+PI/2) && (alpha2>beta-PI/2 && alpha2<beta+PI/2)){//2 side alpha1=abs(alpha1-beta); a1=r1*r1*(0.5*alpha1-0.5*cos(alpha1)*sin(alpha1)); alpha2=abs(alpha2-beta); a2=r2*r2*(0.5*(PI-alpha2)+0.5*cos(alpha2)*sin(alpha2)); //cout<<i<<"2side"; } else if((alpha1<beta-PI/2 || alpha1>beta+PI/2) && (alpha2<beta-PI/2 || alpha2>beta+PI/2)){//1 side if(alpha1<0) alpha1+=2*PI; if(alpha2<0) alpha2+=2*PI; alpha1=abs(PI-abs(alpha1-beta)); a1=r1*r1*(0.5*(PI-alpha1)+0.5*cos(alpha1)*sin(alpha1)); alpha2=abs(PI-abs(alpha2-beta)); a2=r2*r2*(0.5*alpha2-0.5*cos(alpha2)*sin(alpha2)); //cout<<i<<"1side"; } else{ //between alpha1=abs(alpha1-beta); a1=r1*r1*(0.5*alpha1-0.5*cos(alpha1)*sin(alpha1)); alpha2=abs(PI-abs(alpha2-beta)); a2=r2*r2*(0.5*alpha2-0.5*cos(alpha2)*sin(alpha2)); //cout<<i<<"between"<<endl; //cout<<alpha1<<" "<<alpha2<<endl<<a1<<" "<<a2<<endl; } area=2*(a1+a2); fout.precision(7); fout<<" "<<fixed<<area; } //cin>>R; return R; }
void SpinAdapted::TwoElectronArray::DumpToFile(ofstream& dumpFile) const { dumpFile.precision(20); dumpFile << dim << endl; for (int i=0; i<dim; ++i) for (int j=0; j<dim; ++j) for (int k=0; k<dim; ++k) for (int l=0; l<dim; ++l) if (fabs((*this)(i, j, k, l)) > 1.e-20) dumpFile << i << " " << j << " " << k << " " << l << " " << (*this)(i, j, k, l) << endl; }
void print ( ofstream & o, stringstream & txt, bool only2file ) { cout.precision ( 3 ); o.precision ( 3 ); if ( !only2file ) { cout << txt.str (); } o << txt.str (); txt.str ( string () ); txt.clear (); return; }
void analysis::print(ofstream& resOut, vector<basicStats> minReqs) { resOut << std::endl<<fName<<":"<<std::endl; bool ok = true; for (int t = 0; t < latencyStats.size(); t++) { basicStats tmpTask = latencyStats[t]; resOut<<tmpTask.taskName<<": "; bool tfound = false; //compare this against the min requirements by searching through the minreqs array //and checking if the names match; if they do, see if the mean and stddev are within the bounds for (int a = 0; a < minReqs.size(); a++) { if (tolower(strtrim(tmpTask.taskName)) == tolower(strtrim(minReqs[a].taskName))) { tfound = true; if (tmpTask.mean <= (minReqs[a].mean) && tmpTask.mean >= 0) resOut <<"OK"; else { resOut <<"Failed!"; ok = false; } } } //if the min requirement for this analysis was not defined, say so, otherwise output the results if (!tfound) resOut<<"not defined in BCI2000Certification.cfg."<<endl; else { resOut.precision(4); resOut<<"\t("<<tmpTask.mean<<", "<< tmpTask.std<<", "<<tmpTask.min<<", "<<tmpTask.max<<")"<<endl; } } if (droppedSamples > 0) resOut << "Samples appear to have been dropped during program execution!"<<endl; else resOut <<"No samples appear to have been dropped during program execution."<<endl; //say whether this file passed the requirements if (ok) { resOut<<"This task passed the minimum BCI2000 requirements."<<endl; cout<<fName<< " passed the minimum BCI2000 requirements."<<endl; } else { resOut<<"One or more components of this task did not meet minimum BCI2000 requirements!"<<endl; cout<<fName<< " did not pass the minimum BCI2000 requirements."<<endl; } }
/// \brief Opens the statistics file and sets the properties for the ofstream /// /// \param file An uninitialized ofstream for the statistics files void CMinimizerThread::OpenStatisticsFile(ofstream & file) { stringstream filename; if(file.is_open()) file.close(); // Open the statistics file for writing: filename.str(""); filename << mSaveDirectory << "/best_fit.txt"; file.open(filename.str().c_str()); file.width(15); file.precision(8); }
void advanceTrial() { double timeElapsed = timer.getElapsedTimeInMilliSec(); responseFile.precision(3); responseFile << parameters.find("SubjectName") << "\t" << //interoculardistance << "\t" << trialNumber << "\t" << stimPosn << "\t" << trial.getCurrent()["RodVisibleTime"] << "\t" << trial.getCurrent()["AbsDepth"] <<"\t" << //"50" << "\t" <<//trial.getCurrent()["ObjHeight"] <<"\t" << timer.getElapsedTimeInMilliSec() << "\t" << //trial.getCurrent()["HapticFB"] << "\t" << //randCond << "\t" << //randIncrement << "\t" << stimCond << "\t" << BG_WHITE << "\t" << endl; trialFile.close(); double percent_occluded_frames = num_lost_frames/TGA_frame; bool not_enough_frames = percent_occluded_frames > 0.20; cout << num_lost_frames << "_" << frameN << "_" << percent_occluded_frames << endl; int overwrite = 0; if (training || !reachedObject || not_enough_frames ) { cout << training << "_" << !reachedObject << "_" << not_enough_frames << endl; map<std::string,double> currentFactorsList = trial.getCurrent(); trial.reinsert(currentFactorsList); beepOk(1); overwrite = 1; } if( !trial.isEmpty() ) { if (!overwrite) trialNumber++; cout << trialNumber << endl; factors = trial.getNext(); initTrial(); } else { exit(0); } }
int main() { bulirsch_stoer_dense_out< state_type > stepper( 1E-9 , 1E-9 , 1.0 , 0.0 ); state_type x1 = {{ 0.0 , 1.0 , 1.0 }}; double t = 0.0; double dt = 0.01; out.open( "elliptic1.dat" ); out.precision(16); integrate_const( stepper , rhs , x1 , t , 100.0 , dt , write_out ); out.close(); state_type x2 = {{ 0.0 , 1.0 , 1.0 }}; out.open( "elliptic2.dat" ); out.precision(16); integrate_adaptive( stepper , rhs , x2 , t , 100.0 , dt , write_out ); out.close(); typedef runge_kutta_dopri5< state_type > dopri5_type; typedef controlled_runge_kutta< dopri5_type > controlled_dopri5_type; typedef dense_output_runge_kutta< controlled_dopri5_type > dense_output_dopri5_type; dense_output_dopri5_type dopri5 = make_dense_output( 1E-9 , 1E-9 , dopri5_type() ); //dense_output_dopri5_type dopri5( controlled_dopri5_type( default_error_checker< double >( 1E-9 , 0.0 , 0.0 , 0.0 ) ) ); state_type x3 = {{ 0.0 , 1.0 , 1.0 }}; out.open( "elliptic3.dat" ); out.precision(16); integrate_adaptive( dopri5 , rhs , x3 , t , 100.0 , dt , write_out ); out.close(); }
int main() { int n; cin >> n; vector <vector <double> > p(n, vector <double>(n)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> p[i][j]; } } power(n, p, 64); cout.precision(10); cout << fixed; for (int i = 0; i < n; i++) { cout << p[0][i] << endl; } }
void write(ofstream& out, Car c[], int size) { for(int i=0; i < size; i++) { Car CAR = c[i]; out.setf(ios::fixed); out.setf(ios::showpoint); out.precision(2); out << CAR.make << " " << CAR.model << " " << CAR.year << " " << CAR.price << " " << CAR.miles << " " << CAR.getValue() << endl; } return; }
void advanceTrial(bool response) { double timeElapsed = timer.getElapsedTimeInMilliSec(); responseFile.precision(3); // max three decimal positions responseFile << fixed << parameters.find("SubjectName") << "\t" << interoculardistance << "\t" << trialNumber << "\t" << objdistance << "\t" << objheight << "\t" << objtheta << "\t" << depth_pedestal << "\t" << depth_stimulus << "\t" << first_object << "\t" << second_object << "\t" << depth_cue_pedestal << "\t" << depth_cue_stimulus << "\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" << trial.getCurrent().second->getCurrentStaircase()->getStepsDone() << "\t" << responsekey << "\t" << response << "\t" << trial.getCurrent().first["DepthCue"] << "\t" << timeElapsed << endl; trial.next(response); trialNumber++; if(!trial.isEmpty()) { initTrial(); } else { responseFile.close(); expFinished = true; } }
void Reshuffle::write_data_chi(ifstream& out_file,ofstream& txt_chi){ out_file.seekg(0, ios_base::beg); double chi = 0; double CheckChi = (*p_Parameters).chi.value == "all" ? -1.0 : atof((*p_Parameters).chi.value.c_str()); cout << "Start_write_chi_data=" << double(clock()) / CLOCKS_PER_SEC <<" sec" << endl; txt_chi.precision(PRECISION_DOUBLE); txt_chi << "SNP\t"; txt_chi << "Trait\t"; for (int beta = 0; beta < (*(*p_iout_file).labels.beta).size(); beta++) txt_chi << (*(*p_iout_file).labels.beta)[beta] << "\t"; for (int se = 0;se < (*(*p_iout_file).labels.se).size(); se++) txt_chi << (*(*p_iout_file).labels.se)[se] << "\t"; for (int cov = 0;cov < (*(*p_iout_file).labels.cov).size(); cov++) txt_chi << (*(*p_iout_file).labels.cov)[cov] << "\t"; txt_chi << "Chi2" << endl; for (set<int>::iterator trait= (*p_Parameters).traits.numbersset.begin();trait!=(*p_Parameters).traits.numbersset.end();trait++) { //ofstream txt_chi(create_filename("chi_data//chi", (*(*p_iout_file).labels.trait_names)[*trait]).c_str()); double* buf = new double[per_trait_per_snp]; int oldPos = 0; char s[30]; for (set<int>::iterator snp= (*p_Parameters).snps.numbersset.begin();snp!=(*p_Parameters).snps.numbersset.end();snp++) { int pos = (*p_iout_file).tilecoordinates(*trait, *snp); //cout << oldPos << "-" << pos << endl; if(pos != oldPos) { out_file.seekg(pos,ios_base::beg); } oldPos=pos+sizeof(double)*per_trait_per_snp; out_file.read((char *)buf, sizeof(double)*per_trait_per_snp); chi=pow((buf[(*(*p_iout_file).labels.beta).size()-1]/buf[(*(*p_iout_file).labels.beta).size()+(*(*p_iout_file).labels.se).size()-1]),2); if(chi>CheckChi){ txt_chi << (*(*p_iout_file).labels.snp_names)[*snp] << "\t"; txt_chi << (*(*p_iout_file).labels.trait_names)[*trait]<<"\t"; for (int i = 0; i < per_trait_per_snp; i++) { sprintf(s, "%.15g", buf[i]); txt_chi << s << "\t"; } txt_chi << chi << endl; } } delete buf; //txt_chi.close(); cout << "End_write_chi_trait\t" << (*(*p_iout_file).labels.trait_names)[*trait] << " "<< double(clock()) / CLOCKS_PER_SEC <<" sec" << endl; } cout << "Finish_write_chi_data\t" << double(clock()) / CLOCKS_PER_SEC <<" sec" << endl; }