コード例 #1
0
ファイル: sprofalyze.c プロジェクト: josepedrazap/trabajo2
static struct binary_info *binary_find(const char *name) {
	struct binary_info *binary;
	const char *current_name;
	unsigned i;
	char path[PATH_MAX + 1], *path_end;

	assert(name);

	/* name is required */
	if (!*name) {
		fprintf(stderr, "warning: binary unspecified in sample\n");
		return NULL;
	}

	/* do we already know this binary? */
	binary = binary_hashtab_get(name);
	if (binary) return binary;

	/* search for it */
	dprintf("searching for binary \"%.*s\" in \"%s\"\n",
		PROC_NAME_LEN, name, src_path);
	for (i = 0; i < LENGTHOF(default_binaries); i++) {
		snprintf(path, sizeof(path), "%s/%s", src_path,
			default_binaries[i]);
		current_name = binary_name(path);
		assert(current_name);
		if (*current_name) {
			/* paths not ending in slash: use if name matches */
			if (strncmp(name, current_name,
				PROC_NAME_LEN) != 0) {
				continue;
			}
		} else {
			/* paths ending in slash: look in subdir named after
			 * binary
			 */
			path_end = path + strlen(path);
			snprintf(path_end, sizeof(path) - (path_end - path),
				"%.*s/%.*s", PROC_NAME_LEN, name,
				PROC_NAME_LEN, name);
		}

		/* use access to find out whether the binary exists and is
		 * readable
		 */
		dprintf("checking whether \"%s\" exists\n", path);
		if (access(path, R_OK) < 0) continue;

		/* ok, this seems to be the one */
		return binary_add(strdup_checked(path));
	}

	/* not found */
	return NULL;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: Psyroth/infoFond
int main(int argc, char **argv)
{
    // Vérifier le nombre d'arguments
    if (argc != 3)
    {
        std::cerr << "Utilisation : " << argv[0] << " <contraintes> <sortie>" << std::endl;
        return 1;
    }

    std::string binary_name(argv[0]);
    std::string constraints(argv[1]);
    std::string output(argv[2]);

    
    int question_number = 3;

    if (binary_name.size() >= 13)
    {
        char c = binary_name[binary_name.size()-5];

        if (c == '1') question_number = 1;
        else if (c == '2') question_number = 2;
        else if (c == '3') question_number = 3;
    }

    // Parser le fichier de contraintes
    Parser1 *parser;

    // Résoudre le problème
    Problem1 *problem;
    
    if(question_number == 1)
    {
        parser = new Parser1(constraints);
        problem = new Problem1(parser);
    }
    else if(question_number == 2)
    {
        parser = new Parser2(constraints);
        problem = new Problem2(parser);
    }
    else if(question_number == 3)
    {
        parser = new Parser3(constraints);
        problem = new Problem3(parser);
    }

    problem->addAllClauses();
    problem->solve();
    problem->printResult();
    problem->write(output);
    delete problem;
    delete parser;
}
コード例 #3
0
ファイル: phat_tool.cpp プロジェクト: bnels/ctl
int main( int argc, char *argv[]){
  po::variables_map vm;
  process_args( argc, argv, vm);

  //setup some variables
  std::string full_complex_name = vm[ "input-file"].as< std::string>();
  std::string complex_name( full_complex_name);
  std::string binary_name( argv[ 0]);
  std::string base_name( full_complex_name);
  std::string output_name;
  size_t found = complex_name.rfind( '/');
  if ( found != std::string::npos){
        complex_name.replace( 0, found+1, "");
  }
  found = full_complex_name.rfind('.');
   if ( found != std::string::npos){
        base_name.replace(found,full_complex_name.length(), "");
  	output_name = base_name + ".phat";
  }
  std::ofstream out(output_name.c_str());
  
  Complex complex;

  // Read the cell_set in
  ctl::read_complex( full_complex_name, complex);
 
  Complex_filtration complex_filtration( complex);


  typedef ctl::Filtration_boundary< Complex_filtration> 
				   Filtration_boundary;
  typedef Filtration_boundary::Term Filtration_term;
  typedef ctl::Chain< Filtration_term> Chain;
  std::cout << "Writing PHAT ASCII file To: " << output_name << std::endl;
  Filtration_boundary bd( complex_filtration);
  for (Complex_filtration_iterator sigma = complex_filtration.begin(); 
				   sigma != complex_filtration.end(); ++sigma){
       Chain cascade_boundary;
       cascade_boundary.reserve( bd.length( sigma));
       for( auto i = bd.begin( sigma); i != bd.end( sigma); ++i){
                  cascade_boundary.emplace( i->cell(), i->coefficient());
       }
       cascade_boundary.sort();
       out << (*sigma)->first.dimension();
       for( auto term : cascade_boundary){
       	out << " " << term.cell(); 
       }
       out << std::endl;
  }
  return 0;
}
コード例 #4
0
ファイル: sprofalyze.c プロジェクト: josepedrazap/trabajo2
static struct binary_info *binary_add(const char *path) {
	struct binary_info *binary, **ptr;
	const char *name;

	/* assumption: path won't be overwritten or deallocated in the future */

	/* not too much effort escaping for popen, prevent problems here */
	assert(path);
	if (strchr(path, '"')) {
		fprintf(stderr, "error: path \"%s\" contains a quote\n", path);
		exit(1);
	}

	/* get filename */
	name = binary_name(path);
	dprintf("adding binary \"%s\" with name \"%.*s\"\n",
		path, PROC_NAME_LEN, name);
	if (strlen(name) == 0) {
		fprintf(stderr, "error: path \"%s\" does not "
			"contain a filename\n", path);
		exit(1);
	}

	/* check in hashtable whether this entry is indeed new */
	ptr = binary_hashtab_get_ptr(name);
	if (*ptr) {
		fprintf(stderr, "warning: ignoring \"%s\" because \"%s\" was "
			"previously specified\n", path, (*ptr)->path);
		return *ptr;
	}
	dprintf("using %.*s from \"%s\"\n", PROC_NAME_LEN, name, path);

	/* allocate new binary_info */
	binary = MALLOC_CHECKED(struct binary_info, 1);
	memset(binary, 0, sizeof(struct binary_info));
	binary->path = path;
	strncpy(binary->name, name, sizeof(binary->name));

	/* insert into linked list */
	binary->next = binaries;
	binaries = binary;

	/* insert into hashtable */
	*ptr = binary;
	return binary;
}
コード例 #5
0
ファイル: wsgc_test.cpp プロジェクト: Yuhulabs/wsgc
//=================================================================================================
int main(int argc, char *argv[])
{
	std::string binary_name(argv[0]);
    Options options(binary_name);

    srand(WsgcUtils::timenow_usec_hour());

    if (options.get_options(argc,argv))
    {
        std::ostringstream os;
        options.print_options(os);
        std::cout << os.str() << std::endl;

        unsigned int nb_message_symbols;

#ifdef _CCSOFT
        if (options.fec_scheme == Options::OptionFEC_CCSoft)
        {
            unsigned int tmp_n, tmp_k, tmp_m;
            ccsoft::get_cc_parameters<unsigned int>(options.cc_k_constraints, 
                options.cc_generator_polys,
                tmp_n,
                tmp_k,
                tmp_m);
            nb_message_symbols = 1<<tmp_n;
        }
        else
        {
            nb_message_symbols = options.nb_message_symbols;
        }
#else
        nb_message_symbols = options.nb_message_symbols;
#endif

        GoldCodeGenerator gc_generator(options.gc_nb_stages, nb_message_symbols, options.nb_service_symbols, options.nb_training_symbols, options.g1_poly_powers, options.g2_poly_powers);
        Transmission transmission(options, gc_generator);
        transmission.generate_samples(options.prns);
        wsgc_complex *faded_source_samples = transmission.get_samples();
        unsigned int nb_faded_source_samples = transmission.get_nb_samples();

        if (faded_source_samples)
        {
            if (options.transmission_scheme == Options::OptionTrans_MFSK)
            {
                Reception_MFSK reception_MFSK(options, gc_generator);
                reception_MFSK.message_processing(faded_source_samples, nb_faded_source_samples);
            }
            else if (options.transmission_scheme == Options::OptionTrans_WSGC)
            {
                Reception_WSGC reception_WSGC(options, gc_generator);

                if (options.simulate_training)
                {
                    reception_WSGC.training_processing(faded_source_samples, nb_faded_source_samples);
                }
                else
                {
                    reception_WSGC.message_processing(faded_source_samples, nb_faded_source_samples);
                }
            }
            else if (options.transmission_scheme == Options::OptionTrans_WSGCE)
            {
                Reception_WSGCE reception_WSGCE(options, gc_generator);

                if (options.simulate_training)
                {
                    std::cerr << "Simulating training sequence is not implemented" << std::endl;
                }
                else
                {
                    reception_WSGCE.message_processing(faded_source_samples, nb_faded_source_samples);
                }
            }
            else if (options.transmission_scheme == Options::OptionTrans_WSGCO)
            {
                Reception_WSGCO reception_WSGCO(options, gc_generator);
                
                if (options.simulate_training)
                {
                    reception_WSGCO.training_processing(faded_source_samples, nb_faded_source_samples);
                }
                else
                {
                    reception_WSGCO.message_processing(faded_source_samples, nb_faded_source_samples);
                }
            }
            else if (options.transmission_scheme == Options::OptionTrans_WSGCD)
            {
                Reception_WSGCD reception_WSGCD(options, gc_generator);
                
                if (options.simulate_training)
                {
                    reception_WSGCD.training_processing(faded_source_samples, nb_faded_source_samples);
                }
                else
                {
                    reception_WSGCD.message_processing(faded_source_samples, nb_faded_source_samples);
                }
            }
            else
            {
                std::cout << "Unknown or undefined transmission scheme" << std::endl;
            }
        }
        else
        {
            std::cout << "No samples" << std::endl;
        }

        return 0;
    }
    else
    {
        std::cout << "Incorrect options. Please correct and re-submit" << std::endl;
        return -1;
    }
}
コード例 #6
0
ファイル: cover_homology_tool.cpp プロジェクト: albertasd/ctl
int main( int argc, char *argv[]){
  #ifdef ZOOM_PROFILE
  std::cout << "Connect" <<  ZMConnect() << std::endl;
  #endif
 
  po::variables_map vm;
  process_args( argc, argv, vm);
  size_t num_parts = atoi( vm[ "num-parts"].as< std::string>().c_str());

  //setup some variables
  std::string full_complex_name = vm[ "input-file"].as< std::string>();
  std::string complex_name( full_complex_name);
  std::string binary_name( argv[ 0]);

  size_t found = complex_name.rfind( '/');
  if ( found != std::string::npos){
        complex_name.replace( 0, found+1, "");
  }
  tbb::task_scheduler_init init;
  
  Complex complex;
  Nerve nerve;
  tbb::concurrent_vector< Complex_iterator> nearly_pure;
  Stats stats;

  // Read the cell_set in
  //read_complex( full_complex_name, complex);
  stats.timer.start();
  Complex_filtration complex_filtration( complex);
  stats.timer.stop();
  double orig_filtration_time = stats.timer.elapsed();
  std::cout << "filtered complex " << orig_filtration_time << std::endl;
  stats.timer.start();
  ctl::parallel::init_cover_complex( nerve, num_parts);
  ctl::parallel::graph_partition_open_cover( complex_filtration, nerve, nearly_pure);
  stats.timer.stop();
  double cover_time = stats.timer.elapsed();
  std::cout << "built cover." << std::endl;
  #ifdef ZOOM_PROFILE
  std::cout << "Profiling Begin";
  ZMError start_error = ZMStartSession();
  std::cout << start_error << std::endl;
  #endif 
 
  ctl::parallel::compute_homology( complex, nerve, num_parts, stats);
  #ifdef ZOOM_PROFILE
  ZMError end_error = ZMStopSession();
  std::cout << "Profiling End" << end_error << std::endl;
  #endif
  #ifdef ZOOM_PROFILE
   std::cout << "Disconnect" <<  ZMDisconnect() << std::endl;
  #endif
  double total_time = cover_time + stats.filtration_time + stats.get_iterators +
         	     stats.parallel_persistence + stats.initialize_cascade_boundary;
                  
  std::cout << std::setprecision( 2) << std::fixed;
                                                                                
  std::cout << "build cover: " << cover_time 
            << " (" << (cover_time/total_time)*100 << "%)" << std::endl;
                                                                                
  std::cout << "re-filter complex: " << stats.filtration_time 
            << " (" << (stats.filtration_time/total_time)*100 << "%)" 
            << std::endl;
  std::cout << "compute parallel ranges: " << stats.get_iterators
            << " (" << (stats.get_iterators/total_time)*100 << "%)" 
	    << std::endl;
  std::cout << "initialize_cascade_boundary: " 
            << stats.initialize_cascade_boundary << " (" 
            << (stats.initialize_cascade_boundary/total_time)*100 << "%)" << std::endl;
  std::cout << "parallel_homology: " 
            << stats.parallel_persistence << " (" 
            << (stats.parallel_persistence/total_time)*100 << "%)" << std::endl;
  std::cout << "total time: " << total_time << " (100%)" << std::endl;

#ifdef TESTS_ON
  ctl::run_tests( complex, blowup_complex, nerve);
#endif
  init.terminate();
  return 0;
}