CHROMA
block_couplings.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Caclulates the couplings between neighboring blocks given a displacement path
4  */
5 
6 #include "chromabase.h"
8 
9 namespace Chroma
10 {
11  LatticeInteger displace(const LatticeInteger& in,
12  const int len,
13  const int dir)
14  {
15  LatticeInteger out = in;
16  LatticeInteger tmp ;
17  if (len > 0)
18  for(int n = 0; n < len; ++n){
19  tmp = shift(out, FORWARD, dir);
20  out = tmp;
21  }
22  else // If length = or < 0. If length == 0, does nothing.
23  for(int n = 0; n > len; --n){
24  tmp = shift(out, BACKWARD, dir);
25  out = tmp;
26  }
27  return out;
28  }
29 
30  void displace(LatticeInteger& blk2,
31  const int len,
32  const multi1d<int>& disp)
33  {
34  for(int i=0; i < disp.size(); ++i)
35  if (disp[i] > 0){
36  int disp_dir = disp[i] - 1;
37  int disp_len = len;
38  blk2 = displace(blk2, disp_len, disp_dir);
39  }
40  else if (disp[i] < 0){
41  int disp_dir = -disp[i] - 1;
42  int disp_len = -len;
43  blk2 = displace(blk2, disp_len, disp_dir);
44  }
45  }
46 
47 
48  std::vector<int> block_couplings(const int b,
49  const Set& S,
50  const multi1d<int>& disp,
51  const int len)
52  {
53  std::vector<int> b_list;
54  LatticeInteger blk = zero;
55  LatticeInteger One = 1;
56  blk[S[b]] = One;
57 
58  for(int b2(0); b2 < S.numSubsets(); b2++)
59  {
60  LatticeInteger blk2 = zero;
61  blk2[S[b2]] = One;
62  //QDPIO::cout<<"Points in block "<<b2<<" "<<sum(blk2)<<std::endl;
63  displace(blk2,len,disp);
64 
65  int flag = toInt(sum(blk2*blk));
66  //QDPIO::cout<<"b2 ="<<b2<<" flag "<<flag << std::endl;
67  if(flag > 0)
68  b_list.push_back(b2);
69  }
70 
71  return b_list;
72  }
73 
74  bool blocks_couple(const multi1d<DisplacedBlock>& b,
75  const Set& S,
76  const int len,
77  int blocks_to_check)
78  {
79  if (blocks_to_check <= 0)
80  return false;
81 
82  LatticeInteger One = 1;
83  LatticeInteger flag = 1;
84 
85  if (blocks_to_check > b.size())
86  blocks_to_check = b.size();
87 
88  for(int k(0); k < blocks_to_check; k++)
89  {
90  LatticeInteger blk = zero;
91  blk[S[b[k].blk]] = One;
92  displace(blk,len,b[k].disp);
93  flag *= blk;
94  }
95 
96  //QDPIO::cout<<" Coupling flag "<<sum(flag)<<std::endl;
97  if (toBool(sum(flag) > 0))
98  return true;
99  else
100  return false;
101  }
102 
103  bool blocks_couple(const multi1d<DisplacedBlock>& b,
104  const Set& S,
105  const int len)
106  {
107  return blocks_couple(b,S,len,b.size());
108  }
109 
110 } // namespace Chroma
Caclulates the couplings between neighboring blocks given a displacement path.
Primary include file for CHROMA library code.
T displace(const multi1d< LatticeColorMatrix > &u, const T &psi, int length, int dir, const Subset &sub)
Apply a displacement operator to a lattice field.
Definition: displace.cc:41
unsigned n
Definition: ldumul_w.cc:36
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
bool blocks_couple(const multi1d< DisplacedBlock > &b, const Set &S, const int len, int blocks_to_check)
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
int i
Definition: pbg5p_w.cc:55
std::vector< int > block_couplings(const int b, const Set &S, const multi1d< int > &disp, const int len)
static QDP_ColorVector * out
Constructor.
Complex b
Definition: invbicg.cc:96
Double zero
Definition: invbicg.cc:106
static QDP_ColorVector * in
int k
Definition: invbicg.cc:119
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Double sum
Definition: qtopcor.cc:37