예제 #1
0
파일: ArModel.cpp 프로젝트: comenerv/Boom
 Vec ArModel::simulate(int n, const Vec &y0) const {
   if(y0.size() != number_of_lags()){
     ostringstream err;
     err << "Error in ArModel::simulate." << endl
         << "Initial state value y0 was size " << y0.size()
         << ", but the model has " << number_of_lags() << " lags."
         << endl;
     report_error(err.str());
   }
   const Vec &phi(this->phi());
   std::deque<double> lags(y0.rbegin(), y0.rend());
   Vec ans;
   ans.reserve(n);
   for(int i = 0; i < n; ++i) {
     double mu = 0;
     for(int lag = 0; lag < number_of_lags(); ++lag) {
       mu += phi[lag] * lags[lag];
     }
     double y = rnorm(mu, sigma());
     lags.push_front(y);
     lags.pop_back();
     ans.push_back(y);
   }
   return ans;
 }
예제 #2
0
void IterTest::iter3()
{
  typedef vector<const char*> Vec;
  Vec v; // Vector of character strings.
  v.push_back("zippy"); // First element.
  v.push_back("motorboy"); // Second element.
  Vec::reverse_iterator it;
  unsigned counter = 0;
  for (it = v.rbegin(); it != v.rend(); ++it, ++counter) {
    switch (counter) {
      case 1:
        CPPUNIT_ASSERT(!strcmp(*it, "zippy"));
        break;
      case 0:
        CPPUNIT_ASSERT(!strcmp(*it, "motorboy"));
        break;
      default:
        CPPUNIT_FAIL;
    }
  }
}
예제 #3
0
파일: path.hpp 프로젝트: Tkachov/ceu_pingus
 reverse_iterator rbegin() { return vec.rbegin(); }