Ejemplo n.º 1
0
 void init() {
   neighbors_.resize(num_sites());
   source_.resize(num_bonds());
   target_.resize(num_bonds());
   site_phase_.resize(num_sites());
   bond_phase_.resize(num_bonds());
   for (unsigned int s = 0; s < num_sites(); ++s) {
     int x, y;
     boost::tie(x, y) = index2xy(s);
     site_phase_[s] = 2.0 * ((x + y) % 2) - 1.0;
     for (unsigned int k = 0; k < 4; ++k) {
       int d = 1- int(k & 2);
       neighbors_[s][k] = ((k & 1) == 0) ? xy2index(x + d, y) : xy2index(x, y + d);
     }
   }
   for (unsigned int b = 0; b < num_bonds(); ++b) {
     unsigned int s = b / 2;
     int x, y;
     boost::tie(x, y) = index2xy(s);
     unsigned int t;
     if (b % 2 == 0) {
       t = xy2index(x + 1, y); // target right
       bond_phase_[b] = 2.0 * ((b / 2) % 2) - 1.0;
     } else {
       t = xy2index(x, y + 1); // target below
       bond_phase_[b] = 2.0 * ((b / length_x_ / 2) % 2) - 1.0;
     }
     source_[b] = s;
     target_[b] = t;
   }
 }
Ejemplo n.º 2
0
 void init() {
   source_.resize(num_bonds());
   target_.resize(num_bonds());
   site_phase_.resize(num_sites());
   bond_phase_.resize(num_bonds());
   for (unsigned int s = 0; s < num_sites(); ++s) {
     int x, y;
     boost::tie(x, y) = index2xy(s);
     site_phase_[s] = 2 * ((x + y) % 2) - 1;
   }
   for (unsigned int b = 0; b < num_bonds(); ++b) {
     unsigned int s = b / 2;
     int x, y;
     boost::tie(x, y) = index2xy(s);
     unsigned int t;
     if (b % 2 == 0) {
       t = xy2index(x + 1, y); // target right
       bond_phase_[b] = 2.0 * ((b / 2) % 2) - 1.0;
     } else {
       t = xy2index(x, y + 1); // target below
       bond_phase_[b] = 2.0 * ((b / length_x_ / 2) % 2) - 1.0;
     }
     source_[b] = s;
     target_[b] = t;
   }
 }
Ejemplo n.º 3
0
double hamiltonian::multiply(const double *v1, double *v0) const {
  double prdct = 0;
  for (int k = 0; k < num_bonds(); ++k) {
    int isite1 = ipair_[k * 2];
    int isite2 = ipair_[k * 2 + 1];
    int is1 = 1 << isite1;
    int is2 = 1 << isite2;
    int is = is1 + is2;
    double wght = 0.5 * bondwt_[k] * zrtio_[k];
    for (int j = 0; j < dimension(); ++j) {
      int ibit = config(j) & is;
      double factor, offdg;
      if (ibit == 0 || ibit == is) {
        v0[j] -= wght * v1[j];
        factor = 1;
        offdg = 0;
      } else {
        v0[j] += wght * v1[j];
        double temp = v1[config2index(config(j) ^ is)] * bondwt_[k];
        v0[j] -= temp;
        factor = -1;
        offdg = -temp * v1[j];
      }
      prdct += - factor * wght * v1[j] * v1[j] + offdg;
    }
  }
  return prdct;
}