static unsigned int processDocuments( const strus::PatternMatcherInstanceInterface* ptinst, const KeyTokenMap& keytokenmap, const std::vector<TreeNode*> treear, const std::vector<strus::utils::Document>& docs, std::map<std::string,double>& stats, const char* outputpath)
{
	unsigned int totalNofmatches = 0;
	std::vector<strus::utils::Document>::const_iterator di = docs.begin(), de = docs.end();
	std::size_t didx = 0;
	for (; di != de; ++di,++didx)
	{
#ifdef STRUS_LOWLEVEL_DEBUG
		std::cout << "document " << di->tostring() << std::endl;
#endif
		std::vector<strus::analyzer::PatternMatcherResult>
			results = eliminateDuplicates( sortResults( processDocument( ptinst, *di, stats)));

		if (outputpath)
		{
			std::ostringstream out;
			out << "number of matches " << results.size() << std::endl;
			strus::utils::printResults( out, std::vector<strus::SegmenterPosition>(), results);

			std::string outputfile( outputpath);
			outputfile.push_back( strus::dirSeparator());
			outputfile.append( "res.txt");

			strus::writeFile( outputfile, out.str());
		}
		std::vector<strus::analyzer::PatternMatcherResult>
			expectedResults = eliminateDuplicates( sortResults( processDocumentAlt( keytokenmap, treear, *di)));

		if (outputpath)
		{
			std::ostringstream out;
			out << "number of matches " << expectedResults.size() << std::endl;
			strus::utils::printResults( out, std::vector<strus::SegmenterPosition>(), expectedResults);

			std::string outputfile( outputpath);
			outputfile.push_back( strus::dirSeparator());
			outputfile.append( "exp.txt");

			strus::writeFile( outputfile, out.str());
		}

		if (!compareResults( results, expectedResults))
		{
			throw std::runtime_error(std::string( "results differ to expected for document ") + di->id);
		}
		totalNofmatches += results.size();
		if (g_errorBuffer->hasError())
		{
			throw std::runtime_error("error matching rule");
		}
	}
	return totalNofmatches;
}
Пример #2
0
void Append_file_to_file(char *inputPath, char *outputPath)
{
        qint64 BUFFER_SIZE = 10*1024*1024;
        qint64 buffer_len = 0;

        QFile inputfile(inputPath);
        if (!inputfile.open(QIODevice::ReadOnly))
                 return;

        QFile outputfile(outputPath);
        if (!outputfile.open(QIODevice::WriteOnly | QIODevice::Append))
                 return;

        QDataStream inputstream(&inputfile);
        QDataStream outputstream(&outputfile);

        char* buffer = new char[BUFFER_SIZE];

        while(!inputstream.atEnd())
        {
                buffer_len = inputstream.readRawData( buffer, BUFFER_SIZE );
                outputstream.writeRawData( buffer, buffer_len );
        }

        inputfile.close();
        outputfile.close();

        delete[] buffer;

        return;
}
Пример #3
0
/*
 * Assemble name.s into name.o
 */
bool	Assembler::assemble(const char *name)
{
	int i;
	struct Instruction s;

	if (!inputfile(asmf, name, ".s")) return false;
	if (!outputfile(of, name, ".o")) return false;
	symbols.clear();

	while (parse());
	asmf.clear();
	asmf.seekg(0);
	for (;;) {
		i = generate(&s);
		if (i == 1) {
#if BYTECODE == 1
			of.write((const char *)&s, sizeof(s));
#else
			of << *(uint16_t*)&s << std::endl;
#endif
		} else if (i == -1) break;
		else if (i == -2) {
			of.close();
			return false;
		}
	}

	of.close();
	asmf.close();
	symbols.clear();
	return true;
}
Пример #4
0
int main(int argc, char **argv)
{
	if (argc < 3)
	{
		printf("usage: bf3decrypt infile outfile\n", argv[0]);
		return 1;
	}
	
	mmap_buf(argv[1]);
	
	if (filebuf[0] != 0x00 && 
		filebuf[1] != 0xD1 && 
		filebuf[2] != 0xCE &&
		filebuf[3] != 0x00)
	{
		printf("Invalid File!\n");
		free(filebuf);
		return 1;
	}
	
	decrypt();
	outputfile(argv[2]);
	
	free(filebuf);
	return 0;
}
Пример #5
0
int main()
{
/*******************************************************************\
*                                                                   *
*            W r i t e   t o   a n   O u t p u t F i l e            *
*                                                                   *
\*******************************************************************/

    try {
	OutputFile outputfile("odata");
	
	for (int i = 1; i <= 10; ++i) {
	    outputfile << " " << i;
	}
	
	std::cout << "Data written to file: \"" << outputfile.Filename() << "\"" << std::endl;
	std::cout << "The numbers: 1 2 3 4 5 6 7 8 9 10" << std::endl;

	return 0;
    }
    catch (std::exception const& Exception) {
	std::cout << Exception.what() << std::endl;
    }
    return -1;
}
Пример #6
0
int main () {

// file to write
  ofstream outputfile("sample2.csv");

  //make instance
  double m_dt=0.001;
  interpolator* i = new interpolator(1, m_dt,interpolator::HOFFARBIB,0.5);
  if (i->isEmpty()) {
    std::cout<< "interpolater is  empty!" << std::endl;
  };

  double start=0.0,goal=1.0,goalv=0;
  double t=0;
  double x,v,a;
  double remain_t;

  i->set(&start);
  i->go(&goal,&goalv, 1.0, true);

  while (! i->isEmpty()) {
    i->get(&x,&v,&a,true);
    remain_t=i->remain_time();
    outputfile << t << " " << x << " " << v << " "<< a << " " << remain_t <<std::endl;
    t+=i->deltaT();
  }
  outputfile.close();
  return 0;
};
Пример #7
0
bool SqlFileExporter::exportTableAsCSV(QSqlQuery query, const QString &outputpath, bool csv) {
    QFile outputfile(outputpath);
    if (!outputfile.open(QIODevice::WriteOnly))
        return false;

    QString delimiter = "\t";
    if (csv)
        delimiter = ",";

    QSqlRecord record = query.record();
    for (int i = 0; i < record.count(); ++i) {
        if (i != 0)
            outputfile.write(delimiter.toUtf8());
        if (csv)
            outputfile.write(quoteCSVColumn(record.fieldName(i)).toUtf8());
        else
            outputfile.write(record.fieldName(i).toUtf8());
    }
    outputfile.write("\n");

    do {
        record = query.record();
        for (int i = 0; i < record.count(); ++i) {
            if (i != 0)
                outputfile.write(delimiter.toUtf8());
            if (csv)
                outputfile.write(quoteCSVColumn(record.value(i).toString()).toUtf8());
            else
                outputfile.write(record.value(i).toString().toUtf8());
        }
        outputfile.write("\n");
    } while(query.next());
    outputfile.close();
    return true;
}
void FossilRecord::WriteRecord(QString fname)
{
    QFile outputfile(fname);

    if (!writtenonce)
    {
        outputfile.open(QIODevice::WriteOnly);
        QTextStream out(&outputfile);

        out<<"'"<<name<<"'\n";
        out<<"'X',"<<xpos<<",'Y',"<<ypos<<",'start',"<<startage<<"\n";
        out<<"'Time','Red','Green','Blue','Genome',";

        for (int j=0; j<63; j++) out<<j<<",";
        out<<"63\n";
        outputfile.close();
    }

    outputfile.open(QIODevice::Append);
    QTextStream out(&outputfile);

    for (int i=0; i<fossils.length(); i++)
    {
        out<<fossils[i]->timestamp<<","<<fossils[i]->env[0]<<","<<fossils[i]->env[1]<<","<<fossils[i]->env[2]<<","<<fossils[i]->genome<<",";
        for (int j=0; j<63; j++)
           if (tweakers64[63-j] & fossils[i]->genome) out<<"1,"; else out<<"0,";

        if (tweakers64[0] & fossils[i]->genome) out<<"1\n"; else out<<"0\n";
    }
    outputfile.close();
    writtenonce=true;
    qDeleteAll(fossils);
    fossils.clear();
}
Пример #9
0
	//function to print body to screen (for debug purposes)
	void body::print_body_to_screen(string filename)
	{
		ofstream outputfile(filename.c_str(), ios::app);
		outputfile << "Body name: " << name << endl;
		outputfile << "Short name: " << short_name << endl;
		outputfile << "Body position in menu: " << body_code << endl;
		outputfile << "SPICE ID: " << spice_ID << endl;
		outputfile << "Valid flyby target? " << (minimum_safe_flyby_altitude > 0.0 ? "True" : "False") << endl;
		if (minimum_safe_flyby_altitude > 0.0)
			outputfile << "Minimum safe flyby altitude (km) " << minimum_safe_flyby_altitude << endl;
		outputfile << "Mass (kg): " << mass << endl;
		outputfile << "Radius (km): " << radius << endl;
		outputfile << "Ephemeris source: " << body_ephemeris_source << endl;
		outputfile << "R_SOI: " << r_SOI << endl;
		outputfile << "Reference Epoch (MJD): " << reference_epoch << endl;
		outputfile << "SMA (km): " << SMA << endl;
		outputfile << "ECC: " << ECC << endl;
		outputfile << "INC (deg): " << INC * 180.0 / EMTG::math::PI << endl;
		outputfile << "RAAN (deg): " << RAAN * 180.0 / EMTG::math::PI << endl;
		outputfile << "AOP (deg): " << AOP * 180.0 / EMTG::math::PI << endl;
		outputfile << "MA (deg): " << MA * 180.0 / EMTG::math::PI << endl;
		outputfile << endl;

		outputfile.close();
	}
Пример #10
0
static void debug_args(const char* message, std::va_list ap, debug_message_type debug)
{
  char buf[1024];
  std::string output_string;
  std::stringstream ss;
  bool should_output = false;

  vsnprintf(buf ,1024, message, ap);

  switch(debug)
  {
  case(DEBUG_INFO):
    ss << date_time_string() << ": Information : " << buf;
    output_string = ss.str();
    if(Configuration::show_info_messages)
      should_output = true;
    break;
  case(DEBUG_WARN):
    ss << date_time_string() << ": Warning : " << buf;
    output_string = ss.str();
    if(Configuration::show_warn_messages)
      should_output = true;
    break;
  case(DEBUG_FATAL):
    ss << date_time_string() << ": Fatal : " << buf;
    output_string = ss.str();
    should_output = true;
    break;
  }

  if(should_output)
  {
    if(!log_started)
    {
      // This will reset the file if this is the first write this session
      std::ofstream temp(Configuration::logfile.c_str());
      log_started = true;
      temp.close();
    }

    std::ofstream outputfile(Configuration::logfile.c_str(), std::ios_base::app);

    if(Configuration::debug_stdout)
    {
      std::cout << output_string << std::endl;
    }

    if(Configuration::debug_fileout)
    {
      if(outputfile)
      {
	outputfile << output_string << std::endl;
      }
    }

    outputfile.close();
  }
}
Пример #11
0
void WriteBufferToFile(_In_ std::wstring path, _In_ std::vector<uint8_t>& buffer)
{
    std::ofstream outputfile(path,std::ios_base::binary);
    if (outputfile.is_open())
    {
        outputfile.write(reinterpret_cast<char*>(buffer.data()), buffer.size());
        outputfile.close();
    }
}
Пример #12
0
void process( const QString inputfilename, const QString outputfilename) {
    const QString result = process(inputfilename);
    QFile outputfile(outputfilename);
    if (!outputfile.open(QIODevice::WriteOnly)) {
        throw Exception(u("Unable to open output file \"%1\" for writing!").arg(outputfilename));
    }
    QTextStream stream(&outputfile);
    stream << result;
}
void generateNewsReport()
{
    char sentence[30000],sentence2[3000],source[500];
    int i,j,k,foundtag;

    std::ifstream file(newsname);
    std::ofstream outputfile(newsreportname);
    while(!file.eof())
    {
        file.getline(sentence,29999,'^');
        file.getline(source,499,'^');
        if(file.eof())
            break;
        outputfile<<source;
        outputfile<<"^\n";
        i=0;
        while(sentence[i]!='\0')
        {
            int flag=0;
            for(j=0;sentence[i]!='.'&&sentence[i]!='\0';i++)
            {
                flag=1;
                sentence2[j++]=sentence[i];
            }
            if(flag)
            {
                sentence2[j++]='.';
                sentence2[j++]='\n';
                sentence2[j]='\0';
                foundtag=0;
                if(getLengthNoStopWords(sentence2)>2)
                {
                    for(k=0;k<tagcount;k++)
                    {
                        if(strstr(sentence2,tags[k]))
                            foundtag++;
                    }
                    if(foundtag)
                    {
                        if(sentence2[0]=='\n'||sentence2[0]==' ')
                            outputfile<<(sentence2+1);
                        else
                            outputfile<<sentence2;
                    }
                }
            }
            if(sentence[i]=='\0'||sentence[i+1]=='\0')
                break;
            i++;
        }
        outputfile<<"\n^";
    }
    file.close();
    outputfile.close();
}
Пример #14
0
 void PDBtoCG::output(const std::string& outfile)
 {
     std::ofstream outputfile(outfile);
     int counter(1);
     for(auto iter = cg_style_chain.begin(); iter != cg_style_chain.end();
         ++iter)
     {
         (*iter)->write_block(outputfile, counter);
         ++counter;
     }
     return;
 }
Пример #15
0
int main(int argc, char** argv) 
{   
    std::ifstream inputfile (SOURCE_DIR "/input.txt");
    std::ofstream outputfile (SOURCE_DIR "/output.txt");
    if (openFiles(inputfile,outputfile)) {
        task1p3(inputfile,outputfile);
        inputfile.close();
        outputfile.close();
    } else {
        std::cout << "fail" << std::endl;
    }
    
    return 0;
}
void cleanNewsReport()
{
    char source[1000],sentence[3000],newsreporttemp[50];
    int k,foundtag,flag=0;

    strcpy(newsreporttemp,cwd);
    strcat(newsreporttemp,"\\");
    strcat(newsreporttemp,name);
    strcat(newsreporttemp,"\\");
    strcat(newsreporttemp,"temp.txt");

    //generate file with single sentence
    std::ifstream file(newsreportname);
    std::ofstream outputfile(newsreporttemp);
    while(!file.eof())
    {
        file.getline(sentence,2999);
        if(sentence[strlen(sentence)-1]=='^')
        {
            outputfile<<sentence;
            outputfile<<"\n";
            continue;
        }
        strcat(sentence,"\n");
        if(strlen(sentence)>3)
        {
            foundtag=0;
            if(getLengthNoStopWords(sentence)>2)
            {
                for(k=0;k<tagcount;k++)
                {
                    if(strstr(sentence,tags[k]))
                        foundtag++;
                }
                if(foundtag)
                {
                    if(sentence[0]=='\n'||sentence[0]==' ')
                        outputfile<<(sentence+1);
                    else
                        outputfile<<sentence;
                }
            }
        }
    }
    file.close();
    outputfile.close();
    remove(newsreportname);
    rename(newsreporttemp,newsreportname);
}
Пример #17
0
int main()
{
    std::ofstream outputfile("outputScalar.txt");
    std::vector<long long int> vec1, vec2;
    std::string fileName;
    int cases = 0;
    int cnt = 1;
    int vecLength = 0;
    long long int numb = 0;

    std::cout << "Enter Input File Name: ";
    getline(std::cin,fileName);

    std::ifstream streamIn;
    streamIn.open(fileName);

    if(!streamIn)
    {
        std::cout << "Error Opening File.\n";
        return -1;
    }

    streamIn >> cases;
    streamIn.ignore();

    while(!streamIn.fail() && cnt != cases+1)
    {
        streamIn >> vecLength;
        streamIn.ignore();
        for(int i = 0; i < vecLength; ++i)
        {
            streamIn >> numb;
            vec1.push_back(numb);
        }
        streamIn.ignore();
        for(int i = 0; i < vecLength; ++i)
        {
            streamIn >> numb;
            vec2.push_back(numb);
        }
        outputfile << "Case #" << cnt << ": " << findSmallestScalarProduct(vec1,vec2) << "\n";
        vec1.clear();
        vec2.clear();
        streamIn.ignore();
        ++cnt;
    }

    return 0;
}
Пример #18
0
int main(void) {
	int i;
	static char congress[272];

	if (!(finput = fopen("congress.txt", "r"))) {
		printf("Error: Cannot open file for input.");
		exit(-1);
	}

	processFile(congress);
	cipher(1, congress);
	outputfile(congress);
	return(0);

}
Пример #19
0
int main(int argc, const char * argv [] )
{
 std::ifstream inputfile  ( argv[1] );
 std::ofstream outputfile ( argv[2] );

 typedef std::istream_iterator< std::string > istritr;
 typedef std::ostream_iterator< std::string > ostritr;

 std::set< std::string >
         words( (istritr(inputfile)), istritr() );

 std::copy( words.begin(), words.end(),
            (ostritr( outputfile, "\n" )));

 return !inputfile.eof() || !outputfile;
}
//Go through each bunny in list and print the information to console and file
void BunnyWorld::printBunnies()
{
    //point to first bunny
    Bunny* tracker = m_first->m_next;
    //go through list until nullptr pointer reached and print information about each bunny
    while (tracker!=nullptr){
        printBunny(tracker);
        tracker = tracker->m_next;
    }
    std::ofstream outputfile ("population.txt" , std::ios::app);
    //print info to console
    std::cout << "Population: " << m_population << " Radioactive population: " << m_radioactivePopulation << '\n';
    //print info to file
    outputfile << "Population: " << m_population << " Radioactive population: " << m_radioactivePopulation << '\n';
    outputfile.close();
}
Пример #21
0
void MAJ::OndownloadAndInstallBtClick(wxCommandEvent& event)
{
    //Warn the user his work can be lost
    if ( wxMessageBox(_("GDevelop will be closed at the end of the download so as to install the new version. Don't forget to save your work.\nDownload and install the new version \?"), _("Installation of the new version"), wxYES_NO | wxICON_QUESTION, this) == wxNO )
        return;

    wxString tempDir = wxFileName::GetHomeDir()+"/.GDevelop";

    //Open connection to file
    wxHTTP http;
    wxURL *url = new wxURL(_T("http://www.compilgames.net/dl/gd.exe"));
    wxInputStream * input = url->GetInputStream();

    if (input!=NULL) {
        unsigned int current_progress = 0;
        char buffer[1024];

        wxProgressDialog progress(_("Download"),_("Progress"),(int)input->GetSize(), NULL, wxPD_CAN_ABORT | wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
        wxFileOutputStream outputfile(tempDir+"/newgd.exe");
        while(!input->Eof() && current_progress!=input->GetSize()) { //Download part as long we haven't reached the end
            input->Read((void *)buffer,1024);
            outputfile.Write((const void *)buffer,input->LastRead());
            current_progress+=input->LastRead();
            if ( !progress.Update(current_progress) ) //Enable the user to stop downloading
            {
                if ( wxMessageBox(_("Stop the download \?\n\nYou can also get the new version by downloading it on our website."), _("Stop the download"), wxYES_NO | wxICON_QUESTION, this) == wxYES )
                {
                    wxRemoveFile(tempDir+"/newgd.exe");
                    return;
                }
                else
                    progress.Resume();
            }
        }

        delete input;
    }
    else
    {
        gd::LogWarning( _( "Unable to connect to the server so as to check for updates.\nCheck :\n-Your internet connection\n-Your firewall-If you can manually access  our site.\n\nYou can disable Check for updates in the preferences of GDevelop." ) );
        return;
    }

    wxExecute(tempDir+"/newgd.exe /SILENT /LANG="+gd::LocaleManager::Get()->locale->GetLocale(), wxEXEC_ASYNC);
    EndModal(2);
}
int main(const int argc, const char* const argv[]) {

  if (argc != 2) {
    std::cerr << err << "Exactly one input is required,\n"
      " the name of the file with the clause-set in DIMACS-format.\n"
      "However, the actual number of input parameters was " << argc-1 << ".\n";
    return error_parameters;
  }

  const std::string shg_input_filepath = argv[1];
  std::ifstream shg_inputfile(shg_input_filepath.c_str());
  if (not shg_inputfile) {
    std::cerr << err << "Failure opening input file " << shg_input_filepath << ".\n";
    return error_openfile;
  }

  typedef OKlib::InputOutput::RawDimacsCLSAdaptor<> CLSAdaptor;
  CLSAdaptor cls_F;
  typedef OKlib::InputOutput::StandardDIMACSInput<CLSAdaptor> CLSInput;
  const CLSInput input_F(shg_inputfile, cls_F);
  shg_inputfile.close();

  // Compute the prime clauses:
  typedef OKlib::Satisfiability::FiniteFunctions::QuineMcCluskey<num_vars>::clause_set_type clause_set_type;
  const clause_set_type prime_imp_F = OKlib::Satisfiability::FiniteFunctions::quine_mccluskey<num_vars>(cls_F.clause_set);

  // Compute the subsumption hypergraph:
  typedef OKlib::SetAlgorithms::Subsumption_hypergraph<clause_set_type, CLSAdaptor::clause_set_type>::set_system_type subsumption_hg_type;
  subsumption_hg_type subsumption_hg = 
    OKlib::SetAlgorithms::subsumption_hypergraph(prime_imp_F, cls_F.clause_set);
  std::sort(subsumption_hg.begin(), subsumption_hg.end());
  subsumption_hg.erase(std::unique(subsumption_hg.begin(), subsumption_hg.end()), subsumption_hg.end());

  // Output:
  const std::string comment1("Subsumption hypergraph for the minimisation problem for " + shg_input_filepath);
  OKlib::InputOutput::List2DIMACSOutput(subsumption_hg,std::cout,comment1.c_str());
  // Output of prime clauses if needed:
  const std::string primes_output_filepath = boost::filesystem::path(shg_input_filepath).filename().string() + "_primes";
  std::ofstream outputfile(primes_output_filepath.c_str());
  if (not outputfile) {
    std::cerr << err << "Failure opening output file " << primes_output_filepath << ".\n";
    return error_openfile;
  }
  const std::string comment2("All prime implicates for " + shg_input_filepath);
  OKlib::InputOutput::List2DIMACSOutput(prime_imp_F,outputfile,comment2.c_str());
}
Пример #23
0
int main (int argc, char ** argv) 
{
  TChain * albero = new TChain ("makeNtple/OniaTree") ;
  string filename(argv[1]);
  filename += "*.root" ;
  albero -> Add(filename.c_str());
  std::cout << "al : " << albero->GetEntries () << std::endl ;

  string outputfile(argv[2]);
  outputfile += ".root" ;
  TFile *f1 = new TFile(outputfile.c_str(),"RECREATE");  

  EleEleLooper analyzer(albero);
  analyzer.Loop(filename);
  analyzer.saveHistos(f1);
  delete albero;

  return 0;
}
Пример #24
0
int main (int argc, char ** argv) 
{
  /*
  char inputFileName[150];
  if ( argc < 2 ){
    std::cout << "missing argument: insert inputFile with list of root files" << std::endl; 
    return 1;
  }

  TChain *theChain = new TChain("OniaTree");

  TList *treelist = new TList();

  for(int i=1;i<argc;i++){

    string filename(argv[i]);
    filename += "/makeNtple";

    cout << "Adding " << filename.c_str() << endl;

    theChain->Add(filename.c_str());
  }

  cout << "Total number of entries" << theChain->GetEntries() << endl;
  */
  
  TChain * albero = new TChain ("makeNtple/OniaTree") ;
  string filename(argv[1]);
  filename += "*.root" ;
  albero -> Add(filename.c_str());
  std::cout << "al : " << albero->GetEntries () << std::endl ;

  string outputfile(argv[2]);
  outputfile += ".root" ;
  TFile *f1 = new TFile(outputfile.c_str(),"RECREATE");  

  MuMuLooper analyzer(albero);
  analyzer.Loop(filename);
  analyzer.saveHistos(f1);
  delete albero;

  return 0;
}
Пример #25
0
int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);
    if(app.arguments().count() < 3) {
        std::cerr<<"Insufficient arguments.\n"
                 <<"Usage:\n"
                 <<"./kdictionary-lingoes <LD2/LDX FILE> <OUTPUT FILE>\n"<<std::endl;
        exit(1);
    }

    QFileInfo ld2FileInfo(app.arguments().at(1));
    if (!ld2FileInfo.exists()) {
        std::cerr<<"Error: Input file doesn't exist."<<std::endl;
        exit(2);
    }

    QString ld2file = ld2FileInfo.canonicalFilePath();
    QString outputfile(app.arguments().at(2));
    kdictionary_lingoes foo(ld2file);
    foo.main(outputfile);
}
Пример #26
0
int main () {
  // file to write
  ofstream outputfile("tracking.csv");

  //make instance
  double m_dt=0.001;
  interpolator* i = new interpolator(1, m_dt,interpolator::HOFFARBIB,0.5);

  double start=0.0,goal=1.0,goalv=0;
  double test_time=10;
  double t=0;
  double x=0,v=0,a=0;
  double rt;

  //i->load("data.csv");
  i->set(&start);

  for (int j=0;j<test_time/m_dt;j++){
    // set goal
    double target,c_target;
    double interpolation_time;
    double interpolation_gain=10;
    double Kp=0.1;
    target=target_pos(t);
    c_target=Kp*(target-x) +x;
    interpolation_time= 0.1;//interpolation_gain*fabs(x-target);
    //std::cout << fabs(x-target) << std::endl;
    // std::cout << interpolation_time << std::endl;

    i->setGoal(&c_target, interpolation_time, true);
    // get interpolation val
    if (i->isEmpty()) std::cout << "empty!" << std::endl;
    i->get(&x,&v,&a,true);
    outputfile << t << " " << x << " " << v << " "<< a << " " << target <<std::endl;
    t+=i->deltaT();
  }
  outputfile.close();
  return 0;
};
Пример #27
0
int main (int argc, char ** argv) 
{
  TChain * albero = new TChain ("SimpleNtple/SimpleTree") ;
  string filename(argv[1]);
  filename += "*.root" ;
  albero -> Add(filename.c_str());
  std::cout << "al : " << albero->GetEntries () << std::endl ;

  int entries = 1E8 ;
  if ( argc > 3 ) entries = 10000 ; 

  string outputfile(argv[2]);
  outputfile += ".root" ;
  TFile *f1 = new TFile(outputfile.c_str(),"RECREATE");  

  MakeEleReducedTree analyzer(albero);
  analyzer.Loop(entries);
  analyzer.saveTree(f1);
  delete albero;

  return 0;
}
Пример #28
0
int
getlocal(char *filename, char *range)
{
	struct stat	buf;

	if (stat(filename, &buf) == 0) {

#ifdef	DEBUG
		logmsg("getlocal:file (%s)\n", filename);
#endif

		status = HTTP_OK;

		if (outputfile(filename, range) != 0) {
			logmsg("outputfile():failed:(%d)\n", errno);
			return(-1);
		}
	} else {
		return(-1);
	}

	return(0);
}
Пример #29
0
int main(int argc, char ** argv)
{
	double start,end,duration; 
	start = clock();
    double alpha = 0.013;  //经测试这个值比较好
    double beta = 0.001;   //经过测试这个也还行
    int dim = 100;//atoi(argv[1]);
    test_level = 1;//atoi(argv[2]);
    ofstream outputfile("parameter.txt");
    
    //for(int i=0; i < 10; i++)
    {
    //	beta = i*0.001 + 0.002;
    //	cout << beta << endl;
    	svd::model(dim,alpha,beta);
    	
    }
    outputfile.close();
    end = clock();
    duration = (end-start)/CLOCKS_PER_SEC;
    cout << "duration:"<<duration <<" s!" <<endl;
    return 0;
}
Пример #30
0
int main(int argc, char ** argv)
{
	float start,end,duration; 
	start = clock();
    float alpha = 0.003;  //0.0045according to the paper of "a guide to SVD for CF"
    float beta = 0.05;   //0.015 according to the paper of "a guide to SVD for CF"
    					   //0.0005 according the experiment
    int dim = 100;//atoi(argv[1]);
    test_level = 1;//atoi(argv[2]);
    ofstream outputfile("parameter.txt");
    
    //for(int i=0; i < 10; i++)
    {
    	//alpha = i*0.0005 + 0.0025;
    	//cout << alpha << endl;
    	svd::model(dim,alpha,beta);	
    }
    outputfile.close();
    end = clock();
    duration = (end-start)/CLOCKS_PER_SEC;
    cout << "duration:"<<duration <<" s!" <<endl;
    return 0;
}