示例#1
0
  /// Time from number of days, fractional values ok
  Time::Time(double fracDays)
  {
    double fracHours = HOURS_PER_DAY * fracDays;
    int hours = floor0(fracHours);

    double fracMinutes = MINUTES_PER_HOUR * (fracHours-hours);
    int minutes = floor0(fracMinutes);

    double fracSeconds = SECONDS_PER_MINUTE * (fracMinutes-minutes);
    int seconds = floor0(fracSeconds);

    m_impl = ImplType(hours, minutes, seconds, 0);
  }
示例#2
0
unsigned destination_processor(const Gear & gear, double rad, double angle, double height, unsigned p_rank, unsigned p_size)
{
  unsigned result = 0;
  // Distribute elements across angles: (not working perfectly yet)
  angle = scale_angle_2pi(angle);
  result = static_cast<unsigned>(floor0((angle/TWO_PI)*p_size));
  
  // Distribute elements across radius:
  //result = static_cast<unsigned>(floor0((rad-gear.rad_min)/(gear.rad_max-gear.rad_min)*p_size));

  // Distribute elements across height:
  //result = static_cast<unsigned>(floor0((height-gear.height_min)/(gear.height_max-gear.height_min)*p_size));
  
  // Distribute elements randomly:
  //result = std::rand() % p_size;

  // Distribute in round-robin fashion:
  //static unsigned dest_proc = 0;
  //result = dest_proc++ % p_size;

  // Distribute all to processor 2:
  //result = 1;

  scale_p_rank(result,p_size);
  
  //std::cout << "P"<<p_rank<<"("<<p_size<<"):  (r,t,z) = ("<<rad<<", "<<angle<<", "<<height<<"), dest = " << result << std::endl;

  return result;
}
示例#3
0
QList<Candidate* > HalfStar::select(QList<Candidate* > population, int selectionSize) {
    QList<QList<Candidate* > > twoDimCandidates;
    int x = 0;
    int y = 0;
    int remainder = 0;
    x = round(sqrt(population.size()));
    y = floor0(population.size()/x);
    remainder = population.size() - (x*y);
    //Tournament
    for(int i=0; i<(population.size() - remainder);i++) {

    }
}
示例#4
0
 /// whole number of days
 int Time::days() const
 {
   return floor0(totalDays());
 }