Beispiel #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());
  }
}
Beispiel #2
0
int compute_M_shift_end(double new_t_end, int k, int new_position, int flavor_rem, MAT & M,
 const operator_container_t & creation_operators, const HYB & F,
 double BETA, SCALAR det_rat) {

  std::vector<SCALAR> R(M.size1(), 0), M_k(M.size1(), 0), Fe(M.size1(), 0);

  operator_container_t::const_iterator itc = creation_operators.begin();
  for (int i = 0; i < (int) M_k.size(); i++) {
    M_k[i] = M(i, k);
    Fe[i] = interpolate_F(new_t_end - itc->time(), BETA, F[flavor_rem][itc->flavor()]);
    itc++;
  }
  for (int i = 0; i < (int) R.size(); i++) {
    if (i != k) {
      for (int j = 0; j < (int) R.size(); j++)
        R[i] += Fe[j] * M(j, i);
    }
  }
  for (int m = 0; m < (int) M.size1(); m++) {
    if (m != k) {
      for (int n = 0; n < (int) M.size1(); n++) {
        M(n, m) -= M_k[n] * R[m] / det_rat;
      }
    } else {
      for (int n = 0; n < (int) M.size1(); n++) {
        M(n, m) = M_k[n] / det_rat;
      }
    }
  }

  //swap column
  move_column(M, k, new_position);

  return std::abs(k-new_position);
}  
Beispiel #3
0
typename MAT::type
det_rat_row_column_up(int flavor_ins, int flavor_rem, double t_ins, double t_rem, int row, int column, const MAT & M,
  const operator_container_t& creation_operators, const operator_container_t& annihilation_operators, const HYB& F, MAT2& sign_Fs, MAT2& Fe_M, double BETA) {

  typedef typename MAT::type SCALAR;
  
  const double sign=((row+column)%2==0 ? 1 : -1);
  
  if (annihilation_operators.size()>0) {
    operator_container_t::iterator it_c=creation_operators.begin();
    operator_container_t::iterator it_a=annihilation_operators.begin();
    Eigen::Matrix<SCALAR,Eigen::Dynamic,Eigen::Dynamic> Fe(1,annihilation_operators.size());
    if (annihilation_operators.size()!=creation_operators.size()) {
      throw std::runtime_error("annihilation_operators.size()!=creation_operators.size() in det_rat_row_column_up");
    }

    for (int i=0; i<(int)creation_operators.size(); i++) {
      Fe(0,i) = interpolate_F(t_rem-it_c->time(), BETA, F[flavor_rem][it_c->flavor()]);
      sign_Fs(i,0) = sign*interpolate_F(it_a->time()-t_ins, BETA, F[(int)(it_a->flavor())][flavor_ins]);
      it_c++;
      it_a++;
    }
    
    Fe_M = Fe*M.block();
  
    return sign*interpolate_F(t_rem-t_ins, BETA, F[flavor_rem][flavor_ins])-(Fe_M*sign_Fs)(0,0);
  } else {
    return sign*interpolate_F(t_rem-t_ins, BETA, F[flavor_rem][flavor_ins]);
  }
}
Beispiel #4
0
int num_operators_in_range_open(const operator_container_t &operators, T t1, T t2) {
  namespace bll = boost::lambda;
  typedef operator_container_t::iterator Iterator;

  std::pair<Iterator, Iterator> ops_range
      = operators.range(
          std::min(t1, t2) < bll::_1, bll::_1 < std::max(t1, t2)
      );
  return std::distance(ops_range.first, ops_range.second);
}
Beispiel #5
0
SCALAR det_rat_shift_end(double new_t_end, int k, int flavor_rem, MAT & M,
 const operator_container_t & creation_operators, const HYB & F, double BETA) {

  SCALAR det_rat = 0;
  operator_container_t::const_iterator itc = creation_operators.begin();
  for (int i = 0; i < M.size1(); i++) {
    det_rat += interpolate_F(new_t_end - itc->time(), BETA, F[flavor_rem][itc->flavor()]) * M(i, k);
    itc++;
  }
  return det_rat;
}
Beispiel #6
0
SCALAR det_rat_shift_start(double new_t_start, int k, int flavor_ins,
 MAT & M, operator_container_t & annihilation_operators, const HYB & F, double BETA) {

  SCALAR det_rat = 0;
  operator_container_t::iterator ita = annihilation_operators.begin();
  for (int i = 0; i < M.size1(); i++) {
    det_rat += interpolate_F(ita->time() - new_t_start, BETA, F[ita->flavor()][flavor_ins]) * M(k, i);//right
    ita++;
  }

  return det_rat;
}
Beispiel #7
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
  );
}
Beispiel #8
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;
  }
}
Beispiel #9
0
int compute_M_shift_start(double new_t_start, int k, int new_position, int flavor_ins,
        MAT & M, const operator_container_t & annihilation_operators, const HYB & F, double BETA, SCALAR det_rat) {

  std::vector<SCALAR> R(M.size1(), 0), M_k(M.size1(), 0), Fs(M.size1(), 0);

  operator_container_t::const_iterator ita = annihilation_operators.begin();
  for (int i = 0; i < (int) M_k.size(); i++) {
    M_k[i] = M(k, i);
    Fs[i] = interpolate_F(ita->time() - new_t_start, BETA, F[ita->flavor()][flavor_ins]);
    ita++;
  }

  for (int i = 0; i < (int) R.size(); i++) {
    if (i != k) {
      for (int j = 0; j < (int) R.size(); j++)
        R[i] += M(i, j) * Fs[j];
    }
  }

  for (int n = 0; n < (int) M.size1(); n++) {
    if (n != k) {
      for (int m = 0; m < (int) M.size1(); m++) {
        M(n, m) -= M_k[m] * R[n] / det_rat;
      }
    } else {
      for (int m = 0; m < (int) M.size1(); m++) {
        M(n, m) = M_k[m] / det_rat;
      }
    }
  }

  //swap rows
  move_row(M, k, new_position);

  return std::abs(k-new_position);
}