00001 #include<config.h>
00002 CPS_START_NAMESPACE
00003
00008
00009
00010
00011 #ifndef INCLUDED_ALG_INT_H
00012 #define INCLUDED_ALG_INT_H
00013
00014 CPS_END_NAMESPACE
00015 #include <util/lattice.h>
00016 #include <util/smalloc.h>
00017 #include <util/pmalloc.h>
00018 #include <alg/alg_base.h>
00019 #include <alg/alg_meas.h>
00020 #include <alg/cg_stats.h>
00021 #include <util/checksum.h>
00022 #include <alg/int_arg.h>
00023 #include <alg/remez_arg.h>
00024 #include <util/qcdio.h>
00025 #include <alg/alg_eig.h>
00026 CPS_START_NAMESPACE
00027
00031 class AlgInt {
00032
00033 private:
00034 char *cname;
00035
00036 protected:
00038 int traj;
00039 IntegratorType int_type;
00040
00041 public:
00042
00043 AlgInt();
00044 virtual ~AlgInt();
00045
00047 virtual void heatbath() = 0;
00048
00050 virtual void evolve (Float dt, int steps) = 0;
00051
00053 virtual Float energy() = 0;
00054
00056 virtual void cost(CgStats*) = 0;
00057
00059 virtual void reverse() = 0;
00060
00062 virtual void init() = 0;
00063
00064 };
00065
00069 class AlgIntAB : public AlgInt {
00070
00071 private:
00072 char *cname;
00073
00074 protected:
00075 AlgInt *A;
00076 AlgInt *B;
00077 int A_steps, B_steps;
00078 int A_calls, B_calls;
00079
00080 IntegratorLevel level;
00081 unsigned long step_cnt;
00082 IntABArg *ab_arg;
00083
00084 public:
00085 AlgIntAB(AlgInt &A, AlgInt &B, IntABArg &);
00086 virtual ~AlgIntAB();
00087
00088 void heatbath();
00089
00090 Float energy();
00091
00093 virtual void evolve(Float dt, int steps) = 0;
00094
00095 void cost(CgStats*);
00096 void reverse();
00097
00099 void init();
00100
00102 static AlgIntAB& Create(AlgInt &A, AlgInt &B, IntABArg &ab_arg);
00103 static void Destroy(AlgIntAB&);
00104
00105 };
00106
00111 class AlgIntLeap : public AlgIntAB {
00112
00113 private:
00114 char *cname;
00115
00116 public:
00117 AlgIntLeap(AlgInt &A, AlgInt &B, IntABArg &);
00118 virtual ~AlgIntLeap();
00119
00121 void evolve(Float dt, int steps);
00122
00123 };
00124
00129 class AlgIntOmelyan : public AlgIntAB {
00130
00131 private:
00132 char *cname;
00133 Float lambda;
00134
00135 public:
00136 AlgIntOmelyan(AlgInt &A, AlgInt &B, IntABArg &);
00137 virtual ~AlgIntOmelyan();
00138
00140 void evolve(Float dt, int steps);
00141
00142 };
00143
00148 class AlgIntCampostrini : public AlgIntAB {
00149
00150 private:
00151 char *cname;
00152 Float sigma;
00153 Float epsilon;
00154
00155 public:
00156 AlgIntCampostrini(AlgInt &A, AlgInt &B, IntABArg &);
00157 virtual ~AlgIntCampostrini();
00158
00160 void evolve(Float dt, int steps);
00161
00162 };
00163
00168 class AlgIntOmelyan44 : public AlgIntAB {
00169
00170 private:
00171 char *cname;
00172 Float rho;
00173 Float theta;
00174 Float lambda;
00175
00176 public:
00177 AlgIntOmelyan44(AlgInt &A, AlgInt &B, IntABArg &);
00178 virtual ~AlgIntOmelyan44();
00179
00181 void evolve(Float dt, int steps);
00182
00183 };
00184
00189 class AlgIntOmelyan45 : public AlgIntAB {
00190
00191 private:
00192 char *cname;
00193 Float theta;
00194 Float rho;
00195 float lambda;
00196 Float mu;
00197
00198 public:
00199 AlgIntOmelyan45(AlgInt &A, AlgInt &B, IntABArg &);
00200 virtual ~AlgIntOmelyan45();
00201
00203 void evolve(Float dt, int steps);
00204
00205 };
00206
00212 class AlgIntSum : public AlgIntAB {
00213
00214 private:
00215 char *cname;
00216
00217 public:
00218 AlgIntSum(AlgInt &A, AlgInt &B, IntABArg &);
00219 virtual ~AlgIntSum();
00220
00222 void evolve(Float dt, int steps);
00223
00224 };
00225
00229 class AlgHamiltonian : public AlgInt {
00230
00231 protected:
00232 int g_size;
00233
00234 private:
00235 char *cname;
00236
00237 public:
00238 AlgHamiltonian();
00239 virtual ~AlgHamiltonian();
00240
00241 virtual void heatbath() = 0;
00242 virtual Float energy() = 0;
00243 virtual void evolve(Float dt, int steps) = 0;
00244 virtual void cost(CgStats*) = 0;
00245
00246 };
00247
00251 class AlgMomentum : public AlgHamiltonian {
00252
00253 private:
00254 char *cname;
00255
00257 char *md_time_str;
00258 Matrix *mom;
00259
00260 public:
00261 AlgMomentum();
00262 virtual ~AlgMomentum();
00263
00264 void heatbath();
00265
00266 Float energy();
00267
00269 void evolve(Float dt, int steps);
00270
00271 void cost(CgStats*);
00272
00273 Matrix* getMom();
00274
00275 void reverse();
00276
00278 void init();
00279 };
00280
00284 class AlgAction : public AlgHamiltonian {
00285
00286 private:
00287 char *cname;
00288
00289 protected:
00290 Matrix *mom;
00291 ForceMeasure force_measure;
00292 char *force_label;
00293 ForceArg Fdt;
00294
00295 public:
00296 AlgAction();
00297 AlgAction(AlgMomentum &mom, ActionArg &action_arg);
00298 ~AlgAction();
00299
00300 virtual void heatbath() = 0;
00301 virtual Float energy() = 0;
00302 virtual void evolve(Float dt, int steps) = 0;
00303 virtual void cost(CgStats*) = 0;
00304 void reverse();
00305
00306 };
00307
00311 class AlgActionBilinear : public AlgAction {
00312
00313 private:
00314 char *cname;
00315
00316 protected:
00317 ActionBilinearArg *bi_arg;
00318
00319 int n_masses;
00320 FclassType fermion;
00321
00323 Float *mass;
00324
00326 int *max_num_iter;
00327
00329 int f_sites;
00331 int f_vec_count;
00333 int f_size;
00335 int Ncb;
00336
00338 CgStats cg_stats;
00339 int cg_iter;
00340
00342 Vector **phi;
00343
00344 int md_steps;
00345
00346 public:
00347 AlgActionBilinear();
00348 AlgActionBilinear(AlgMomentum &, ActionBilinearArg &);
00349 virtual ~AlgActionBilinear();
00350 void cost(CgStats*);
00351 void updateCgStats(CgArg*);
00352
00353 int getNmass();
00354 Float getMass(int);
00355 FclassType getFermion();
00356
00357 virtual void heatbath() = 0;
00358 virtual Float energy() = 0;
00359 virtual void evolve(Float dt, int steps) = 0;
00360
00361 void init();
00362
00363 };
00364
00373 class AlgActionRational : public AlgActionBilinear {
00374
00375 private:
00376 char *cname;
00377 int **fractionSplit;
00378 int **splitCheck;
00379 ActionRationalArg *rat_arg;
00380
00382 RemezArg *remez_arg_md;
00383 RemezArg *remez_arg_mc;
00384
00385 protected:
00386
00388 int evolved;
00389
00391 int heatbathEval;
00392
00394 int energyEval;
00395
00396 Float h_init;
00397
00398 CgArg ***frm_cg_arg_md;
00399 CgArg ***frm_cg_arg_mc;
00401
00406 Vector** frmn;
00408
00410 Vector** frmn_d;
00412
00415 Vector** frmn_tmp;
00417
00418 int total_size;
00420
00421 int max_size;
00423
00424 Float *all_res;
00426
00427 EigArg eig_arg;
00429
00430 char eig_file[256];
00432
00433 CommonArg ca_eig;
00435
00436 Float **lambda_low;
00437 Float **lambda_high;
00439
00441 void generateApprox(Float *mass, RemezArg **remez_arg_md,
00442 RemezArg **remez_arg_mc, RationalDescr *rat);
00443
00444
00445 void destroyApprox(RemezArg *remez_arg_md, RemezArg *remez_arg_mc);
00446
00448 void generateCgArg(Float *mass, CgArg ****cg_arg_md,
00449 CgArg ****cg_arg_mc, char *label,
00450 RationalDescr *rat_des);
00451
00452
00453 void destroyCgArg(CgArg ***cg_arg_md, CgArg ***cg_arg_mc,
00454 char *label, RemezArg *remez_arg_md,
00455 RemezArg *remez_arg_mc);
00456
00458 void generateEigArg(EigenDescr eigen);
00459
00461 void destroyEigArg();
00462
00463 void checkApprox(Float *mass, RemezArg *remez_arg, EigenDescr eigen);
00465
00466 public:
00467
00468 AlgActionRational();
00469 AlgActionRational(AlgMomentum &mom, ActionRationalArg &rat_arg, int traj_num=0);
00470 AlgActionRational(AlgMomentum &mom, ActionBilinearArg &bi_arg);
00471 virtual ~AlgActionRational();
00472
00473 void heatbath();
00474 Float energy();
00475
00477 void evolve(Float dt, int steps);
00479 void evolve(Float dt, int steps, int **fractionSplit);
00480
00482 static int compareApprox(RemezArg &, RemezArg &);
00483
00484 void init(int traj_num);
00485
00486 void setSplit(int i, int j);
00488 void checkSplit();
00490
00491 };
00492
00497 class AlgActionRationalSplit : public AlgActionRational {
00498
00499 private:
00500 char *cname;
00501 AlgActionRational *rat;
00502 ActionRationalSplitArg *rat_split_arg;
00503 int **fractionSplit;
00504
00505 public:
00506 AlgActionRationalSplit(AlgActionRational &rat,
00507 ActionRationalSplitArg &rat_split_arg);
00508
00509 virtual ~AlgActionRationalSplit();
00510
00511 void heatbath();
00512 Float energy();
00513
00515 void evolve(Float dt, int steps);
00516
00517 int getNmass();
00518 Float getMass(int);
00519
00520 void cost(CgStats*);
00521 };
00522
00528 class AlgActionBoson : public AlgActionBilinear {
00529
00530 private:
00531 char *cname;
00532
00533 ActionBosonArg *bsn_arg;
00534 CgArg **bsn_cg_arg;
00535
00536 public:
00537
00538 AlgActionBoson(AlgMomentum &mom, ActionBosonArg &boson_arg);
00539 virtual ~AlgActionBoson();
00540
00541 void heatbath();
00542
00543 Float energy();
00544
00546 void evolve(Float dt, int steps);
00547
00548 };
00549
00558 class AlgActionFermion : public AlgActionBilinear {
00559
00560 private:
00561 char *cname;
00562
00563 ActionFermionArg *frm_arg;
00564
00565 CgArg **frm_cg_arg_md;
00566 CgArg **frm_cg_arg_mc;
00567
00568 int evolved;
00569 Float h_init;
00570
00572 Vector ***v;
00573 Vector ***cg_sol_old;
00574 Vector *cg_sol;
00575
00579 Vector ***vm;
00580
00581 int *chrono;
00582
00583 public:
00584
00585 AlgActionFermion(AlgMomentum &mom, ActionFermionArg &frm_arg);
00586 virtual ~AlgActionFermion();
00587
00588 void heatbath();
00589
00590 Float energy();
00591
00593 void evolve(Float dt, int steps);
00594
00595 void init();
00596 };
00597
00608 class AlgActionQuotient : public AlgActionBilinear {
00609
00610 private:
00611 char *cname;
00612
00613 ActionQuotientArg *quo_arg;
00614
00615 CgArg **bsn_cg_arg;
00616 CgArg **frm_cg_arg_md;
00617 CgArg **frm_cg_arg_mc;
00618
00619 Float *bsn_mass;
00620
00621 Float *bsn_mass_epsilon;
00622 Float *frm_mass;
00623
00624 Float *frm_mass_epsilon;
00625
00626 int evolved;
00627 Float h_init;
00628
00630 Vector ***v;
00631 Vector ***cg_sol_old;
00632 Vector *cg_sol;
00633 Vector *tmp1;
00634 Vector *tmp2;
00635
00639 Vector ***vm;
00640
00641 int *chrono;
00642
00643 public:
00644
00645 AlgActionQuotient(AlgMomentum &mom, ActionQuotientArg &frm_arg);
00646 virtual ~AlgActionQuotient();
00647
00648 void reweight(Float *rw_fac,Float *norm);
00649 void heatbath();
00650
00651 Float energy();
00652
00654 void evolve(Float dt, int steps);
00655
00656 void init();
00657 };
00658
00669 class AlgActionRationalQuotient : public AlgActionRational {
00670
00671 private:
00672 char *cname;
00673 int **fractionSplit;
00674 ActionRationalQuotientArg *rat_quo_arg;
00675
00676 protected:
00677
00678 Float *bsn_mass;
00679 Float *frm_mass;
00680
00681 RemezArg *frm_remez_arg_md;
00682 RemezArg *frm_remez_arg_mc;
00683 RemezArg *bsn_remez_arg_md;
00684 RemezArg *bsn_remez_arg_mc;
00685
00686 CgArg ***bsn_cg_arg_md;
00687 CgArg ***bsn_cg_arg_mc;
00689
00694 Vector **eta;
00695
00696 public:
00697
00698 AlgActionRationalQuotient();
00699 AlgActionRationalQuotient(AlgMomentum &mom,
00700 ActionRationalQuotientArg &rat_quo_arg, int traj_num=0);
00701 virtual ~AlgActionRationalQuotient();
00702
00703 void reweight(Float *rw_fac,Float *norm);
00704 void heatbath();
00705 Float energy();
00706
00708 void evolve(Float dt, int steps);
00710 void evolve(Float dt, int steps, int **fractionSplit);
00711
00712 };
00713
00718 class AlgActionGauge : public AlgAction {
00719
00720 private:
00721 char *cname;
00722 ActionGaugeArg *gauge_arg;
00723 GclassType gluon;
00724
00725 public:
00726
00727 AlgActionGauge(AlgMomentum &mom, ActionGaugeArg &gauge_arg);
00728 virtual ~AlgActionGauge();
00729
00730 void heatbath();
00731
00732 Float energy();
00733
00735 void evolve(Float dt, int steps);
00736
00737 void cost(CgStats*);
00738
00739 void init();
00740
00741 };
00742
00743 #endif
00744
00745 CPS_END_NAMESPACE