Пример #1
0
int main()
{
  X x;
  X* xp = &x;

  assert(mem_fn(&X::negate)(x, 17) == -17);
  assert(mem_fn(&X::negate)(xp, 17) == -17);
  assert(mem_fn(&X::plus)(x, 17, 25) == 42);
  assert(mem_fn(&X::plus)(xp, 17, 25) == 42);

  return 0;
}
void findEmptyString(const std::vector<std::string>& strings) {
    auto endIterator = end(strings);
    auto iterator = 
        find_if(begin(strings), endIterator, mem_fn(&std::string::empty));
    if (endIterator == iterator) {
        std::cout << "No empty strings!" << std::endl;
    }
    else {
        std::cout << "Empty string at postion: "
                  << static_cast<int>(iterator - begin(strings))
                  << std::endl;
    }
}
Пример #3
0
 static R invoke(const functor &member_ptr, TArgs... args) {
     F *f = reinterpret_cast<F *>(member_ptr.u.obj_ptr);
     return mem_fn(*f)(args...);
 }
Пример #4
0
	vector<Polynomial> F4::compute(vector<Polynomial>& generators) 
	{
		vector<Polynomial> result;
		tbb::task_scheduler_init init(threads);

		if(this->reducer == 0) {
			this->reducer = new F4DefaultReducer(this, false, 1024);
		}
		// Attention: init is only called for the "main reducer"

#if PGBC_WITH_MPI == 1
		if(world.rank() == 0) {
#endif
		

		double start = F4Logger::seconds();

		pairs = F4PairSet( F4Pair::comparator(O) );


		sort(generators.begin(), generators.end(), Polynomial::comparator(O, true));		

		//normalize
		for_each(generators.begin(), generators.end(), bind(mem_fn(&Polynomial::normalize), _1, field));

		updatePairs(generators, true);

		this->reducer->init();
		
		while( !pairs.empty() ) {
			vector<Polynomial> polys;
			select();
			reduce(polys);
			if(!polys.empty()) {
				updatePairs(polys, false);
			}
		}

		this->reducer->finish();

		if(log->verbosity & 2) {
			*(log->out) << "Reduction (s): \t" << log->reductionTime << "\n";
		}
		if(log->verbosity & 4) {
			*(log->out) << "Prepare (s): \t" << log->prepareTime << "\n";
		}
		if(log->verbosity & 8) {
			*(log->out) << "Update (s): \t" << log->updateTime << "\n";
			*(log->out) << "Simplify (s): \t" << log->simplifyTime << "\n";
#if PGBC_WITH_MPI == 1
			*(log->out) << "MPI Overhead (s): \t" << log->mpiTime << "\n";
#endif
		}
		for(size_t i = 0; i < groebnerBasis.size(); i++)
		{
			if(inGroebnerBasis[i])
				result.push_back(groebnerBasis[i]);
		}
		if(log->verbosity & 1) {
			*(log->out) << "Runtime (s):\t" << F4Logger::seconds() - start << "\n";
		}

		/* Enable this to collect timings
		 *(log->out) << threads << ";";
		 *(log->out) << F4Logger::seconds() - start << ";";
		 *(log->out) << reductionTime << ";";
		 *(log->out) << updateTime << ";";
		 *(log->out) << prepareTime << "\n";
		 */
#if PGBC_WITH_MPI == 1
		} else {
			this->reducer->client();
		}
#endif
		return result;
	}