コード例 #1
0
ファイル: imu_buffer.cpp プロジェクト: ayumizll/tonav
ImuItem ImuBuffer::interpolateAtTime(double time) const {
    if (time > getMaxTime()) {
        throw GeneralException("Lookup would require extrapolation into the future.");
    }
    if (time < getMinTime()) {
        throw GeneralException("Interpolating too far in to past.");
    }
    for (int i = 0; i < size_ - 1; ++i) {
        const ImuItem& later = items_[(cur_pos_ - i - 1) % size_];
        const ImuItem& earlier = items_[(cur_pos_ - i - 2) % size_];
        if (std::abs(time - later.getTime()) < 1e-3) {
            return later;
        }
        if (std::abs(time - earlier.getTime()) < 1e-3) {
            return earlier;
        }
        if (earlier.getTime() >= later.getTime()) {
            throw ImpossibleException("Bad time ordering.");
        }
        if (earlier.getTime() < time && time < later.getTime()) {
            ImuItem interpolated;
            double time_delta = later.getTime() - earlier.getTime();
            double t = (time - earlier.getTime()) / time_delta;
            interpolated.time_ = time;
            interpolated.device_ = later.getDevice();
            interpolated.data_ = t * earlier.data_ + (1-t) * later.data_;
            return interpolated;
        }
    }
    throw ImpossibleException("Interpolation failure. Time " + std::to_string(time) + " min " + std::to_string(getMinTime()) + " max " + std::to_string(getMaxTime()));
}
コード例 #2
0
void Scheduler::regenerate(double t, unsigned long long eventCount)
{
    masterEL.clear();
    BOOST_FOREACH(Particle p1, simulator->getParticles())
    masterEL.push_back(getMinTime(t, p1.getID()));

    if(masterEL.size() != simulator->getParticles().size())
    {
        std::cerr << "MasterEL not correct size" << std::endl;
        exit(3);
    }
    //if thermostat is active, initialise its events
    if(simulator->setThermostat()->is_initialised())
    {
        masterEL.push_back(Event());
        thermoPoint = masterEL.size() - 1;
        getThermoEvent(t, eventCount);
    }
    //if measuring RDF, initialise its events
    if(simulator->getSettings().getSampleRDF())
    {
        masterEL.push_back(Event());
        RDFPoint = masterEL.size() - 1;
        getRDF(0);
    }

}
コード例 #3
0
ファイル: Drying.cpp プロジェクト: yabincui/oj_coding
int main() {
  freopen("Drying.in", "r", stdin);
  while (scanf("%d", &N) == 1) {
    for (int i = 0; i < N; ++i) {
      scanf("%d", &A[i]);
    }
    scanf("%d", &K);
    int result = getMinTime();
    printf("%d\n", result);
  }
  return 0;
}
コード例 #4
0
void Scheduler::update(double t, unsigned int p1)
{
    masterEL[p1] = getMinTime(t, p1);
}