Exemplo n.º 1
0
/// Sieve the primes and prime k-tuplets (twin primes, prime
/// triplets, ...) within the interval [start, stop].
///
void PrimeSieve::sieve()
{
  reset();
  if (start_ > stop_)
    return;
  double t1 = getWallTime();
  if (isStatus())
    updateStatus(INIT_STATUS, false);

  // Small primes and k-tuplets (first prime <= 5)
  // are checked manually
  if (start_ <= 5) {
    LockGuard lock(*this);
    for (int i = 0; i < 8; i++)
      doSmallPrime(smallPrimes_[i]);
  }
  if (stop_ >= 7) {
    PrimeFinder finder(*this);
    // First generate the sieving primes up to
    // sqrt(stop) and add them to finder
    if (finder.getSqrtStop() > finder.getPreSieve()) {
      PrimeGenerator generator(finder);
      generator.doIt();
    }
    // sieve the primes within [start, stop]
    finder.sieve();
  }

  seconds_ = getWallTime() - t1;
  if (isStatus())
    updateStatus(FINISH_STATUS, true);
}
Exemplo n.º 2
0
void CpersonTarget::updateStatus(unsigned int th1, unsigned int th2, unsigned int th3, unsigned int th4)
{
      
//       if ( ( countToBeRemoved > MAX_REMOVING_ITERATIONS ) || ( countConsecutiveUncorrected > th1*this->status ) )
      if ( ( countToBeRemoved > MAX_REMOVING_ITERATIONS ) || ( countConsecutiveUncorrected > th1 ) ) 
      {
            //this->status = TO_BE_REMOVED;
            setStatus(TO_BE_REMOVED,true);
      }
      
      else //no removing case
      {
//             switch(this->status)
//             {
//                   case CANDIDATE: 
//                         if ( countIterations > th2 ) this->status = LEGGED_TARGET;
//                         if ( this->estimate.position.getCovTrace() > 1 ) this->status = TO_BE_REMOVED;
//                         break;
//                         
//                   case LEGGED_TARGET:
//                         if ( countVisuallyCorrected > th3 ) this->status = VISUALLY_CONFIRMED;//this->print();
//                         if ( this->estimate.position.getCovTrace() > 1 ) this->status = TO_BE_REMOVED;
//                         break;
//                         
//                   case VISUALLY_CONFIRMED:
//                         if ( countVisuallyCorrected > th4 ) this->status = FRIEND_IN_SIGHT;
//                         break;
//                         
//                   case FRIEND_IN_SIGHT:
//                         // to do : some rule to transition to FRIEND_OUT_OF_RANGE
//                         // to do : friends are never removed !
//                         break;
//                         
//                   case FRIEND_OUT_OF_RANGE:
//                         // to do: some rule to come back to FRIEND_IN_SIGHT
//                         // to do: friends are never removed !
//                         break;
//                         
//                   default:
//                         break;
//             }
            if ( isStatus(VISUALLY_CONFIRMED) ) {
                  if ( countVisuallyCorrected > th4 ) setStatus(FRIEND_IN_SIGHT, true);                  
                  return;}
            if ( isStatus(LEGGED_TARGET) ) {
                  if ( countVisuallyCorrected > th3 ) setStatus(VISUALLY_CONFIRMED, true);
                  if ( this->estimate.position.getCovTrace() > 1 ) setStatus(TO_BE_REMOVED,true);
                  return;}
            if ( isStatus(CANDIDATE) ) {
                  if ( countIterations > th2 ) 
                  {
                        setStatus(LEGGED_TARGET,true);
                        setStatus(CANDIDATE,false);
                  }
                  if ( this->estimate.position.getCovTrace() > 1 ) setStatus(TO_BE_REMOVED,true);
                  return;}
      }
}
Exemplo n.º 3
0
				StatusMessage::StatusMessage(const RoboCanMessage & m) {
					if (!isStatus(m.getCmd())) {
						throw Poco::Exception("RoboCan: Status number out of range");
					}
					this->message = m;
				}