CHROMA
gramschm.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Gramm-Schmidt orthogonolization
3  */
4 
5 
6 #include "meas/eig/gramschm.h"
7 
8 namespace Chroma {
9 
10 
11 //! Gramm-Schmidt orthogonolization
12 /*!
13  * \ingroup eig
14  *
15  * Templated version
16  *
17  * Arguments:
18  * \param psi Pseudofermion field (Modify)
19  * \param vec subspace wrt orthog (Read)
20  * \param Nvec Number of vectors (Read)
21  * \param Npsi Number of source vectors (Read)
22  * \param sub Subset to use (Read)
23  */
24 
25 template< typename T>
26 void GramSchm_T(multi1d<T>& psi, const int Npsi,
27  const multi1d<T>& vec, const int Nvec,
28  const Subset& sub)
29 {
30  START_CODE();
31 
32  // if I was paranoid I'd assert that Npsi and Nvec are
33  // reasonable
34 #if 0
35  if ( Npsi > psi.size() || Nvec > vec.size() ) {
36  QDP_error_exit("Npsi and Nvec are out of range in GramSchm");
37  }
38 #endif
39 
40  for(int s = 0; s < Npsi; ++s) {
41  for(int i = 0; i < Nvec; ++i) {
42  Complex xp = innerProduct(vec[i], psi[s], sub);
43  psi[s][sub] -= vec[i] * xp;
44  }
45  }
46 
47  END_CODE();
48 }
49 
50 //! Gram Schmidt rothogonalisation
51 /*!
52  * \ingroup eig
53  *
54  * Orthogonalise single std::vector psi against
55  * the first Nvec vectors of vec
56  *
57  * Templated version
58  * Arguments:
59  * \param psi Pseudofermion field (Modify)
60  * \param vec subspace wrt orthog (Read)
61  * \param Nvec no of vectors to orthog against (Read)
62  * \param sub Subset to use (Read)
63  */
64 template <typename T>
65 void GramSchm_T(T& psi,
66  const multi1d<T>& vec,
67  const int Nvec,
68  const Subset& sub)
69 {
70 
71  START_CODE();
72 #if 0
73  if ( Nvec > vec.size() ) {
74  QDP_error_exit("Nvec out of range in GramSchm");
75  }
76 #endif
77  for(int i = 0; i < Nvec; ++i) {
78  Complex xp = innerProduct(vec[i], psi, sub);
79  psi[sub] -= vec[i] * xp;
80  }
81 
82  END_CODE();
83 }
84 
85 //! Gram Schmidt rothogonalisation
86 /*!
87  * \ingroup eig
88  *
89  * Orthogonalise single std::vector psi against
90  * the first Nvec vectors of vec
91  *
92  * Templated version
93  * Arguments:
94  * \param psi Pseudofermion field (Modify)
95  * \param vec subspace wrt orthog (Read)
96  * \param Nvec no of vectors to orthog against (Read)
97  * \param sub Subset to use (Read)
98  */
99 template <typename T>
100 void GramSchm_T(T& psi,
101  const T& vec,
102  const Subset& sub)
103 {
104 
105  START_CODE();
106 
107  Complex xp = innerProduct(vec, psi, sub);
108  psi[sub] -= vec * xp;
109 
110  END_CODE();
111 }
112 
113 
114 
115 //! Gramm-Schmidt orthogonolization
116 /*!
117  * \ingroup eig
118  *
119  * Arguments:
120  * \param psi Pseudofermion field (Modify)
121  * \param vec subspace wrt orthog (Read)
122  * \param Nvec Number of vectors (Read)
123  * \param Npsi Number of source vectors (Read)
124  * \param sub Subset to use (Read)
125  */
126 
127 void GramSchm(multi1d<LatticeFermion>& psi, const int Npsi,
128  const multi1d<LatticeFermion>& vec, const int Nvec,
129  const Subset& sub)
130 {
131  GramSchm_T(psi, Npsi, vec, Nvec, sub);
132 }
133 
134 //! Gram Schmidt rothogonalisation
135 /*!
136  * \ingroup eig
137  *
138  * Orthogonalise single std::vector psi against
139  * the first Nvec vectors of vec
140  *
141  * Arguments:
142  * \param psi Pseudofermion field (Modify)
143  * \param vec subspace wrt orthog (Read)
144  * \param Nvec no of vectors to orthog against (Read)
145  * \param sub Subset to use (Read)
146  */
147 void GramSchm(LatticeFermion& psi,
148  const multi1d<LatticeFermion>& vec,
149  const int Nvec,
150  const Subset& sub)
151 {
152  START_CODE();
153 
154  GramSchm_T(psi, vec, Nvec, sub);
155 
156  END_CODE();
157 }
158 
159 //! Gram Schmidt rothogonalisation
160 /*!
161  * \ingroup eig
162  *
163  * Orthogonalise single std::vector psi against
164  * the first Nvec vectors of vec
165  *
166  * Arguments:
167  * \param psi Pseudofermion field (Modify)
168  * \param vec subspace wrt orthog (Read)
169  * \param Nvec no of vectors to orthog against (Read)
170  * \param sub Subset to use (Read)
171  */
172 void GramSchm(LatticeColorVector& psi,
173  const multi1d<LatticeColorVector>& vec,
174  const int Nvec,
175  const Subset& sub)
176 {
177  START_CODE();
178 
179  GramSchm_T(psi, vec, Nvec, sub);
180 
181  END_CODE();
182 }
183 
184 //! Gram Schmidt rothogonalisation
185 /*!
186  * \ingroup eig
187  *
188  * Convenience function: Orthogonalise all vectors of psi against
189  * the first Nvec vectors of vec
190  *
191  * Arguments:
192  * \param psi Pseudofermion field (Modify)
193  * \param vec subspace wrt orthog (Read)
194  * \param Nvec Number of vectors (Read)
195  * \param sub Subset to use (Read)
196  */
197 void GramSchm(multi1d<LatticeFermion>& psi,
198  const multi1d<LatticeFermion>& vec, const int Nvec,
199  const Subset& sub)
200 {
201  GramSchm_T(psi, psi.size(), vec, Nvec, sub);
202 }
203 
204 
205 
206 //! Gram Schmidt rothogonalisation
207 /*!
208  * \ingroup eig
209  *
210  * Convenience function: Orthogonalise all vectors of psi against
211  * the all the vectors of vec
212  *
213  * Arguments:
214  * \param psi Pseudofermion field (Modify)
215  * \param vec subspace wrt orthog (Read)
216  * \param sub Subset to use (Read)
217  */
218 void GramSchm(multi1d<LatticeFermion>& psi,
219  const multi1d<LatticeFermion>& vec,
220  const Subset& sub)
221 {
222  GramSchm_T(psi, psi.size(), vec, vec.size(), sub);
223 }
224 
225 //! Gram Schmidt rothogonalisation
226 /*!
227  * \ingroup eig
228  *
229  * Convenience function: Orthogonalise single std::vector psi against
230  * all the vectors of vec
231  *
232  * Arguments:
233  * \param psi Pseudofermion field (Modify)
234  * \param vec subspace wrt orthog (Read)
235  * \param Nvec no of vectors to orthog against (Read)
236  * \param sub Subset to use (Read)
237  */
238 void GramSchm(LatticeFermion& psi,
239  const multi1d<LatticeFermion>& vec,
240  const Subset& sub)
241 {
242  GramSchm_T(psi, vec, vec.size(), sub);
243 }
244 
245 
246 //! Gram Schmidt rothogonalisation
247 /*!
248  * \ingroup eig
249  *
250  * Orthogonalise single std::vector psi against
251  * the first Nvec vectors of vec
252  *
253  * Templated version
254  * Arguments:
255  * \param psi Pseudofermion field (Modify)
256  * \param vec subspace wrt orthog (Read)
257  * \param Nvec no of vectors to orthog against (Read)
258  * \param sub Subset to use (Read)
259  */
260 void GramSchm(LatticeFermion& psi,
261  const LatticeFermion& vec,
262  const Subset& sub)
263 {
264 
265  START_CODE();
266 
267  Complex xp = innerProduct(vec, psi, sub);
268  psi[sub] -= vec * xp;
269 
270  END_CODE();
271 }
272 
273 } // end namespace Chroma
Gramm-Schmidt orthogonolization.
void GramSchm(multi1d< LatticeFermion > &psi, const int Npsi, const multi1d< LatticeFermion > &vec, const int Nvec, const Subset &sub)
Gramm-Schmidt orthogonolization.
Definition: gramschm.cc:127
void GramSchm_T(multi1d< T > &psi, const int Npsi, const multi1d< T > &vec, const int Nvec, const Subset &sub)
Gramm-Schmidt orthogonolization.
Definition: gramschm.cc:26
BinaryReturn< C1, C2, FnInnerProduct >::Type_t innerProduct(const QDPSubType< T1, C1 > &s1, const QDPType< T2, C2 > &s2)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
LinOpSysSolverMGProtoClover::T T
int i
Definition: pbg5p_w.cc:55
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
multi1d< LatticeFermion > s(Ncb)