CHROMA
group_baryon_operator_w.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Construct group baryon operators
4  */
5 
6 #ifndef __group_baryon_operator_w_h__
7 #define __group_baryon_operator_w_h__
8 
9 #include "handle.h"
12 #include "io/xml_group_reader.h"
13 #include "io/qprop_io.h"
14 #include "io/cfgtype_io.h"
23 #include "meas/sources/zN_src.h"
24 
25 namespace Chroma
26 {
27 //#define MAKE_SOURCE_OPERATORS
28 #define MAKE_SINK_OPERATORS
29 #define PARALLEL_RUN
30 //#define REDUCETOTIMEDILUTION 1
31 
32  //! Name and registration
33  /*! @ingroup hadron */
34  namespace GroupBaryonOperatorEnv
35  {
36  bool registerAll();
37  //! Group baryon operator parameters
38  /*! @ingroup hadron */
39 
41  {
42  //! Serialize generalized operator object
43  multi1d<Complex> serialize();
44  //! Baryon operator
46  {
47  //! Possible operator index
49  {
50  //! Baryon operator element
52  {
53  multi2d<DComplex> elem;
54  };
55  multi1d<BaryonOperatorElement_t> ind;
56  };
57  multi3d<BaryonOperatorIndex_t> op;
58  };
59  Seed seed_l; /*!< Id of left quark */
60  Seed seed_m; /*!< Id of middle quark */
61  Seed seed_r; /*!< Id of right quark */
62 
63  multi1d< multi1d<int> > quarkOrderings; // [ index ][ LMR ]=0,1,2
64  int mom2_max;
65  int j_decay;
66  int version;
67  multi1d<BaryonOperatorInsertion_t> orderings;
68  };
69 
70  int DilSwap( int ord, int i, int j, int k, int which );
71  int DilSwapInv( int ord, int i, int j, int k, int which );
72 
73  struct Params
74  {
75  Params();
76  Params( XMLReader& in, const std::string& path );
77  void writeXML( XMLWriter& in, const std::string& path ) const;
78 
81 
82  struct param_t
83  {
84  std::string baryon_operator; // NUCLEON, DELTA
85  }
87 
89  int j_decay;
90 
91  std::string InputFileName; // Input generated by "Gen_Input_For_All2All_Baryons2.pl"
92  multi1d<std::string> Names; // Names of operators ... "G1g_L3_TDT_15"
93  multi1d<int> nrow; // lattice size Nx Ny Nz Nt
95  int Noperators; // total number of baryon operators to be constructed
96  int NQQQs; // total number of QQQ's
98  multi1d< multi1d<int> > SrcOrderings; // [ index ][ LMR ]=0,1,2
99  multi1d< multi1d<int> > SnkOrderings; // [ index ][ LMR ]=0,1,2
100 
101  // the hybrid-list (dilution) sizes
102  multi1d< multi1d<int> > NH; // NH[ ord ][ 0,1,2 ]
103 
104  struct Qprop_t // Prop_t
105  {
106  struct Solutions_t // Operator_t
107  {
108  multi1d<std::string> soln_file_names; // soln_files
109  Seed seed;
110  };
111  multi1d<Solutions_t> solns; // quark index (0,1,2) op
113  }
114  qprop; // prop
115 
116  //! Structure holding a source and its solutions
118  {
119  //! Structure holding solutions
121  {
122  LatticeFermion source;
123  LatticeFermion soln;
126  };
127  int j_decay;
128  Seed seed;
129  multi1d<QuarkSolution_t> dilutions;
130  };
131 
133  {
135  multi1d<LatticeColorMatrix> u;
137  }
139 
140  struct dilution_t
141  {
142  int N; /*!< Z(N) */
143  multi1d<int> spatial_mask_size; /*!< Spatial size of periodic mask */
144  multi1d< multi1d<int> > spatial_mask; /*!< Sites included in site mask */
145  multi1d<int> color_mask; /*!< Color size of periodic mask */
146  multi1d<int> spin_mask; /*!< Spin size of periodic mask */
147  int j_decay; // is 3
148  int t_source; // assuming time-dilution
149  Seed ran_seed;
150  };
151 
152  multi1d<dilution_t> dilution;
153 
155  {
160  }
162 
164 
165  }; // end struct Params
166 
167 
168  //! Structure holding a source and its solutions
170  {
171  //! Structure holding solutions
173  {
174  LatticeFermion source;
175  LatticeFermion soln;
178  };
179  int j_decay;
180  Seed seed;
181  multi1d<QuarkSolution_t> dilutions;
182  };
183 
184 
185  class GroupBaryonOp //: public BaryonOperator<LatticeFermion>
186  {
187  public:
189  {}
191  {}
192  //! Baryon operator
194 
197  }; // end class GroupBaryonOp
198 
199 
200  /*! @ingroup hadron
201  *
202  * Create a group theoretical construction baryon
203  */
204  class GroupBaryonQQQ : public BaryonOperator<LatticeFermion>
205  {
206  public:
207  void init( const Params& p );
208  //! Full constructor
209  GroupBaryonQQQ( const Params& p );
211  // ?
213 
214  //! Compute the operator
215  multi1d<LatticeComplex> operator() ( const LatticeFermion& quark1,
216  const LatticeFermion& quark2,
217  const LatticeFermion& quark3,
218  int* qindices,
219  enum PlusMinus isign
220  ) const;
221 
222  LatticeComplex operator() ( const LatticeFermion& quark1,
223  const LatticeFermion& quark2,
224  const LatticeFermion& quark3,
225  int* qindices
226  ) const;
227  //! Compute the operator
228  multi1d<LatticeComplex> operator() ( const LatticeFermion& quark1,
229  const LatticeFermion& quark2,
230  const LatticeFermion& quark3,
231  enum PlusMinus isign
232  ) const;
233 
234  LatticeComplex operator() ( const LatticeFermion& quark1,
235  const LatticeFermion& quark2,
236  const LatticeFermion& quark3
237  ) const;
238 
239  struct QuarkTerm_t
240  {
241  int displacement; /*!< Orig plus/minus 1-based directional displacements */
242  int spin; /*!< 0-based spin index */
243  int disp_dir; /*!< 0-based direction */
244  int disp_len; /*!< 0-based length */
245  int disp_ind; // disp index 0=0, 1=1, 2=2, 3=3, 4=-1, 5=-2, 6=-3
246  };
247  multi1d<QuarkTerm_t> quark; /*!< Displacement and spin for each quark */
248 
249  // Number of Baryon operators requiring this QQQ
250  int NBaryonOps; // this is the size of the arrays below
251  multi1d<DComplex> coef; // coef[ local_BOpIndex ]
252  multi1d<int> whichBaryonOps; // whichBaryonOps[local_BopIndex] of size NBaryonOps
253  multi1d<std::string> Names; // and their names
254  multi1d<GroupBaryonOp*> baryon; // pointer to the GroupBaryonOp array
255 
256  //private:
257  //! Hide partial constructor
258  GroupBaryonQQQ();
260  SpinMatrix spin_rotate_mat;
261 
262  //protected:
263  //Handle< QuarkSourceSink<LatticeFermion> > sourceSmearing;
264  //Handle< QuarkSourceSink<LatticeFermion> > sinkSmearing;
265 
266  //! Construct array of std::maps of displacements
267  void displaceQuarks( multi1d< std::map<int, LatticeFermion> >& disp_quarks,
268  const multi1d<LatticeFermion>& q,
269  int* qindices
270  ) const;
271  //! First smear then displace the quarks
272  void smearDisplaceQuarks( multi1d< std::map<int, LatticeFermion> >& disp_quarks,
273  const LatticeFermion& q1,
274  const LatticeFermion& q2,
275  const LatticeFermion& q3,
276  int* qindices
277  ) const;
278  //! Manipulate the quark fields
279  void quarkManip( multi1d< std::map<int, LatticeFermion> >& disp_quarks,
280  const LatticeFermion& q1,
281  const LatticeFermion& q2,
282  const LatticeFermion& q3,
283  int* qindices
284  ) const;
285  //! The spin basis matrix to goto Dirac
286  const SpinMatrix& rotateMat() const
287  {
288  return spin_rotate_mat;
289  }
290  LatticeFermion operator() ( Params::dilution_t ) const;
291 
292  }; // end class GroupBaryonQQQ
293 
294  //
295  // read in input parameters from an ASCII file
296  //
297  void ReadTextInput( Params&, multi1d<GroupBaryonOp>&, multi1d<GroupBaryonOp>&,
298  multi1d<GroupBaryonQQQ>&, multi1d<GroupBaryonQQQ>& );
299 
300  //! Reader
301  /*! @ingroup hadron */
302 
303  void read( XMLReader& xml, const std::string& path,
305  void read( XMLReader& xml, const std::string& path,
307  void read( XMLReader& xml, const std::string& path,
309 
310  } // end namespace GroupBaryonOperatorEnv
311 
312  //! Writer
313  /*! @ingroup hadron */
314  void write( XMLWriter& xml, const std::string& path,
315  const GroupBaryonOperatorEnv::Params& param );
316 
317 } // end namespace Chroma
318 
319 //
320 // Perl script to generate the input file
321 //
322 /*
323 #! /usr/bin/perl
324 #------------------------------------------------------------------------
325 # The output file of this script ... the name is kind of important
326 # because the xml input file is not ready to go yet and hence the name
327 # will be used to identify the record of the inputs
328 $OutputFileName = "Chroma_Input.txt";
329 #------------------------------------------------------------------------
330 # Some other files that will be generated ...
331 $SortedListFileName = "SortedChannelList.txt";
332  $ListOfNames = "NamesOfOperators.txt";
333 #------------------------------------------------------------------------
334 $ProjCoeffDir = "$ENV{HOME}/src2/work2/projection_coefficients/Nucleons";
335 #------------------------------------------------------------------------
336 # Input file for operator indices (note that the range op - doesn't work)
337 # an example is given below ...
338 $OperatorIndicesFile = "from_point2all.in";
339 #------------------------------------------------------------------------
340 # Lattice Size
341 @Nsize = ( 12, 12, 12, 48 );
342 $Nt = $Nsize[ 3 ];
343 #------------------------------------------------------------------------
344 # Hybrid list size
345 for(my $q=1; $q<=3; ++$q)
346 {
347  $NTdil[$q] = $Nt; $NCdil[$q] = 1; $NSdil[$q] = 1; $NXdil[$q] = 1;
348  #$NTdil[$q] = $Nt; $NCdil[$q] = 3; $NSdil[$q] = 4; $NXdil[$q] = 1;
349 }
350 for(my $q=1; $q<=3; ++$q){ $NH[$q]=$NTdil[$q]*$NCdil[$q]*$NSdil[$q]*$NXdil[$q]; }
351 #
352 @Ndil = ( $NH[1], $NH[2], $NH[3] );
353 #------------------------------------------------------------------------
354 # Different displacement lengths
355 @DispLengths = ( 3 );
356 # all the channels
357 @Channels = ( 'G1g', 'G1u', 'G2g', 'G2u', 'Hg', 'Hu' );
358 #------------------------------------------------------------------------
359 # Solution file names arg: stub, time-dil, colour-dil, spin-dil, space-dil, ".lime"
360 $qstub = "wl_6p1_12_48_m0p305_nu0p902"; $qext = ".lime";
361 @qpropFileNames = ();
362 for(my $q=1; $q<=3; ++$q)
363 {
364  @temp = &make_qprop_names( "${qstub}${q}",$NTdil[$q],$NCdil[$q],$NSdil[$q],$NXdil[$q],$qext );
365  push( @qpropFileNames, @temp );
366 }
367 #------------------------------------------------------------------------
368 # Nucleon correlation function is re-written as,
369 #
370 # (N+) (I) ijk _ijk _ijk _ijk
371 # C = c B (t) { 2 B ___ - B ___ - B ___
372 # IJ[012] mnt I<mnt> J<mnt> J<mtn> J<nmt>
373 # _ijk _ijk _ijk
374 # + ( 2 B ___ - B ___ - B ___ )
375 # J<tnm> J<tmn> J<ntm>
376 # _(J)
377 # }(t0) c___
378 # mnt
379 #------------------------------------------------------------------------
380 # Input File Example: (from_point2all.in)
381 #
382 # <G1>
383 # SS 0 1 2
384 # SD 0 11 17 20 22
385 # DDI 0 4 5 9 12
386 # DDL 1 4 10 15 21
387 # TDT 3 5 9 11 25
388 # <G2>
389 # SS
390 # SD 0 1 2 6 7
391 # DDI 1 4 5 6 7
392 # DDL 32 37 41 52 61
393 # TDT 1 33 45 51 61
394 # <H>
395 # SS 0
396 # SD 7 9 10 13 31
397 # DDI 8 15 17 23 31
398 # DDL 47 54 84 113 124
399 # TDT 35 71 86 95 104
400 #
401 #------------------------------------------------------------------------
402 # Nothing from here needs to be touched
403 #------------------------------------------------------------------------
404 #
405 # Permutations of noise indices
406 #
407 $NumSrcPerm = 6; # number of perm of 0,1,2 for SOURCE
408  @srcOrder0 = ( 0, 1, 2 ); $SrcPerm{0} = "srcOrder0";
409  @srcOrder1 = ( 2, 1, 0 ); $SrcPerm{1} = "srcOrder1";
410  @srcOrder2 = ( 0, 2, 1 ); $SrcPerm{2} = "srcOrder2";
411  @srcOrder3 = ( 1, 0, 2 ); $SrcPerm{3} = "srcOrder3";
412  @srcOrder4 = ( 1, 2, 0 ); $SrcPerm{4} = "srcOrder4";
413  @srcOrder5 = ( 2, 0, 1 ); $SrcPerm{5} = "srcOrder5";
414 $NumSnkPerm = 1; # number of perm of 0,1,2 for SINK
415  @snkOrder0 = ( 0, 1, 2 ); $SnkPerm{0} = "snkOrder0";
416 #------------------------------------------------------------------------
417 @ListOfIrreps = ( 'G1', 'G2', 'H' ); # in the input file
418 @OperatorTypes = ( 'SS', 'SD', 'DDI', 'DDL', 'TDT' );
419 $LongForm{'SS'} = "Single_Site";
420 $LongForm{'SD'} = "Singly_Displaced";
421 $LongForm{'DDI'} = "Doubly_Displaced_I";
422 $LongForm{'DDL'} = "Doubly_Displaced_L";
423 $LongForm{'TDT'} = "Triply_Displaced_T";
424 $QNS{'G1g'} = 'G1'; $QNS{'G1u'} = 'G1';
425 $QNS{'G2g'} = 'G2'; $QNS{'G2u'} = 'G2';
426  $QNS{'Hg'} = 'H'; $QNS{'Hu'} = 'H';
427 #------------------------------------------------------------------------
428 #
429 # First get all of the operator indices
430 #
431 if ( 1 ) {
432  $Noperators = 0;
433  foreach $irrep ( @ListOfIrreps ) {
434  $name = $irrep.'ops'; # ex. G1ops
435  &GetOperatorList( $OperatorIndicesFile, ListOfIrreps, $irrep, $name );
436  foreach $type ( @OperatorTypes ) {
437  $name2 = $name.'List_'.$type; # ex. G1opsList_SS
438  @$name2 = &GetNums( $$name{"$type"} ); # ex. $G1ops{"SS"}
439  foreach $channel ( @Channels ) {
440  if ( ($QNS{$channel} eq $irrep) && (@$name2 ne {}) ) {
441  if ( $type eq 'SS' ) {
442  $Noperators += (scalar(@$name2));
443  } else {
444  $Noperators += (scalar(@$name2)) * (scalar(@DispLengths));
445  } } } } }
446 }
447 #
448 # Generate the hash table
449 #
450 if ( 1 ) {
451  open(HASH,">Hashes");
452  foreach my $QN ( @Channels )
453  {
454  $QNS = $QNS{"$QN"};
455  foreach my $OperatorType ( @OperatorTypes )
456  {
457  $InputFileName = "${ProjCoeffDir}/${QN}/$LongForm{\"$OperatorType\"}";
458  $ListName = "${QNS}opsList_${OperatorType}";
459  foreach my $OperatorIndx ( @${ListName} )
460  {
461  $Nterms = 0;
462  ( $Nterms, %list ) = &ReadProjCoeffFile( $InputFileName, $OperatorIndx );
463  foreach my $DispLength ( @DispLengths )
464  {
465  #
466  # SS L1
467  #
468  if ( (${OperatorType}eq'SS')and(${DispLength}==${DispLengths[0]}) )
469  {
470  for (my $i=0; $i<$Nterms; ++$i)
471  {
472  @IJK = &GetNums( $list{$i} );
473  $line = '';
474  # DO NOT use the coefficients here
475  for (my $j=0; $j<($#IJK-1); ++$j) { $line = $line . "$IJK[$j] "; }
476  $line = $line . "0";
477  #$line = $line . ${DispLength};
478  $hash = &HashCode($line);
479  printf(HASH "${hash}\n");
480  }
481  }
482  #
483  # SD L1 L2 : DDI L1 L2 : DDL L1 L2 : TDT L1 L2
484  #
485  if ( ${OperatorType} ne 'SS' )
486  {
487  for (my $i=0; $i<$Nterms; ++$i)
488  {
489  @IJK = &GetNums( $list{$i} );
490  $line = '';
491  # DO NOT use the coefficients here
492  for (my $j=0; $j<($#IJK-1); ++$j) { $line = $line . "$IJK[$j] "; }
493  $line = $line . ${DispLength};
494  $hash = &HashCode($line);
495  printf(HASH "${hash}\n");
496  }
497  }
498  } # end foreach $DispLength ( @DispLengths )
499  } # end foreach $OperatorIndx ( @${ListName} )
500  } # end foreach $OperatorType ( @OperatorTypes )
501  } # end foreach $QN ( @Channels )
502  close(HASH);
503 
504  system( "sort Hashes | uniq > Hashes2" );
505  open(FILE,"<Hashes2");
506  @UniqHashes = ();
507  while (<FILE>) { chop($_); push( @UniqHashes, $_ ); }
508  close(FILE);
509  system("rm Hashes Hashes2");
510 }
511 #
512 # Main Loop over Irreps
513 #
514 foreach $QN ( @Channels )
515 {
516  &MakeOpTable($QN);
517 }
518 #
519 # Sorted List (according to channel name)
520 # "Name re im # s1 s2 s3 d1 d2 d3 dL"
521 #
522 if ( 1 ) {
523  open(FILE,">$SortedListFileName");
524  open(FILENAMES,">$ListOfNames");
525  foreach my $QN ( @Channels )
526  {
527  $QNS = $QNS{"$QN"};
528  foreach my $OperatorType ( @OperatorTypes )
529  {
530  $ListName = "${QNS}opsList_${OperatorType}";
531  $InputFileName = "${ProjCoeffDir}/${QN}/$LongForm{\"$OperatorType\"}";
532  foreach my $OperatorIndx ( @${ListName} )
533  {
534  ( $Nterms, %list ) = &ReadProjCoeffFile( $InputFileName, $OperatorIndx );
535  for (my $i=0; $i<$Nterms; ++$i)
536  {
537  @IJK = &GetNums( $list{$i} );
538  foreach my $DispLength ( @DispLengths )
539  {
540  $line = '';
541  for (my $j=0; $j<($#IJK-1); ++$j) { $line=$line."$IJK[$j] "; }
542  if(($OperatorType eq 'SS')&&(${DispLength}==${DispLengths[0]}))
543  {
544  $line=$line." 0";
545  } else {
546  $line=$line." ${DispLength}";
547  }
548  $hash = &HashCode($line);
549  for (my $r=0; $r <= $#{$IrrepsInHash{$hash}}; $r=$r+3)
550  {
551  $newline = "${$IrrepsInHash{$hash}}[$r] ${$IrrepsInHash{$hash}}[$r+1] ${$IrrepsInHash{$hash}}[$r+2] ${line}";
552  printf(FILE "$newline\n");
553  printf(FILENAMES "${$IrrepsInHash{$hash}}[$r]\n");
554  } } } } } }
555  close(FILE);
556  close(FILENAME);
557  system("sort ${SortedListFileName} | uniq > mytemp");
558  system("mv mytemp ${SortedListFileName}");
559  system("sort ${ListOfNames} | uniq > myDistinctOperators");
560  open(FILE,"<myDistinctOperators");
561  open(OUTFILE,">DistinctOperators");
562  $GlobalNumbering = 0;
563  while (<FILE>) {
564  chop($_);
565  printf(OUTFILE "%-3i %s\n",$GlobalNumbering,$_);
566  $OperatorNames{"$_"} = $GlobalNumbering;
567  $GlobalNumbering++;
568  }
569  close(FILE);
570  close(OUTFILE);
571  system("wc -l DistinctOperators > mytemp2");
572  system("cat mytemp2 DistinctOperators > ${ListOfNames}");
573  system("rm -f mytemp2 myDistinctOperators DistinctOperators");
574 }
575 #
576 # Output Results to File
577 # "# s1 s2 s3 d1 d2 d3 dL NtermsNeedingThisComb"
578 # "index" corresponding to "Name" (check NamesOfOperators.txt)
579 # "re im "
580 #
581 if ( 1 ) {
582  open(FILE,">${OutputFileName}");
583  printf(FILE "${Nsize[0]} ${Nsize[1]} ${Nsize[2]} ${Nsize[3]}\n");
584  printf(FILE "$NumSrcPerm\n");
585  for (my $i=0; $i < $NumSrcPerm; ++$i)
586  {
587  printf(FILE "${$SrcPerm{$i}}[0] ${$SrcPerm{$i}}[1] ${$SrcPerm{$i}}[2]\n");
588  }
589  # added so that XML and TXT input files are more similar
590  printf(FILE "$NumSnkPerm\n");
591  for (my $i=0; $i < $NumSnkPerm; ++$i)
592  {
593  printf(FILE "${$SnkPerm{$i}}[0] ${$SnkPerm{$i}}[1] ${$SnkPerm{$i}}[2]\n");
594  }
595  printf(FILE "${Ndil[0]} ${Ndil[1]} ${Ndil[2]}\n");
596  printf(FILE "${Noperators}\n");
597  # moved here so that XML and TXT input files are more similar
598  open(INFILE,"<${ListOfNames}");
599  $line = <INFILE>;
600  while ( <INFILE> )
601  {
602  printf(FILE "$_");
603  }
604  close(INFILE);
605  #
606  $NElemOps = scalar(@UniqHashes);
607  printf(FILE "${NElemOps}\n");
608  foreach $hash ( @UniqHashes )
609  {
610  $line = $InvHashCode{$hash}; # all 7 indices
611  @indices = &GetNums( $line );
612  printf(FILE "${hash} ");
613  PrintList2FILE( FILE, @indices );
614  my $N = ( scalar(@{$IrrepsInHash{$hash}}) ) / 3;
615  printf(FILE "${N}\n"); # number of ops which need this qqq
616  for (my $r=0; $r <= $#{$IrrepsInHash{$hash}}; $r=$r+3)
617  {
618  #printf(FILE "${$IrrepsInHash{$hash}}[$r]\n");
619  printf(FILE "$OperatorNames{${$IrrepsInHash{$hash}}[$r]}\n");
620  printf(FILE "${$IrrepsInHash{$hash}}[$r+1]");
621  printf(FILE " ${$IrrepsInHash{$hash}}[$r+2]\n");
622  }
623  }
624  for (my $i=0; $i <= $#{qpropFileNames}; ++$i)
625  {
626  printf(FILE "$qpropFileNames[$i]\n");
627  }
628  close(FILE);
629 }
630 
631 #===================================================================================
632 
633 # name s1 s2 s3 d1 d2 d3 h
634 # 0 1 2 3 4 5 6 7 (use with "sort list_by_hash_value keys %hasharray")
635 sub list_by_hash_value { ($shash{$a}[7]) <=> ($shash{$b}[7]); };
636 sub PrintList{ foreach $i (@_) { printf("%2s ",$i); } print "\n";};
637 sub PrintList2FILEN
638 { local *HANDLE = shift;
639  foreach$i(@_){printf(HANDLE "%2s ",$i);}printf(HANDLE "\n");
640 }
641 sub PrintList2FILE
642 { local *HANDLE = shift;
643  foreach$i(@_){printf(HANDLE "%2s ",$i);}
644 }
645 sub HashCode
646 { my ( $line ) = @_;
647  @in = &GetNums(@_); # s1 s2 s3 d1 d2 d3 dL
648  $hash_code = ( ( $in[0] - 1 ) << 17 ) # spins from 1
649  + ( ( $in[1] - 1 ) << 15 )
650  + ( ( $in[2] - 1 ) << 13 )
651  + ( ( $in[3] + 3 ) << 10 ) # displ dirs from -3
652  + ( ( $in[4] + 3 ) << 7 )
653  + ( ( $in[5] + 3 ) << 4 )
654  + ( $in[6] ); # disp length index from 1
655  $InvHashCode{$hash_code} = "$in[0] $in[1] $in[2] $in[3] $in[4] $in[5] $in[6]";
656  $GetHashCode{$line} = $hash_code;
657  return($hash_code);
658 }
659 sub MakeOpTable
660 { # Coefficient File: ${ProjCoeffDir}/${QN}/$LongForm{\"$OperatorType\"}
661  my($irrep,$type,$name,$name2,$IndexName,$ListName,$InputFileName);
662  my($Nterms,$line,$hash);
663  $QN = $_[0];
664  $QNS = $QNS{"$QN"};
665  print "$QNS $QN\n";
666  foreach my $DispLength ( @DispLengths ) {
667  foreach my $OperatorType ( @OperatorTypes ) {
668  $InputFileName = "${ProjCoeffDir}/${QN}/$LongForm{\"$OperatorType\"}";
669  $ListName = "${QNS}opsList_${OperatorType}";
670  if ( ${OperatorType} eq 'SS' ) {
671  if ( ${DispLength} == ${DispLengths[0]} ) {
672  foreach my $OperatorIndx ( @${ListName} ) {
673  $Nterms = 0;
674  ( $Nterms, %list ) = &ReadProjCoeffFile($InputFileName, $OperatorIndx);
675  $IndexName = "${OperatorType}_${OperatorIndx}";
676  for (my $i=0; $i<$Nterms; ++$i) {
677  @IJK = &GetNums( $list{$i} );
678  $line = '';
679  for (my $j=0; $j<($#IJK-1); ++$j) {
680  $line = $line . "$IJK[$j] ";
681  }
682  $line = $line . "0";
683  #$line = $line . ${DispLength};
684  $hash = &HashCode( $line );
685  push( @{$IrrepsInHash{$hash}}, "${QN}_L0_${IndexName}" );
686  #push( @{$IrrepsInHash{$hash}}, "${QN}_L${DispLength}_${IndexName}" );
687  push( @{$IrrepsInHash{$hash}}, $IJK[($#IJK-1)] );
688  push( @{$IrrepsInHash{$hash}}, $IJK[($#IJK)] );
689  } # end of going thru terms
690  } # end foreach OperatorIndx
691  } # end if (${DispLength} == ${DispLengths[0]})
692  } # end if SS
693  if ( ${OperatorType} ne 'SS' ) {
694  foreach my $OperatorIndx ( @${ListName} ) {
695  $Nterms = 0;
696  ( $Nterms, %list ) = &ReadProjCoeffFile($InputFileName, $OperatorIndx);
697  $IndexName = "${OperatorType}_${OperatorIndx}";
698  for (my $i=0; $i<$Nterms; ++$i) {
699  @IJK = &GetNums( $list{$i} );
700  $line = '';
701  for (my $j=0; $j<($#IJK-1); ++$j) {
702  $line = $line . "$IJK[$j] ";
703  }
704  $line = $line . "$DispLength";
705  $hash = &HashCode( $line );
706  push( @{$IrrepsInHash{$hash}}, "${QN}_L${DispLength}_${IndexName}" );
707  push( @{$IrrepsInHash{$hash}}, $IJK[($#IJK-1)] );
708  push( @{$IrrepsInHash{$hash}}, $IJK[($#IJK)] );
709  } # end of $i<Nterms loop
710  } # end of : foreach OperatorIndx
711  } # end of : ne SS
712  } # end OperatorType loop
713  } # end DispLength loop
714 };
715 sub ReadProjCoeffFile
716 { my ( $FileName, $TargetIndx ) = @_;
717  my($NumOps,$OpIndx,$Nterms_,$NTerms,$line,$k,$len);
718  open( PROJCOEF, "< $FileName" );
719  $NumOps = <PROJCOEF>; chop($NumOps); $NumOps*=1;
720  $OpIndx = -1; $Nterms_ = 0; $NTerms = 0; %mylist = ();
721  while( <PROJCOEF> )
722  { chomp;
723  $len = split;
724  if( $len == 1 ) {
725  ( $Nterms_ ) = split; $OpIndx++;
726  } else {
727  if( $OpIndx == $TargetIndx ) {
728  $line = $_;
729  my @entry = &GetNums($line);
730  $mylist{"0"}="$entry[0] $entry[1] $entry[2] $entry[3] $entry[4] $entry[5] $entry[6] $entry[7]";
731  for($k=1; $k < $Nterms_; ++$k) {
732  $line = <PROJCOEF>; chomp;
733  @entry = &GetNums($line);
734  $mylist{"$k"}="$entry[0] $entry[1] $entry[2] $entry[3] $entry[4] $entry[5] $entry[6] $entry[7]";
735  }
736  $NTerms = $Nterms_;
737  }
738  }
739  } close( PROJCOEF );
740  return( $NTerms, %mylist );
741 };
742 sub GetOperatorList
743 { my ( $filename, $list, $channel, $outputref ) = @_;
744  my ( $irrep, $line, $oplist );
745  open(FILE,"<$filename");
746  foreach $irrep ( @{$list} ) {
747  $line = <FILE>; # irrep
748  $line = <FILE>; chop($line);
749  if ( ($irrep eq "$channel") and ( $line ) ) {
750  ${$outputref}{'SS'} = $line; }
751  $line = <FILE>;
752  if ( ($irrep eq "$channel") and ( $line ) ) {
753  ${$outputref}{'SD'} = $line; }
754  $line = <FILE>;
755  if ( ($irrep eq "$channel") and ( $line ) ) {
756  ${$outputref}{'DDI'} = $line; }
757  $line = <FILE>;
758  if ( ($irrep eq "$channel") and ( $line ) ) {
759  ${$outputref}{'DDL'} = $line; }
760  $line = <FILE>;
761  if ( ($irrep eq "$channel") and ( $line ) ) {
762  ${$outputref}{'TDT'} = $line; }
763  } close(FILE);
764 };
765 sub RmTrail
766 { my($i,$j,$len,$c,$Out);
767  $i=0; $len=length($_[0]); $j=$len;
768  while($i<$len){ $c=substr($_[0],$j-1,1);
769  if($c =~ /[.0-9]/){$Out=substr($_[0],0,$len-$i);$i=$len;}$j--;$i++;}
770  $_[0]=$Out;
771 };
772 sub GetNums # ASCII separated by space, comma, semi-colon, colon
773 { my ( $line ) = @_; # can simplify this routine for ints only ...
774  my($k,$char,$i,$j,$num,$prev);
775  $k=0;$i=0;$j=0;$num='';$char='a';@ReturnThis=();# $j is counter
776  while(($i<=length($line))and($char ne "\n")and($char ne "")){
777  $char=substr($line,$i,1);if(($char eq ',')or($char eq ';')or
778  ($char eq ':')){if(length($num)>0){&RmTrail($num);
779  push(@ReturnThis,$num);}$num='';$j++;}else{if((($char eq '+')
780  or($char eq '-'))and(length($num)==0)){$num=$char;$k++;}else
781  {if($k>0){if($char=~/[0-9,.,E,e,D,d,\-,+]/){
782  $prev=substr($num,$k-1,1);if(not(($char eq '0')and(
783  ($prev eq '+')or($prev eq '-')))){if(($char eq 'D')or($prev eq 'd')
784  ){$num=$num.'E';$k++;}else{$num=$num.$char;$k++;}}}else{if(
785  length($num)>0){&RmTrail($num);push(@ReturnThis,$num);$num='';
786  $j++;}}}else{if($char=~/[0-9,.,\-,+]/){$num=$num.$char;$k++;}}}}
787  $i++;}
788  return(@ReturnThis);
789 };
790 sub sign
791 { my ( $line ) = @_;
792  my $sign_ = 1;
793  @spin = &GetNums(@_); # s1 s2 s3
794  $count = 0;
795  for (my $i=0; $i < 3; ++$i) {
796  if ( $spin[ $i ] >= 3 ) { $count++; }
797  }
798  $odd = ( $count%2 );
799  if ( $odd ) { $sign_ = -1; }
800  return( $sign_ );
801 }
802 sub make_qprop_names
803 { my ( $stub, $TD, $CD, $SD, $XD, $ext ) = @_;
804  # TfSeCfGf
805  if( ($CD >= 2)&&($SD >= 2)&&($XD >= 2) )
806  { my $i = 0;
807  for(my $t=0; $t<$TD; ++$t) {
808  for(my $c=0; $c<$CD; ++$c) {
809  for(my $s=0; $s<$SD; ++$s) {
810  for(my $x=0; $x<$XD; ++$x) {
811  $FileNames[ $i ] = $stub . "_t${t}_c${c}_s${s}_x${x}" . $ext;
812  $i++; }}}}}
813  # TfSxCfGf
814  if( ($CD >= 2)&&($SD >= 2)&&($XD == 1) )
815  { my $i = 0;
816  for(my $t=0; $t<$TD; ++$t) {
817  for(my $c=0; $c<$CD; ++$c) {
818  for(my $s=0; $s<$SD; ++$s) {
819  $FileNames[ $i ] = $stub . "_t${t}_c${c}_s${s}" . $ext;
820  $i++; }}}}
821  # TfSeCfGx
822  if( ($CD >= 2)&&($SD == 1)&&($XD >= 2) )
823  { my $i = 0;
824  for(my $t=0; $t<$TD; ++$t) {
825  for(my $c=0; $c<$CD; ++$c) {
826  for(my $x=0; $x<$XD; ++$x) {
827  $FileNames[ $i ] = $stub . "_t${t}_c${c}_x${x}" . $ext;
828  $i++; }}}}
829  # TfSeCxGf
830  if( ($CD == 1)&&($SD >= 2)&&($XD >= 2) )
831  { my $i = 0;
832  for(my $t=0; $t<$TD; ++$t) {
833  for(my $s=0; $s<$SD; ++$s) {
834  for(my $x=0; $x<$XD; ++$x) {
835  $FileNames[ $i ] = $stub . "_t${t}_s${s}_x${x}" . $ext;
836  $i++; }}}}
837  # TfSeCxGx
838  if( ($CD == 1)&&($SD == 1)&&($XD >= 2) )
839  { my $i = 0;
840  for(my $t=0; $t<$TD; ++$t) {
841  for(my $x=0; $x<$XD; ++$x) {
842  $FileNames[ $i ] = $stub . "_t${t}_x${x}" . $ext;
843  $i++; }}}
844  # TfSxCfGx
845  if( ($CD >= 2)&&($SD == 1)&&($XD == 1) )
846  { my $i = 0;
847  for(my $t=0; $t<$TD; ++$t) {
848  for(my $c=0; $c<$CD; ++$c) {
849  $FileNames[ $i ] = $stub . "_t${t}_c${c}" . $ext;
850  $i++; }}}
851  # TfSxCxGf
852  if( ($CD == 1)&&($SD >= 2)&&($XD == 1) )
853  { my $i = 0;
854  for(my $t=0; $t<$TD; ++$t) {
855  for(my $s=0; $s<$SD; ++$s) {
856  $FileNames[ $i ] = $stub . "_t${t}_s${s}" . $ext;
857  $i++; }}}
858  # TfSxCxGx
859  if( ($CD == 1)&&($SD == 1)&&($XD == 1) )
860  { my $i = 0;
861  for(my $t=0; $t<$TD; ++$t) {
862  $FileNames[ $i ] = $stub . "_t${t}" . $ext;
863  $i++; }}
864  return( @FileNames );
865 }
866 
867 1;
868 # end
869 */
870 #endif
Construct baryon operator.
All baryon operators.
Factory for producing baryon operators.
Configuration structure IO.
Construct baryon operators.
void quarkManip(multi1d< std::map< int, LatticeFermion > > &disp_quarks, const LatticeFermion &q1, const LatticeFermion &q2, const LatticeFermion &q3, int *qindices) const
Manipulate the quark fields.
void smearDisplaceQuarks(multi1d< std::map< int, LatticeFermion > > &disp_quarks, const LatticeFermion &q1, const LatticeFermion &q2, const LatticeFermion &q3, int *qindices) const
First smear then displace the quarks.
const SpinMatrix & rotateMat() const
The spin basis matrix to goto Dirac.
multi1d< LatticeComplex > operator()(const LatticeFermion &quark1, const LatticeFermion &quark2, const LatticeFermion &quark3, int *qindices, enum PlusMinus isign) const
Compute the operator.
void displaceQuarks(multi1d< std::map< int, LatticeFermion > > &disp_quarks, const multi1d< LatticeFermion > &q, int *qindices) const
Construct array of std::maps of displacements.
Random Z(N) source construction using dilution.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
void read(XMLReader &xml, const std::string &path, GroupBaryonOperatorEnv::Params::Qprop_t::Solutions_t &input)
Reader.
Class for counted reference semantics.
unsigned j
Definition: ldumul_w.cc:35
Double q
Definition: mesq.cc:17
int DilSwapInv(int ord, int i, int j, int k, int which)
void ReadTextInput(Params &params, multi1d< GroupBaryonOp > &AB, multi1d< GroupBaryonOp > &CB, multi1d< GroupBaryonQQQ > &AQQQ, multi1d< GroupBaryonQQQ > &CQQQ)
Reader.
bool registerAll()
Register all the factories.
int DilSwap(int ord, int i, int j, int k, int which)
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
int i
Definition: pbg5p_w.cc:55
static QDP_ColorVector * in
int k
Definition: invbicg.cc:119
::std::string string
Definition: gtest.h:1979
Routines associated with Chroma propagator IO.
Quark smearing.
Quark source or sink smearing.
All make sink constructors.
Factory for producing quark prop sinks.
All source smearing.
Factory for producing quark smearing objects.
Gauge configuration structure.
Definition: cfgtype_io.h:16
Propagator parameters.
Definition: qprop_io.h:75
multi1d< BaryonOperatorInsertion_t > orderings
multi1d< Complex > serialize()
Serialize generalized operator object.
struct Chroma::GroupBaryonOperatorEnv::Params::Qprop_t qprop
struct Chroma::GroupBaryonOperatorEnv::Params::param_t param
struct Chroma::GroupBaryonOperatorEnv::Params::NamedObject_t named_obj
struct Chroma::GroupBaryonOperatorEnv::Params::gaugestuff_t gaugestuff
void writeXML(XMLWriter &in, const std::string &path) const
Structure holding a source and its solutions.
Hold group xml and type id.
Sink-smearing parameters.
Definition: qprop_io.h:51
Propagator source construction parameters.
Definition: qprop_io.h:27
Source-smearing parameters.
Definition: qprop_io.h:42
Read an XML group as a std::string.
Volume source of Z(N) noise.