Exemplo n.º 1
0
int main() {  
  // print seed
  std::cout << "Random seed: " << rd.get_seed() << std::endl;

  // options
  CGAL::Quadratic_program_options options;
  options.set_auto_validation(true);

  // generate a set of small random qp's
  for (int i=0; i<tries; ++i) {
    // first choose dimensions
    int n = rd.get_int(1,max_dim);
    int m = rd.get_int(1,max_dim);

    // construct matrix D as C^T C, for C randomly chosen with n columns
    int k = rd.get_int (1, 2*n); // number of rows of C
    std::vector<std::vector<int> > C (k, std::vector<int>(n, 0));
    for (int j=0; j<k+n; ++j)  // sparse C
      C[rd.get_int(0, k)][rd.get_int(0,n)] = 
	rd.get_int(-max_entry, max_entry);

    // now fill the program 
    Program p;
    // A
    for (int j=0; j<n+m; ++j)
      p.set_a (rd.get_int(0,n), rd.get_int(0,m), rd.get_double());
    // b, r
    for (int i=0; i<m/2; ++i) {
      p.set_b (rd.get_int(0,m), rd.get_double());
      p.set_r (rd.get_int(0,m), random_rel());
    }
    // fl, l, fu, u
    for (int j=0; j<n; ++j) {
      double l = rd.get_double();
      double u = rd.get_double();
      if (l > u) std::swap (l, u); 
      p.set_l(j, rd.get_bool(), l);
      p.set_u(j, rd.get_bool(), u);
    }
    // D
    for (int i=0; i<n; ++i)
      for (int j=0; j<=i; ++j) {
	double entry = 0;
	for (int l=0; l<k; ++l) 
	  entry += C[l][i] * C[l][j];
	p.set_d(i, j, entry);
      }
    // c
    for (int j=0; j<n/2; ++j)
      p.set_c (rd.get_int(0, n), rd.get_double());
    // c0
    p.set_c0(rd.get_double());
    
    // solve it
    Solution s = CGAL::solve_quadratic_program (p, ET(), options);
    assert(s.is_valid());
    statistics (s, qp_optimal, qp_infeasible, qp_unbounded);

    // also solve it as nqp, lp, nlp
    s = CGAL::solve_nonnegative_quadratic_program (p, ET(), options); 
    assert(s.is_valid());
    statistics (s, nqp_optimal, nqp_infeasible, nqp_unbounded);
    s = CGAL::solve_linear_program (p, ET(), options);    
    assert(s.is_valid()); 
    statistics (s, lp_optimal, lp_infeasible, lp_unbounded);
    s = CGAL::solve_nonnegative_linear_program (p, ET(), options);   
    assert(s.is_valid());  
    statistics (s, nlp_optimal, nlp_infeasible, nlp_unbounded);
  }
  
  // output statistics
  std::cout << "Solved " << tries 
	    << " random QP / NQP  / LP / NLP .\n"
	    << " Optimal:    " 
	    << qp_optimal << " / " 
	    << nqp_optimal << " / " 
	    << lp_optimal << " / " 
	    << nlp_optimal << "\n"
	    << " Infeasible: "
	    << qp_infeasible << " / " 
	    << nqp_infeasible << " / " 
	    << lp_infeasible << " / " 
	    << nlp_infeasible << "\n"
	    << " Unbounded:  "
	    << qp_unbounded << " / " 
	    << nqp_unbounded << " / " 
	    << lp_unbounded << " / " 
	    << nlp_unbounded << std::endl;

  return 0;
}
Exemplo n.º 2
0
return ___2039; } ___372 FileStreamWriter::close(bool ___3361) { return m_fileIOStream.close(___3361); } ___1393 FileStreamWriter::fileLoc() { REQUIRE(___2041()); return m_fileIOStream.fileLoc(); } ___372 FileStreamWriter::___3460() { REQUIRE(___2041()); return m_fileIOStream.___3460(); } ___372 FileStreamWriter::___3459(___1393 fileLoc) { REQUIRE(___2041()); REQUIRE(fileLoc != ___330); return m_fileIOStream.___3459(fileLoc); } ___372 FileStreamWriter::seekToFileEnd() { REQUIRE(___2041()); return m_fileIOStream.seekToFileEnd(); } std::string const& FileStreamWriter::___1394() const { return m_fileIOStream.___1394(); } void FileStreamWriter::___3494(___372 ___2002) { REQUIRE(VALID_BOOLEAN(___2002)); m_fileIOStream.___3494(___2002); } ___372 FileStreamWriter::___2002() const { return m_fileIOStream.___2002(); } void FileStreamWriter::setDataFileType(DataFileType_e ___844) { REQUIRE(VALID_ENUM(___844, DataFileType_e)); m_fileIOStream.setDataFileType(___844); } DataFileType_e FileStreamWriter::___844() const { return m_fileIOStream.___844(); } class FileIOStatistics& FileStreamWriter::statistics() { return m_fileIOStream.statistics(); } size_t FileStreamWriter::fwrite(void const* ___416, size_t size, size_t count) { REQUIRE(___2041()); REQUIRE(VALID_REF(___416)); size_t ___3358 = ::fwrite(___416, size, count, m_fileIOStream.handle());
 #ifdef PROFILE_FILE_ACCESS
if ( ___3358 > 0 ) { statistics().numReadWritesPerformed++; statistics().___2780 += ___3358*size; }
 #endif
return ___3358; } int FileStreamWriter::fprintf(char const* format, ...) { REQUIRE(___2041()); REQUIRE(VALID_NON_ZERO_LEN_STR(format)); va_list args; va_start(args, format); int ___3358 = ::vfprintf(m_fileIOStream.handle(), format, args); va_end (args);
Exemplo n.º 3
0
return ___3358; } int FileStreamWriter::fprintf(char const* format, ...) { REQUIRE(___2041()); REQUIRE(VALID_NON_ZERO_LEN_STR(format)); va_list args; va_start(args, format); int ___3358 = ::vfprintf(m_fileIOStream.handle(), format, args); va_end (args);
 #ifdef PROFILE_FILE_ACCESS
if (___3358 > 0) { statistics().numReadWritesPerformed++; statistics().___2780 += ___3358; }
 #endif
return ___3358; } }}
Exemplo n.º 4
0
void aig_prop_solvert::usage_count(std::vector<unsigned> &p_usage_count, std::vector<unsigned> &n_usage_count) {

  for (constraintst::const_iterator
      c_it=constraints.begin();
      c_it!=constraints.end();
       c_it++) {
    if (!((*c_it).is_constant())) {

      if ((*c_it).sign()) {
	++n_usage_count[(*c_it).var_no()];
      } else {
	++p_usage_count[(*c_it).var_no()];
      }

    }
  }

  for (unsigned n=0; n<aig.nodes.size(); n++) {
    const aigt::nodet &node=aig.nodes[n];

    if (node.is_and()) {
      if (node.a.sign()) {
	++n_usage_count[node.a.var_no()];
      } else {
	++p_usage_count[node.a.var_no()];
      }

      if (node.b.sign()) {
	++n_usage_count[node.b.var_no()];
      } else {
	++p_usage_count[node.b.var_no()];
      }

    }
  }


  #if 1
  // Compute stats
  unsigned unused = 0;
  unsigned usedOncePositive = 0;
  unsigned usedOnceNegative = 0;
  unsigned usedTwicePositive = 0;
  unsigned usedTwiceNegative = 0;
  unsigned usedTwiceMixed = 0;
  unsigned usedThreeTimes = 0;
  unsigned usedMore = 0;

  for (unsigned n=0; n<aig.nodes.size(); n++) {
    switch (p_usage_count[n] + n_usage_count[n]) {
    case 0 : ++unused; break;
    case 1 :
      if (p_usage_count[n] == 1) {
	++usedOncePositive;
      } else {
	++usedOnceNegative;
      }
      break;

    case 2 :
      if (p_usage_count[n] >= 2) {
	++usedTwicePositive;

      } else if (n_usage_count[n] >= 2) {
	++usedTwiceNegative;

      } else {
	assert(p_usage_count[n] == 1 && n_usage_count[n] == 1);
	++usedTwiceMixed;

      }
      break;
    case 3 : ++usedThreeTimes; break;
    default : ++usedMore; break;
    }
  }

  statistics() << "Unused: " << unused << " "
	       << "Used once: " << usedOncePositive + usedOnceNegative
	       << " (P: " << usedOncePositive
               << ", N: " << usedOnceNegative << ") "
	       << "Used twice: " << usedTwicePositive + usedTwiceNegative + usedTwiceMixed
               << " (P: " << usedTwicePositive
               << ", N: " << usedTwiceNegative
               << ", M: " << usedTwiceMixed << ") "
	       << "Used three times: " << usedThreeTimes << " "
	       << "Used more: " << usedMore
	       << eom;
  #endif
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
	struct thread_data *threads;
	struct thread_data *thread;
	int i, ret, ch;

	if (argc > 1)
	{
		if (strcmp(argv[1], "--help") == 0)
		{
			usage_error(argv[0]);
		}
		init_program_parameter(argc, argv);
	}

	program_parameter(argv[0]);

	create_matrix(&matrix_a);
	create_matrix(&matrix_b);
	create_matrix(&matrix_c);
	create_matrix(&matrix_d);
	random_matrix(matrix_a);
	random_matrix(matrix_b);

	nonmal_matrix_multipy(matrix_a, matrix_b, matrix_d);

	threads = (struct thread_data *)malloc(pthread_max * sizeof(struct thread_data));
	if (threads == NULL)
	{
		unix_error("malloc threads failed");
	}

	cpu_online = sysconf(_SC_NPROCESSORS_CONF);

	for(i = 0; i < pthread_max; i++)
	{
		thread = threads + i;
		thread->index = i;
		if ((ret = pthread_create(&thread->thread_id, NULL, thread_func, thread)) != 0)
		{
			posix_error(ret, "pthread_create failed");
		}
	}

	for(i = 0; i < pthread_max; i++)
	{
		thread = threads + i;
		if ((ret = pthread_join(thread->thread_id, NULL)) != 0)
		{
			posix_error(ret, "pthread_join failed");
		}
	}

	if (matrix_equal(matrix_c, matrix_d) == 0)
	{
		unix_error("runtime error");
	}
	if (dump)
	{
		dump_matrix("matrix A", matrix_a);
		dump_matrix("matrix B", matrix_b);
		dump_matrix("matrix C", matrix_c);
		dump_matrix("matrix D", matrix_d);
	}
	statistics(threads);

	free_matrix(matrix_a);
	free_matrix(matrix_b);
	free_matrix(matrix_c);
	free_matrix(matrix_d);
	free(threads);
	return 0;
}
Exemplo n.º 6
0
//aux to call stats functions
void statistics(char stat)
{
    if(stopApp==1)main();
    char tmp[1024]= {0x0};
    int fldcnt=0;
    char arr[MAXFLDS][MAXFLDSIZE]= {0x0};
    int recordcnt=0;

    if(stat=='a') strcpy(filename,"");

    if (!strcmp(filename,""))
    {
        printf("Enter key [d] to assume defaults [logcsv.csv],\n");
        printf("or insert the name of the CSV file [file.csv]: ");
        scanf("%s", filename);
    }
    if (!strcmp(filename,"d"))
        strcpy(filename,"logcsv.csv");

    in = fopen(filename,"r");/* open file on command line */

    if(checkFileIn()==-1)
    {
        optionSaveStats='3';
        printf("Error loading file...[%s]\n\n", filename);
        statistics('a');
    }
    if(checkFileIn()==0)
    {
        if(stat=='a')printf("Loading file...[%s]\n\n", filename);
        fgets(tmp,sizeof(tmp),in); /*jump over header*/
        while(fgets(tmp,sizeof(tmp),in)!=0) /* read a record */
        {
            i=0;
            j=0;
            recordcnt++;
            parse(tmp,",",arr,&fldcnt);    /* whack record into fields */
            for(i; i<fldcnt; i++)
            {
                //copy all records to strs
                strcpy(strs[recordcnt-1][i],arr[i]);
            }

        }
        if(stat=='a')printf("Done!!!\n", filename);
        if(stat=='a')PressEnterToReturn();
    }

    if (stat=='b') {
        system("clear");
        print_all_macip(recordcnt, 2,"Source devices:\n"); //list of all source devices - print mac and ip
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='c') {
        system("clear");
        print_all(recordcnt, 8, "Source ports:\n"); //list of all source ports
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='d') {
        system("clear");
        print_all_macip(recordcnt, 3,"\nDestination devices:\n"); //list of all destination devices - print mac and ip
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='e') {
        system("clear");
        print_all(recordcnt, 9, "Destination ports:\n"); //list of all destination ports
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='f') {
        system("clear");
        rep_count(recordcnt, 12, "0", "\nNº of Queries: "); //count number of queries, verifying the flag response=o
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='g') {
        system("clear");
        rep_count(recordcnt, 12, "1", "\nNº of Responses: "); //count number of responses, verifying the flag response=1
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='h') {
        system("clear");
        rep_count(recordcnt, 13, "3", "\nNº of Rcodes: "); //count number of Rcodes errors
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='i') {
        system("clear");
        check_times(recordcnt, 10); //verify delay between question and answer
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='j') {
        system("clear");
        print_all_stats(recordcnt, 2, "\nMAC source:"); //stats MAC Source
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='k') {
        system("clear");
        print_all_stats(recordcnt, 3, "\nMAC destination:");//stats MAC destination
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='l') {
        system("clear");
        print_all_stats(recordcnt, 18, "\nNames:");//stats Name
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='m') {
        system("clear");
        string keyword;
        printf("Insert the keyword to search in all queries: ");
        scanf("%s", keyword);
        count_occurrences(recordcnt, 18, "\nThe selected keyword:", keyword);
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }
    if (stat=='n') {
        system("clear");
        check_blacklisted(recordcnt, 21, "\nCheck queries responses:\n");//Check queries responses
        PressEnterToReturn();
        fclose(in);
        optionSaveStats='3';
        system("clear");
        statsMenu();
    }

    statsMenu();
}
Exemplo n.º 7
0
int main() {
  // print seed
  std::cout << "Random seed: " << rd.get_seed() << std::endl;

  // options
  CGAL::Quadratic_program_options options;
  options.set_auto_validation(true);

  // generate a set of small random qp's
  for (int i=0; i<tries; ++i) {
    int  Ax[] = {random_signed(), random_signed()};         
    int  Ay[] = {random_signed(), random_signed()};         
    int*  A[] = {Ax, Ay};                       
    int   b[] = {random_signed(), random_signed()};         
    CGAL::Comparison_result
      r[] = {random_rel(), random_rel()};
    bool fl[] = {rd.get_bool(), rd.get_bool()};                   
    int   l[] = {random_signed(),random_signed()};
    bool fu[] = {rd.get_bool(), rd.get_bool()};               
    int   u[] = {random_signed(),random_signed()};   
    // make sure that l<=u
    if (l[0] > u[0]) {int h = l[0]; l[0] = u[0]; u[0] = h;}
    if (l[1] > u[1]) {int h = l[1]; l[1] = u[1]; u[1] = h;}
    int  D1[] = {random_unsigned()};                    
    int  D2[] = {0, random_unsigned()};
    // can still change D_21 as long as D remains positive-semidefinite
    if (D1[0] < D2[1]) 
      D2[0] = rd.get_int(-D1[0], D1[0]+1);
    else
      D2[0] = rd.get_int(-D2[1], D2[1]+1);
    assert(D1[0] * D2[1] >= D2[0] * D2[0]);  
    int*  D[] = {D1, D2};                      
    int   c[] = {random_signed(), random_signed()};
    int  c0   = random_signed();                     

    // now construct the quadratic program; the first two parameters are
    // the number of variables and the number of constraints (rows of A)
    Program qp (2, 2, A, b, r, fl, l, fu, u, D, c, c0);

    // write/read it and check equality
    std::stringstream inout;
    CGAL::print_quadratic_program (inout, qp);
    CGAL::Quadratic_program_from_mps<int> qp2 (inout);
    assert(CGAL::QP_functions_detail::are_equal_qp (qp, qp2));
  
    // solve it
    Solution s = CGAL::solve_quadratic_program (qp, ET(), options);
    assert(s.is_valid());
    statistics (s, qp_optimal, qp_infeasible, qp_unbounded);

    // also solve it as nqp, lp, nlp
    s = CGAL::solve_nonnegative_quadratic_program (qp, ET(), options); 
    assert(s.is_valid());
    statistics (s, nqp_optimal, nqp_infeasible, nqp_unbounded);
    s = CGAL::solve_linear_program (qp, ET(), options);    
    assert(s.is_valid()); 
    statistics (s, lp_optimal, lp_infeasible, lp_unbounded);
    s = CGAL::solve_nonnegative_linear_program (qp, ET(), options);   
    assert(s.is_valid());  
    statistics (s, nlp_optimal, nlp_infeasible, nlp_unbounded);
  }
  
  // output statistics
  std::cout << "Solved " << tries 
	    << " random QP / NQP  / LP / NLP .\n"
	    << " Optimal:    " 
	    << qp_optimal << " / " 
	    << nqp_optimal << " / " 
	    << lp_optimal << " / " 
	    << nlp_optimal << "\n"
	    << " Infeasible: "
	    << qp_infeasible << " / " 
	    << nqp_infeasible << " / " 
	    << lp_infeasible << " / " 
	    << nlp_infeasible << "\n"
	    << " Unbounded:  "
	    << qp_unbounded << " / " 
	    << nqp_unbounded << " / " 
	    << lp_unbounded << " / " 
	    << nlp_unbounded << std::endl;
  return 0;
}
Exemplo n.º 8
0
namespace tecplot { namespace ___3933 { FileStreamReader::FileStreamReader(std::string const& ___1394) : m_fileIOStream(___1394) { } FileStreamReader::~FileStreamReader() { m_fileIOStream.close(true); } ___372 FileStreamReader::___2041() const { return m_fileIOStream.___2041(); } ___372 FileStreamReader::open() { REQUIRE(!___2041()); ___372 ___2039 = m_fileIOStream.open("rb"); if (!___2039) ___1186("Cannot read file %s", ___1394().c_str());
 #ifdef PROFILE_FILE_ACCESS
___478(statistics().numFSeeksPerformed == 0 && statistics().numReadWritesPerformed == 0 && statistics().___2780 == 0);
 #endif
return ___2039; } ___372 FileStreamReader::close(bool ___3361) { return m_fileIOStream.close(___3361); } ___1393 FileStreamReader::fileLoc() { REQUIRE(___2041()); return m_fileIOStream.fileLoc(); } ___372 FileStreamReader::___3460() { REQUIRE(___2041()); return m_fileIOStream.___3460(); } ___372 FileStreamReader::___3459(___1393 fileLoc) { REQUIRE(___2041()); REQUIRE(fileLoc != ___330); return m_fileIOStream.___3459(fileLoc); } ___372 FileStreamReader::seekToFileEnd() { REQUIRE(___2041()); return m_fileIOStream.seekToFileEnd(); } std::string const& FileStreamReader::___1394() const { return m_fileIOStream.___1394(); } void FileStreamReader::___3494(___372 ___2002) { REQUIRE(VALID_BOOLEAN(___2002)); m_fileIOStream.___3494(___2002); } ___372 FileStreamReader::___2002() const { return m_fileIOStream.___2002(); } void FileStreamReader::setDataFileType(DataFileType_e ___844) { REQUIRE(VALID_ENUM(___844, DataFileType_e)); m_fileIOStream.setDataFileType(___844); } DataFileType_e FileStreamReader::___844() const { return m_fileIOStream.___844(); } class FileIOStatistics& FileStreamReader::statistics() { return m_fileIOStream.statistics(); } size_t FileStreamReader::fread(void* ___416, size_t size, size_t count) { REQUIRE(VALID_REF(___416)); REQUIRE(___2041()); size_t ___3358 = ::fread(___416, size, count, m_fileIOStream.handle());
Exemplo n.º 9
0
return ___2039; } ___372 FileStreamReader::close(bool ___3361) { return m_fileIOStream.close(___3361); } ___1393 FileStreamReader::fileLoc() { REQUIRE(___2041()); return m_fileIOStream.fileLoc(); } ___372 FileStreamReader::___3460() { REQUIRE(___2041()); return m_fileIOStream.___3460(); } ___372 FileStreamReader::___3459(___1393 fileLoc) { REQUIRE(___2041()); REQUIRE(fileLoc != ___330); return m_fileIOStream.___3459(fileLoc); } ___372 FileStreamReader::seekToFileEnd() { REQUIRE(___2041()); return m_fileIOStream.seekToFileEnd(); } std::string const& FileStreamReader::___1394() const { return m_fileIOStream.___1394(); } void FileStreamReader::___3494(___372 ___2002) { REQUIRE(VALID_BOOLEAN(___2002)); m_fileIOStream.___3494(___2002); } ___372 FileStreamReader::___2002() const { return m_fileIOStream.___2002(); } void FileStreamReader::setDataFileType(DataFileType_e ___844) { REQUIRE(VALID_ENUM(___844, DataFileType_e)); m_fileIOStream.setDataFileType(___844); } DataFileType_e FileStreamReader::___844() const { return m_fileIOStream.___844(); } class FileIOStatistics& FileStreamReader::statistics() { return m_fileIOStream.statistics(); } size_t FileStreamReader::fread(void* ___416, size_t size, size_t count) { REQUIRE(VALID_REF(___416)); REQUIRE(___2041()); size_t ___3358 = ::fread(___416, size, count, m_fileIOStream.handle());
 #ifdef PROFILE_FILE_ACCESS
if ( ___3358 > 0 ) { statistics().numReadWritesPerformed++; statistics().___2780 += ___3358*size; }
 #endif
return ___3358; } char* FileStreamReader::fgets(char* s, int size) { REQUIRE(VALID_REF(s)); REQUIRE(size >= 0); REQUIRE(___2041()); char* ___3358 = ::fgets(s, size, m_fileIOStream.handle());
Exemplo n.º 10
0
return ___3358; } int FileStreamReader::feof() { REQUIRE(___2041()); return ::feof(m_fileIOStream.handle()); } int FileStreamReader::getc() { REQUIRE(___2041()); int ___3358 = ::getc(m_fileIOStream.handle());
 #ifdef PROFILE_FILE_ACCESS
statistics().numReadWritesPerformed++; statistics().___2780++;
 #endif
return ___3358; } int FileStreamReader::ungetc(int c) { REQUIRE(___2041()); int ___3358 = ::ungetc(c, m_fileIOStream.handle());
Exemplo n.º 11
0
return ___3358; } int FileStreamReader::ungetc(int c) { REQUIRE(___2041()); int ___3358 = ::ungetc(c, m_fileIOStream.handle());
 #ifdef PROFILE_FILE_ACCESS
___478(statistics().___2780>0); statistics().___2780--;
 #endif
return ___3358; } int FileStreamReader::fscanf(char const* format, void* ___3251) { REQUIRE(___2041()); REQUIRE(VALID_NON_ZERO_LEN_STR(format)); REQUIRE(VALID_REF(___3251));
Exemplo n.º 12
0
return ___3358; } char* FileStreamReader::fgets(char* s, int size) { REQUIRE(VALID_REF(s)); REQUIRE(size >= 0); REQUIRE(___2041()); char* ___3358 = ::fgets(s, size, m_fileIOStream.handle());
 #ifdef PROFILE_FILE_ACCESS
if ( ___3358 != NULL ) { statistics().numReadWritesPerformed++; statistics().___2780 += ___3358 ? strlen(s) : 0; }
 #endif
return ___3358; } int FileStreamReader::feof() { REQUIRE(___2041()); return ::feof(m_fileIOStream.handle()); } int FileStreamReader::getc() { REQUIRE(___2041()); int ___3358 = ::getc(m_fileIOStream.handle());
Exemplo n.º 13
0
  void BVH4Statistics::statistics(NodeRef node, const float A, size_t& depth)
  {
    if (node.isNode())
      {
	hash += 0x1234;
	numAlignedNodes++;
	AlignedNode* n = node.node();
	bvhSAH += A*BVH4::travCostAligned;
	depth = 0;
	for (size_t i=0; i<BVH4::N; i++) {
	  if (n->child(i) == BVH4::emptyNode) continue;
	  childrenAlignedNodes++;
	  const float Ai = max(0.0f,halfArea(n->extend(i)));
	  size_t cdepth; statistics(n->child(i),Ai,cdepth); 
	  depth=max(depth,cdepth);
	}
	depth++;
	hash += 0x76767*depth;
      }
    else if (node.isUnalignedNode())
      {
	hash += 0x1232344;
	numUnalignedNodes++;
	UnalignedNode* n = node.unalignedNode();
	bvhSAH += A*BVH4::travCostUnaligned;

	depth = 0;
	for (size_t i=0; i<BVH4::N; i++) {
	  if (n->child(i) == BVH4::emptyNode) continue;
	  childrenUnalignedNodes++;
	  const float Ai = max(0.0f,halfArea(n->extend(i)));
	  size_t cdepth; statistics(n->child(i),Ai,cdepth); 
	  depth=max(depth,cdepth);
	}
	depth++;
	hash += 0x76767*depth;
      }
    else if (node.isNodeMB())
      {
	hash += 0xEF343;
	numAlignedNodesMB++;
	BVH4::NodeMB* n = node.nodeMB();
	bvhSAH += A*BVH4::travCostAligned;

	depth = 0;
	for (size_t i=0; i<BVH4::N; i++) {
	  if (n->child(i) == BVH4::emptyNode) continue;
	  childrenAlignedNodesMB++;
	  const float Ai = max(0.0f,halfArea(n->extend0(i)));
	  size_t cdepth; statistics(n->child(i),Ai,cdepth); 
	  depth=max(depth,cdepth);
	}
	depth++;
	hash += 0x76767*depth;
      }
    else if (node.isUnalignedNodeMB())
      {
	hash += 0x1EEF4;
	numUnalignedNodesMB++;
	BVH4::UnalignedNodeMB* n = node.unalignedNodeMB();
	bvhSAH += A*BVH4::travCostUnaligned;

	depth = 0;
	for (size_t i=0; i<BVH4::N; i++) {
	  if (n->child(i) == BVH4::emptyNode) continue;
	  childrenUnalignedNodesMB++;
	  const float Ai = max(0.0f,halfArea(n->extend0(i)));
	  size_t cdepth; statistics(n->child(i),Ai,cdepth); 
	  depth=max(depth,cdepth);
	}
	depth++;
	hash += 0x76767*depth;
      }
    else
      {
	depth = 0;
	size_t num; const char* tri = node.leaf(num);
	hash += 0xDD776*num+0x878;
	if (!num) return;

	hash += bvh->primTy.hash(tri,num);
      
	numLeaves++;
	numPrims += num;
	float sah = A * BVH4::intCost * num;
	bvhSAH += sah;
      }
  }
LRESULT CProcessorUsageDialog::OnUsageUpdate( UINT /*uMsg*/, 
                                              WPARAM wParam, 
                                              LPARAM lParam, 
                                              BOOL& /*bHandled*/ )
{
    std::auto_ptr< ProcessStatistics > statistics( ( ProcessStatistics* )wParam );
    unsigned int total_used = static_cast< unsigned int >( lParam );

    static short int token = 0;

    LVFINDINFO find = { 0 };
    find.flags = LVFI_STRING;

    process_list_ctrl_.SetRedraw( FALSE );
    
    for( ProcessStatistics::const_iterator it = statistics->begin();
         it != statistics->end();
         ++it )
    {
        // locate the process name in our list view. if it doesn't exist, add it.
        find.psz = it->first.c_str();
        int found = process_list_ctrl_.FindItem( &find, -1 );
        if( found == -1 )
        {
            found = process_list_ctrl_.InsertItem( 0, it->first.c_str() );
        }

        // format the user time and display it in the list view
        std::wstringstream user_time;
        user_time.precision( 1 );
        user_time << std::fixed << it->second.user << L"%";
        process_list_ctrl_.AddItem( found, 1, user_time.str().c_str() );

        // format the kernel time and display it in the list view
        std::wstringstream kernel_time;
        kernel_time.precision( 1 );
        kernel_time << std::fixed << it->second.kernel << L"%";
        process_list_ctrl_.AddItem( found, 2, kernel_time.str().c_str() );

        // mark the item with our token to show that it is still active
        process_list_ctrl_.SetItemData( found, token + 1 );
    }

    // locate all the list view items that were not updated with the new token
    // in this round and remove them - they represent processes that have exited.
    find.flags = LVFI_PARAM;
    find.psz = NULL;
    find.lParam = token;
    int found = -1;
    while( ( found = process_list_ctrl_.FindItem( &find, found ) ) > -1 )
    {
        process_list_ctrl_.DeleteItem( found );
    }
    
    // if the list view has grown longer than 1 page, scroll bars will appear.
    // re-layout the columns to account for that.
    if( process_list_ctrl_.GetItemCount() > process_list_ctrl_.GetCountPerPage() )
    {
        CRect list_rc;
        process_list_ctrl_.GetClientRect( &list_rc );

        process_list_ctrl_.SetColumnWidth( 0, static_cast< int >( list_rc.Width() * 0.5 ) );
        process_list_ctrl_.SetColumnWidth( 1, static_cast< int >( list_rc.Width() * 0.25 ) );
        process_list_ctrl_.SetColumnWidth( 2, LVSCW_AUTOSIZE_USEHEADER );
    }

    process_list_ctrl_.SetRedraw( TRUE );

    /// format & display the number of running processes
    std::wstringstream count_str;
    count_str << statistics->size();
    process_count_.SetWindowText( count_str.str().c_str() );

    /// format & display the total cpu usage
    std::wstringstream usage_str;
    usage_str.precision( 1 );
    usage_str << total_used << L"%";
    cpu_usage_.SetWindowText( usage_str.str().c_str() );

    ++token;
    return 0;
}
Exemplo n.º 15
0
void turnaroundtime(enum priority p, int n, int info) {
  statistics(p, n, info, "total time");
}
Exemplo n.º 16
0
int main(int argc, char **argv) {
	pcap_t *pcap;
	char errbuf[PCAP_ERRBUF_SIZE];
	const u_char *pkt;
	struct pcap_pkthdr hdr;
	struct ether_header *eptr;
	struct ip *ip_hdr;   
	struct tcphdr *tcp_hdr;   
	unsigned long nbp,nbip,nbtcp;
	unsigned long long totalSize;
	flow * flowrec;
	int c,optpkt;
	struct timeval t0,t1;
	uint32_t last_expiration,current_ts;

	// Default Paramaters for the classification
	labeling=clusterport;
	SSL_labeling=SSL_clusterport;
	sslparsing=0;
	threshold=-255;
	action=ACTION_LABEL;
	memory=NOOPTMEM;
	pktlimit=model.nbpackets;
	optpkt=pktlimit;

	stats.nbstats=0;
	bzero(stats.timeidx,sizeof(stats.timeidx));
	bzero(stats.creations,sizeof(stats.creations));
	bzero(stats.deletions,sizeof(stats.deletions));

	nbflows=0;
	last_expiration=0;

	// Parsing options
	while ((c = getopt (argc, argv, "m:hCDPLSt:p:")) != -1)
		switch (c) {
			case 'h':
				usage(argv);
				break;
			case 'P':
				action=ACTION_PARSE;
				break;
			case 'L':
				action=ACTION_LABEL;
				break;
			case 'D':
				labeling=dominant;
				SSL_labeling=dominant;
				break;
			case 'C':
				labeling=clusterport;
				SSL_labeling=SSL_clusterport;
				break;
			case 'm':
				if (atoi(optarg)>=0) {
					memory=atoi(optarg);
					break;
				} else {
					fprintf(stderr,"Invalid Memory option\n");
					usage(argv);
				}
				break;
			case 'S':
				sslparsing=1;
				break;
			case 't':
				if (atoi(optarg)>0) {
					threshold=-atoi(optarg);
					break;
				} else {
					fprintf(stderr,"Invalid threshold value\n");
					usage(argv);
				}
			case 'p':
				if (atoi(optarg)>0) {
					optpkt=atoi(optarg);
					break;
				} else {
					fprintf(stderr,"Invalid packet value\n");
					usage(argv);
				}

			case '?':
				if (isprint (optopt))
					fprintf (stderr, "Unknown option `-%c'.\n", optopt);
				else
					fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
				usage(argv);
			default:
				usage(argv);
		}


	if (action==ACTION_PARSE) pktlimit=optpkt;

	if (optind>=argc) {
		fprintf(stderr,"No file specified\n");
		usage(argv);
	}
	
	// Opening pcap file
	fprintf(stderr,"Opening file : %s\n",argv[optind]);
	if ((pcap = pcap_open_offline(argv[optind], errbuf)) == NULL) {
		fprintf(stderr,"Error opening pcap file : %s\n",errbuf);
		usage(argv);
	}

	init_hashes ();

	// Empty connection to start list
	first_flow=(flow*)malloc(sizeof(flow));
	first_flow->src.s_addr=0;
	first_flow->dst.s_addr=0;
	first_flow->sport=0;
	first_flow->dport=0;

	active_flows=first_flow;


	// Parse packets one by one
	nbp=0;nbip=0;nbtcp=0;
	totalSize=0;
	gettimeofday (&t0,NULL);
	while (pkt  = pcap_next( pcap,  &hdr )) {
		nbp++;
		totalSize+=hdr.len;

		current_ts=hdr.ts.tv_sec;
		if (last_expiration==0) last_expiration=current_ts;
		if (current_ts-last_expiration>CLEAN_TIME) {
			if (memory>=OPT_GARBAGE) clean_flows(first_flow->next,current_ts);
			statistics(current_ts-last_expiration);
			last_expiration=current_ts;
		}

		if (nbp % PRINTPKT== 0) {
			fprintf(stderr, "Pkt : %lu",nbp);
	    		fprintf(stderr, "\r");
			fflush(stderr);
		}

		eptr = (struct ether_header *) pkt;
		if (ntohs (eptr->ether_type) != ETHERTYPE_IP) {
			continue;
		} else {
			nbip++;
			ip_hdr=(struct ip *)(pkt+14);

			if (ip_hdr->ip_p==IPPROTO_TCP && ((ntohs (ip_hdr->ip_off) & IP_OFFMASK)==0)) {
				nbtcp++;
				count_flow(ip_hdr,hdr.caplen-14,hdr.ts.tv_sec);
			}
		}
	}

	if (memory>=OPT_GARBAGE) clean_flows(first_flow->next,current_ts);
	statistics(current_ts-last_expiration);
	last_expiration=current_ts;
	dump_flows(first_flow->next);
	statistics(1);

	gettimeofday (&t1,NULL);
	pcap_close(pcap);

	fprintf(stderr,"\n%lu Packets parsed in %.2fms\n(%lu non-ip / %lu non-tcp)\n"
			"TCP Connections with Syn: %lu\n"
			"Total Volume: %llu\n"
			"Duration: %lu\n",
			nbp,
			(float)((t1.tv_sec-t0.tv_sec)*1000000 + (t1.tv_usec-t0.tv_usec))/1000,
			nbp-nbip,nbp-nbtcp,flow_hash->total_insert,totalSize,stats.timeidx[stats.nbstats]);
	
	//dump_hashtab_stats(flow_hash);
	//print_statistics();
}
Exemplo n.º 17
0
//Print Stats Menu
char statsMenu()
{
    system("clear");
    char select;
    printf("\n");
    printf("%60s","######## S T A T I S T I C S  M E N U #########\n");
    printf("%60s","# ################## D N S ################## #\n");
    printf("%60s","# #                                         # #\n");
    printf("%60s","# #  a -> Load file [csv]                   # #\n");
    printf("%60s","# #  b -> Source devices                    # #\n");
    printf("%60s","# #  c -> Source ports                      # #\n");
    printf("%60s","# #  d -> Destination devices               # #\n");
    printf("%60s","# #  e -> Destination ports                 # #\n");
    printf("%60s","# #  f -> Number of queries                 # #\n");
    printf("%60s","# #  g -> Number of responses               # #\n");
    printf("%60s","# #  h -> Number of Rcodes                  # #\n");
    printf("%60s","# #  i -> Delay between questions/answers   # #\n");
    printf("%60s","# #  j -> Frequencies for MAC source        # #\n");
    printf("%60s","# #  k -> Frequencies for MAC destination   # #\n");
    printf("%60s","# #  l -> Frequencies for Names             # #\n");
    printf("%60s","# #  m -> Search keywords occurencies       # #\n");
    printf("%60s","# #  n -> Check answers in blacklist        # #\n");
    printf("%60s","# #                                         # #\n");
    printf("%60s","# #  q -> RETURN TO MAIN MENU               # #\n");
    printf("%60s","# #                                         # #\n");
    printf("%60s","# ########################################### #\n");
    printf("%60s","###############################################\n");
    printf("Option: ");

    scanf("%1s", &select);

    switch (select)
    {
    case 'a':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'b':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'c':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'd':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'e':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'f':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'g':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'h':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'i':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'j':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'k':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'l':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'm':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'n':
        system("clear");
        statistics(select);
        optionSaveStats=='3';
        statsMenu();
        break;
    case 'q':
        optionSave = 'm';
        optionSaveStats='3';
        system("clear");
        mainMenu();
        break;
    default:
        system("clear");
        printf(" Invalid option - please select options [a-n] or [q] to return!!! \n ");
        sleep(1);
        optionSaveStats='3';
        statsMenu();
        break;
    }
}
Exemplo n.º 18
0
// Boilerplate program options code from http://www.radmangames.com/programming/how-to-use-boost-program_options
int main(int argc, char** argv)
{
	bool enable_sorting = true;
	double seed = 0;

	double power_mean = 300.0;				// Watts
	double power_stdev = power_mean/10.0;
	double power_estimate_error_stdev = power_stdev/10.0;

	double arrival_rate = 1000.0;				// Jobs per second

	double completion_time_mean = 0.9*NUM_SERVERS/arrival_rate;	// Seconds
	double completion_time_stdev = completion_time_mean/10.0;

	double sorting_time_min = completion_time_mean/1000.0;
	double sorting_time_max = sorting_time_min*2.0;

	double routing_time_min = sorting_time_min;
	double routing_time_max = sorting_time_max;
	try
	{
	/** Define and parse the program options
	*/
	namespace po = boost::program_options;
	po::options_description desc("Options");
	desc.add_options()
	("help", "Print help messages")
	("seed", po::value<double>(&seed), "Seed for random number generator")
	("power_estimate_error_stdev", po::value<double>(&power_estimate_error_stdev), "Power estimate standard deviation")
	("completion_time_stdev", po::value<double>(&completion_time_stdev), "Completion time standard deviation")
	("enable_sorting", po::value<bool>(&enable_sorting), "Enable sorting")
	;

	po::variables_map vm;
	try
	{
		po::store(po::parse_command_line(argc, argv, desc),
					vm); // can throw

		/** --help option
		*/
		if ( vm.count("help")  )
		{
			std::cout << "Basic Command Line Parameter App" << std::endl
			<< desc << std::endl;
			return SUCCESS;
		}

		po::notify(vm); // throws on error, so do after help in case
		// there are any problems
	}
	catch(po::error& e)
	{
		std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
		std::cerr << desc << std::endl;
		return ERROR_IN_COMMAND_LINE;
	}

    // BEGIN APPLICATION CODE //

	DataCenterRandomPtr rand(new DataCenterRandom(
			seed,
			power_mean,
			power_stdev,
			arrival_rate,
			completion_time_mean,
			completion_time_stdev,
			sorting_time_min,
			sorting_time_max,
			routing_time_min,
			routing_time_max,
			power_estimate_error_stdev));

	PriorityTypePtr sortOrder(new JobEvent::PriorityType(JobEvent::TIME));

	PriorityQueueEventListPtr eventList(new PriorityQueueEventList(
			EVENT_LIST_LEN,
			sortOrder));

	PriorityQueueWorkingServers::SortingDomain sortingDomain;
	if(enable_sorting){
		sortingDomain = PriorityQueueWorkingServers::POWER_AWARE;
	}
	else{
		sortingDomain = PriorityQueueWorkingServers::RANDOM;
	}
	std::ostringstream s;
	s << seed;
	AccumulatorStatistics statistics(s.str());
	PriorityQueueWorkingServersPtr workingServersQueue(new PriorityQueueWorkingServers(
			NUM_SERVERS,
			rand,
			eventList,
			statistics.getAccumulator(AccumulatorStatistics::LATENCY),
			statistics.getAccumulator(AccumulatorStatistics::TOTAL_ENERGY),
			sortOrder,
			s.str() + "server_currents.csv",
			sortingDomain));
	PriorityQueueJobSorterPtr sortedJobQueue(new PriorityQueueJobSorter(
			SORTED_JOBS_LIST_LEN,
			rand,
			workingServersQueue,
			eventList,
			sortOrder,
			enable_sorting));
	QueueJobBufferPtr unsortedJobQueue(new QueueJobBuffer(
			UNSORTED_JOBS_LIST_LEN,
			statistics.getAccumulator(AccumulatorStatistics::TIME_BETWEEN_REJECTED_JOBS),
			sortedJobQueue));


#ifndef UNITTEST
	double time = 0;
	
	JobEventPtr arrival(new JobEvent(0, Event::JOB_ARRIVAL, sortOrder));
	
	_NOTEL(0,"Welcome to the data center stacked server simulator.");
	_LOGL(1,"Initialization parameters: ");
	_LOGL(1,"Sorting enabled: " << enable_sorting);
	_LOGL(1,"Simulation time: " << MAX_TIME);
	_LOGL(1,"Event list length: " << EVENT_LIST_LEN);
	_LOGL(1,"Unsorted jobs list length: " << UNSORTED_JOBS_LIST_LEN);
	_LOGL(1,"Sorted jobs list length: " << SORTED_JOBS_LIST_LEN);
	_LOGL(1,"Number of servers: " << NUM_SERVERS);
	_LOGL(1, *rand);

	// Queue up initial arrival.
	_NOTEL(2,"Creating initial arrival event.");
	eventList->enqueue(arrival);
	
	while(time < MAX_TIME){
		EventPtr e = eventList->dequeue();
		time = e->time;
		_NOTEL(2, time);

		if(e->type == Event::JOB_ARRIVAL || e->type == Event::JOB_FINISHED){
			JobEventPtr job = boost::static_pointer_cast<JobEvent>(e);

			if(job->type == Event::JOB_ARRIVAL){
				double t = time + rand->sample_arrivalTime();
				_NOTEL(2,"Processing job arrival event. Scheduling next job arrival for time " << t);
				JobEventPtr nextJob(new JobEvent(t, Event::JOB_ARRIVAL, sortOrder));
				eventList->enqueue(nextJob);


				if(!unsortedJobQueue->enqueue(job)){
					if(!sortedJobQueue->enqueue(job,time)){
						workingServersQueue->enqueue(job,time);
					}
				}
			}

			else{ // if(job->type == Event::JOB_FINISHED){
				_NOTEL(2,"Processing job removal event.");
				workingServersQueue->remove(job,time);
				if(enable_sorting){
					if(!sortedJobQueue->is_busy() && !sortedJobQueue->is_empty()){
						JobEventPtr job = sortedJobQueue->dequeueJob();
						workingServersQueue->enqueue(job,time);
					}
				}
				else{
					if(!unsortedJobQueue->is_empty()){
						JobEventPtr job = unsortedJobQueue->dequeue();
						workingServersQueue->enqueue(job,time);
					}
				}
			}
		}

		else if(e->type == Event::SORTED_QUEUE_READY){
			if(enable_sorting){
				_NOTEL(2,"Processing sorted queue ready event.");
				sortedJobQueue->reset_busy();

				if(!sortedJobQueue->is_empty() && !workingServersQueue->is_busy() && !workingServersQueue->is_full()){
					JobEventPtr job = sortedJobQueue->dequeueJob();
					workingServersQueue->enqueue(job,time);
				}

				if(!unsortedJobQueue->is_empty()){
					JobEventPtr job = unsortedJobQueue->dequeue();
					if(!sortedJobQueue->enqueue(job,time)){
						workingServersQueue->enqueue(job,time);
					}
				}
				else{
					_NOTEL(2,"Nothing for sorted queue to do.");
				}
			}
			else{
				_NOTEL(0,"PROBLEM!!!");
			}
		}

		else{ // if(e->type == Event::WORKING_SERVERS_QUEUE_READY){
			_NOTEL(2,"Processing working servers queue ready event.");
			workingServersQueue->reset_busy();
			if(enable_sorting){
				if(!sortedJobQueue->is_busy() && !sortedJobQueue->is_empty()){
					JobEventPtr job = sortedJobQueue->dequeueJob();
					workingServersQueue->enqueue(job,time);
				}
			}
			else{
				if(!unsortedJobQueue->is_empty()){
					JobEventPtr job = unsortedJobQueue->dequeue();
					workingServersQueue->enqueue(job,time);
				}
			}
		}
		//_NOTE(3, (*eventList) << std::endl);
	}
	
	_NOTEL(1,"Finished simulation of " << time << " virtual seconds.");
	_LOGL(0,"Simulation results: " << std::endl << statistics);
	AccumulatorPtr latency = statistics.getAccumulator(AccumulatorStatistics::LATENCY);
	AccumulatorPtr total_energy = statistics.getAccumulator(AccumulatorStatistics::TOTAL_ENERGY);
	_LOGL(0, latency->getMean() << "$\\pm$" << latency->getCI(0.95) << " & " << total_energy->getMean() << "$\\pm$" << total_energy->getCI(0.95));
	return 0;

// Run the Unit tests
#else
	_NOTEL(0,"Welcome to the unit tests.");
	test_accumulator(rand,statistics);
	test_working_servers(workingServersQueue,sortOrder,statistics);
	return 0;
#endif
    // END APPLICATION CODE //

  }
  catch(std::exception& e)
  {
    std::cerr << "Unhandled Exception reached the top of main: "
              << e.what() << ", application will now exit" << std::endl;
    return ERROR_UNHANDLED_EXCEPTION;

  }

  return SUCCESS;

} // main
Exemplo n.º 19
0
int main(int anz,char *paramstring[]) {
    satz         = (char *)calloc(1,300);
    teil         = (char *)calloc(1,12);
    dateinameein = (char *)calloc(1,255);
    dateinameaus = (char *)calloc(1,255);



    printf("Umwandeln einer Ascii-Datei in ein Festformat\r\n");
    if (anz<2) {
        printf("\n");
        printf("usage: ascigrid <Ascii-Datei> <festformatdatei>\r\n");
        printf("\n");
        printf(" Ascii-Datei: Dateikopf mit : \r\n");
        printf(" ncols,nrows,xll,yll,cs,nodata jeweils ein Wert pro Zeile\r\n");
        printf(" alle weiteren Werte von links oben nach rechts unten zeilenweise\r\n");
        printf("\n");
        printf("Eingabedatei : ");
        dateinameein=gets(dateinameein);
        printf("\r\nAusgabedatei : ");
        dateinameaus=gets(dateinameaus);
        printf("\r\n");
    } else {
        if (paramstring[1]!=NULL) strcpy(dateinameein,paramstring[1]);
        if (anz>1) if (paramstring[2]!=NULL) strcpy(dateinameaus,paramstring[2]);
    }

    while ((dateiein=fopen((char *)dateinameein,"r"))==NULL) {

        printf("Kann Eingabedatei %s nicht finden bzw ÷ffnen!\r\n",dateinameein);
        printf("Bitte neuen Namen angeben : ");
        dateinameein=gets((char *)dateinameein);
        if (*(char *)dateinameein=='\0') exit(1);
        printf("\r\n");
    }
    while ((dateiaus=fopen(dateinameaus,"wb"))==NULL) {
        printf("Kann Ausgabedatei %s nicht finden bzw ÷ffnen!\r\n",dateinameaus);
        printf("Bitte neuen Namen angeben : ");
        dateinameaus=gets(dateinameaus);
        if (*dateinameaus=='\0') exit(1);
        printf("\r\n");

    }


    fscanf(dateiein,"%12s%d",teil,&ncols);
    fscanf(dateiein,"%12s%d",teil,&nrows);
    fscanf(dateiein,"%12s%f",teil,&xll);
    fscanf(dateiein,"%12s%f",teil,&yll);
    fscanf(dateiein,"%12s%f",teil,&cs);
    fscanf(dateiein,"%12s%f",teil,&nodata);

    x[1]=ncols;
    x[2]=nrows;
    x[3]=xll;
    x[4]=yll;
    x[5]=cs;
    x[6]=nodata;

    groesse=sizeof(x[1]);
    clearstat(nodata);
    fwrite(&x[1],sizeof(float),12,dateiaus);
    for (j=1; j<=nrows; j++) {
        for (i=1; i<=ncols; i++) {
            fscanf(dateiein,"%f",&x[1]);
            fwrite(&x[1],groesse,1,dateiaus);
            addstat(x[1]);
        }
        fgets(satz,300,dateiein);
        printf(".");
    }

    printf("\n");

    statistics(&x[6],&x[7],&x[8],&x[9],&x[10],&x[11]);

    fseek(dateiaus,6*sizeof(float),0);
    fwrite(&x[6],sizeof(float),6,dateiaus);

    fclose(dateiein);
    fclose(dateiaus);

    free(satz);
    free(teil);

    free(dateinameein);
    free(dateinameaus);


}
Exemplo n.º 20
0
PetriDish::~PetriDish()
{
#if DEBUG
    cout << statistics();
#endif//DEBUG
}
Exemplo n.º 21
0
Arquivo: vasm.c Projeto: ezrec/vasm
int main(int argc,char **argv)
{
    int i;
    for(i=1; i<argc; i++) {
        if(argv[i][0]=='-'&&argv[i][1]=='F') {
            output_format=argv[i]+2;
            argv[i][0]=0;
        }
        if(!strcmp("-quiet",argv[i])) {
            verbose=0;
            argv[i][0]=0;
        }
    }
    if(!init_output(output_format))
        general_error(16,output_format);
    if(!init_main())
        general_error(10,"main");
    if(verbose)
        printf("%s\n%s\n%s\n%s\n",copyright,cpu_copyright,syntax_copyright,output_copyright);
    for(i=1; i<argc; i++) {
        if(argv[i][0]==0)
            continue;
        if(argv[i][0]!='-') {
            if(inname)
                general_error(11);
            inname=argv[i];
            continue;
        }
        if(!strcmp("-o",argv[i])&&i<argc-1) {
            if(outname)
                general_error(28,'o');
            outname=argv[++i];
            continue;
        }
        if(!strcmp("-L",argv[i])&&i<argc-1) {
            if(listname)
                general_error(28,'L');
            listname=argv[++i];
            produce_listing=1;
            continue;
        }
        if(!strcmp("-Lnf",argv[i])) {
            listformfeed=0;
            continue;
        }
        if(!strcmp("-Lns",argv[i])) {
            listnosyms=1;
            continue;
        }
        if(!strncmp("-Ll",argv[i],3)) {
            sscanf(argv[i]+3,"%i",&listlinesperpage);
            continue;
        }
        if(!strncmp("-D",argv[i],2)) {
            char *def=NULL;
            expr *val;
            if(argv[i][2])
                def=&argv[i][2];
            else if (i<argc-1)
                def=argv[++i];
            if(def) {
                char *s=def;
                if(ISIDSTART(*s)) {
                    s++;
                    while(ISIDCHAR(*s))
                        s++;
                    def=cnvstr(def,s-def);
                    if(*s=='=') {
                        s++;
                        val=parse_expr(&s);
                    }
                    else
                        val=number_expr(1);
                    if(*s)
                        general_error(23,'D');  /* trailing garbage after option */
                    new_abs(def,val);
                    myfree(def);
                    continue;
                }
            }
        }
        if(!strncmp("-I",argv[i],2)) {
            char *path=NULL;
            if(argv[i][2])
                path=&argv[i][2];
            else if (i<argc-1)
                path=argv[++i];
            if(path) {
                new_include_path(path);
                continue;
            }
        }
        if(!strcmp("-unnamed-sections",argv[i])) {
            unnamed_sections=1;
            continue;
        }
        if(!strcmp("-ignore-mult-inc",argv[i])) {
            ignore_multinc=1;
            continue;
        }
        if(!strcmp("-nocase",argv[i])) {
            nocase=1;
            continue;
        }
        if(!strcmp("-noesc",argv[i])) {
            esc_sequences=0;
            continue;
        }
        if(!strcmp("-nosym",argv[i])) {
            no_symbols=1;
            continue;
        }
        if(!strncmp("-nowarn=",argv[i],8)) {
            int wno;
            sscanf(argv[i]+8,"%i",&wno);
            disable_warning(wno);
            continue;
        }
        else if(!strcmp("-w",argv[i])) {
            no_warn=1;
            continue;
        }
        if(!strncmp("-maxerrors=",argv[i],11)) {
            sscanf(argv[i]+11,"%i",&max_errors);
            continue;
        }
        else if(!strcmp("-pic",argv[i])) {
            pic_check=1;
            continue;
        }
        if(cpu_args(argv[i]))
            continue;
        if(syntax_args(argv[i]))
            continue;
        if(output_args(argv[i]))
            continue;
        if (!strncmp("-x",argv[i],2)) {
            auto_import=0;
            continue;
        }
        general_error(14,argv[i]);
    }
    if(inname) {
        setfilename(inname);
        setdebugname(inname);
        include_source(inname);
    } else
        general_error(15);
    if(!init_parse())
        general_error(10,"parse");
    if(!init_syntax())
        general_error(10,"syntax");
    if(!init_cpu())
        general_error(10,"cpu");
    parse();
    if(errors==0||produce_listing)
        resolve();
    if(errors==0||produce_listing)
        assemble();
    if(errors==0&&!auto_import)
        undef_syms();
    if(!listname)
        listname="a.lst";
    if(produce_listing)
        write_listing(listname);
    if(!outname)
        outname="a.out";
    if(errors==0) {
        if(verbose)
            statistics();
        outfile=fopen(outname,"wb");
        if(!outfile)
            general_error(13,outname);
        write_object(outfile,first_section,first_symbol);
    }
    leave();
    return 0; /* not reached */
}
Exemplo n.º 22
0
void ArtemisWebPage::javaScriptAlert(QWebFrame*, const QString& msg)
{
    statistics()->accumulate("WebKit::alerts", 1);
    qDebug() << "JAVASCRIPT ALERT: " << msg;
}