Exemple #1
0
boost::tuple<int, operator_container_t::iterator, operator_container_t::iterator>
pick_up_pair(R &rng,
             const operator_container_t &c_operators,
             const operator_container_t &a_operators,
             int flavor_ins,
             int flavor_rem,
             double t1,
             double t2,
             double distance,
             double BETA) {
  namespace bll = boost::lambda;

  typedef operator_container_t::iterator it_t;

  //get views to operators in the window
  double tau_low = std::min(t1, t2);
  double tau_high = std::max(t1, t2);
  std::pair<operator_container_t::iterator, operator_container_t::iterator>
      crange = c_operators.range(tau_low <= bll::_1, bll::_1 <= tau_high);
  std::pair<operator_container_t::iterator, operator_container_t::iterator>
      arange = a_operators.range(tau_low <= bll::_1, bll::_1 <= tau_high);

  typedef std::list<std::pair<it_t, it_t> > pairs_t;
  pairs_t pairs;
  int num_pairs = 0;

  for (operator_container_t::iterator it_c = crange.first; it_c != crange.second; ++it_c) {
    if (it_c->flavor() != flavor_ins) {
      continue;
    }
    for (operator_container_t::iterator it_a = arange.first; it_a != arange.second; ++it_a) {
      if (it_a->flavor() != flavor_rem) {
        continue;
      }
      if (std::abs(it_c->time() - it_a->time()) <= distance) {
        pairs.push_back(std::make_pair(it_c, it_a));
        ++num_pairs;
      }
    }
  }

  if (num_pairs > 0) {
    int pos = (int) (rng() * num_pairs);
    pairs_t::iterator it_p = pairs.begin();
    std::advance(it_p, pos);
    return boost::make_tuple(num_pairs, (*it_p).first, (*it_p).second);
  } else {
    return boost::make_tuple(0, c_operators.end(), a_operators.end());
  }
}
Exemple #2
0
void construct_blas_matrix(MAT & M, const operator_container_t &creation_operators,
  const operator_container_t &annihilation_operators, double BETA, const HYB & F)
{

  int N = creation_operators.size();
  M.resize(N, N);
  int row = -1;
  int column = -1;
  for (operator_container_t::iterator ita = annihilation_operators.begin(); ita != annihilation_operators.end(); ita++) {
    row++;
    for (operator_container_t::iterator itc = creation_operators.begin(); itc != creation_operators.end(); itc++) {
      column++;

      double argument = ita->time() - itc->time();
      double sign = 1;
      if (argument < 0) {
        argument += BETA;
        sign = -1;
      }
      M(row, column) = interpolate_F(argument, BETA, F[ita->flavor()][itc->flavor()]) * sign;
    }
    column = -1;
  }
}
Exemple #3
0
inline
double make_set_impl(const operator_container_t &annihilation_operators, double BETA, double dtau, std::set<boost::tuple<double,int,double> >& annset) {
  int row = -1;
  annset.clear();
  int num_op_shifted = 0;
  double perm = 1.0;
  for (operator_container_t::iterator ita = annihilation_operators.begin(); ita != annihilation_operators.end(); ita++) {
    row++;
    double p = 1.0;
    double t = ita->time() + dtau;
    if (t > BETA) {
      t -= BETA;
      p = -1.0;
      perm *= -1;
      ++num_op_shifted;
    }
    annset.insert(boost::make_tuple(t,row,p));
  }
  return perm * (
                 ((annihilation_operators.size()-num_op_shifted)*num_op_shifted)%2==0 ? 1 : -1
  );
}