Exemple #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;
   }
 }
 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;
   }
 }
 unsigned int neighbor(unsigned int s, unsigned int k) const {
   int x, y;
   boost::tie(x, y) = index2xy(s);
   int d = 1- 2 * (k & 1);
   return (k & 2) ? xy2index(x + d, y) : xy2index(x, y + d);
 }