From a99092d8150f7386acc05944a078270afc31b4bb Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Thu, 4 Feb 2021 10:55:37 +0900 Subject: [PATCH 01/54] clang-format --style=google --- src/common/read_keyvalues.h | 56 +- src/common/timer.hpp | 12 +- src/common/tostring.h | 4 +- src/dla/SPECIFIC/Boson/measure_specific.cc | 49 +- src/dla/SPECIFIC/Boson/measure_specific.h | 20 +- .../SPECIFIC/Heisenberg/measure_specific.cc | 49 +- .../SPECIFIC/Heisenberg/measure_specific.h | 13 +- src/dla/accumulator.hpp | 38 +- src/dla/array.h | 42 +- src/dla/calctimer.hpp | 12 +- src/dla/cf.hpp | 92 +-- src/dla/chainjob.hpp | 96 +-- src/dla/ck.hpp | 78 ++- src/dla/debug.hpp | 6 +- src/dla/displacement.hpp | 19 +- src/dla/dla.cc | 245 ++++---- src/dla/dla.hpp | 23 +- src/dla/generators/boson_B.h | 36 +- src/dla/generators/canonical.h | 14 +- src/dla/generators/cfgene.cc | 20 +- src/dla/generators/dla_alg.cc | 321 +++++----- src/dla/generators/dla_alg.h | 68 ++- src/dla/generators/exact_B.cc | 54 +- src/dla/generators/exact_H.cc | 35 +- src/dla/generators/lattgene_C.cc | 41 +- src/dla/generators/lattgene_T.cc | 62 +- src/dla/generators/matrix.h | 36 +- src/dla/generators/sfgene.cc | 59 +- src/dla/generators/spin_H.h | 16 +- src/dla/io.h | 43 +- src/dla/lattice.hpp | 65 +- src/dla/link.hpp | 30 +- src/dla/measure.hpp | 186 +++--- src/dla/measure_specific.cc | 58 +- src/dla/measure_specific.h | 31 +- src/dla/name.h | 12 +- src/dla/objects.hpp | 151 +++-- src/dla/parameter.hpp | 113 ++-- src/dla/random.cc | 95 ++- src/dla/random.h | 40 +- src/dla/serialize.hpp | 31 +- src/dla/sf.hpp | 68 ++- src/dla/util.hpp | 17 +- src/dla/wavevector.hpp | 14 +- src/dla/xml.h | 66 +- src/pmwa/PMWA.cpp | 211 ++++--- src/pmwa/configuration.cpp | 69 ++- src/pmwa/graphspace.cpp | 412 +++++++------ src/pmwa/inc/Configuration.h | 121 ++-- src/pmwa/inc/Graph_functions.h | 129 ++-- src/pmwa/inc/PMWA.h | 109 ++-- src/pmwa/inc/Probability.h | 8 +- src/pmwa/inc/Quantities.h | 52 +- src/pmwa/inc/debug.hpp | 28 +- src/pmwa/inc/lattice.hpp | 129 ++-- src/pmwa/inc/systemparameter.h | 141 +++-- src/pmwa/inc/xml.hpp | 41 +- src/pmwa/lattgene.cc | 98 +-- src/pmwa/lattice.cpp | 268 +++++---- src/pmwa/lib/My_rdm.boost.cpp | 6 +- src/pmwa/lib/My_rdm.boost.h | 8 +- src/pmwa/lib/My_rdm.gsl.cpp | 10 +- src/pmwa/lib/My_rdm.gsl.h | 7 +- src/pmwa/lib/My_rdm.hrd.cpp | 4 +- src/pmwa/lib/My_rdm.hrd.h | 3 +- src/pmwa/lib/random.cpp | 94 ++- src/pmwa/lib/random.h | 40 +- src/pmwa/lib/stdma.cpp | 4 +- src/pmwa/lib/stdma.h | 125 ++-- src/pmwa/probability.B.cpp | 105 ++-- src/pmwa/probability.H.cpp | 119 ++-- src/pmwa/quantities.B.cpp | 506 +++++++++------- src/pmwa/quantities.H.cpp | 566 ++++++++++-------- src/pmwa/sfgene.cc | 48 +- src/pmwa/worm.h | 106 ++-- 75 files changed, 3305 insertions(+), 2898 deletions(-) diff --git a/src/common/read_keyvalues.h b/src/common/read_keyvalues.h index dd84a04c..e7838225 100644 --- a/src/common/read_keyvalues.h +++ b/src/common/read_keyvalues.h @@ -17,62 +17,69 @@ #ifndef READ_KEYVALUES_H #define READ_KEYVALUES_H +#include +#include #include #include -#include -#include #include -#include +#include -void read_keyvalues(std::map &dict, std::string const & filename); -std::map read_keyvalues(std::string const & filename); -bool parse_kvline(std::string& key, std::string& value, std::string const& line); +void read_keyvalues(std::map& dict, + std::string const& filename); +std::map read_keyvalues(std::string const& filename); +bool parse_kvline(std::string& key, std::string& value, + std::string const& line); -struct ToLower{ - char operator()(char c) const { return std::tolower(c);} +struct ToLower { + char operator()(char c) const { return std::tolower(c); } }; -void read_keyvalues(std::map &dict, std::string const& filename){ +void read_keyvalues(std::map& dict, + std::string const& filename) { std::string line, key, value; std::ifstream ifs(filename.c_str()); - if(!ifs){ - std::string msg("read_keyvalues> ERROR: cannot open a parameter file: "); + if (!ifs) { + std::string msg("read_keyvalues> ERROR: cannot open a parameter file: "); msg += filename; throw std::runtime_error(msg); } while (ifs && std::getline(ifs, line)) { - if(parse_kvline(key, value, line)){ + if (parse_kvline(key, value, line)) { std::transform(key.begin(), key.end(), key.begin(), ToLower()); dict[key] = value; } } } -std::map read_keyvalues(std::string const& filename){ +std::map read_keyvalues(std::string const& filename) { std::map dict; read_keyvalues(dict, filename); return dict; } -bool parse_kvline(std::string& key, std::string& value, std::string const& line) { +bool parse_kvline(std::string& key, std::string& value, + std::string const& line) { using namespace boost::xpressive; // same as "^\s*(.*?)(#|$)" in PCRE sregex regex_filter_comment = bos >> *_s >> (s1 = -*_) >> ('#' | eos); // same as "^(.*?)\s*=\s*(.*?)\s*$" in PCRE - sregex regex_keyvalue = bos >> (s1 = -*_) >> *_s >> '=' >> *_s >> (s2 = -*_) >> *_s >> eos; + sregex regex_keyvalue = + bos >> (s1 = -*_) >> *_s >> '=' >> *_s >> (s2 = -*_) >> *_s >> eos; smatch what; if (regex_search(line, what, regex_filter_comment)) { - if (static_cast(what[1]).empty()) { return false; } + if (static_cast(what[1]).empty()) { + return false; + } } else { return false; } if (regex_match(what[1], what, regex_keyvalue)) { - key = what[1]; + key = what[1]; value = what[2]; } else { std::string msg("parse_kvline> ERROR: missing '=': "); @@ -82,12 +89,13 @@ bool parse_kvline(std::string& key, std::string& value, std::string const& line) return true; } -#define deprecated_parameter(dict, new, old) \ -if(dict.count(old)>0){\ - std::cerr << "WARNING: parameter " << old << " is deprecated and will be removed in the next version." << std::endl; \ - std::cerr << "Use " << new << " instead." << std::endl; \ - dict[new] = dict[old];\ -} - +#define deprecated_parameter(dict, new, old) \ + if (dict.count(old) > 0) { \ + std::cerr << "WARNING: parameter " << old \ + << " is deprecated and will be removed in the next version." \ + << std::endl; \ + std::cerr << "Use " << new << " instead." << std::endl; \ + dict[new] = dict[old]; \ + } #endif // READ_KEYVALUES_H diff --git a/src/common/timer.hpp b/src/common/timer.hpp index c9db6120..0a0b30a7 100644 --- a/src/common/timer.hpp +++ b/src/common/timer.hpp @@ -31,12 +31,14 @@ namespace CHRONO = std::chrono; class Timer { CHRONO::high_resolution_clock::time_point start; -public: - Timer():start(CHRONO::high_resolution_clock::now()) {} - void reset() {start = CHRONO::high_resolution_clock::now(); } + public: + Timer() : start(CHRONO::high_resolution_clock::now()) {} + void reset() { start = CHRONO::high_resolution_clock::now(); } double elapsed() const { - CHRONO::high_resolution_clock::time_point end = CHRONO::high_resolution_clock::now(); - return CHRONO::duration_cast(end-start).count()*1.0e-6; + CHRONO::high_resolution_clock::time_point end = + CHRONO::high_resolution_clock::now(); + return CHRONO::duration_cast(end - start).count() * + 1.0e-6; } }; #endif // TIMER_HPP diff --git a/src/common/tostring.h b/src/common/tostring.h index 1a705027..f4f6f2ad 100644 --- a/src/common/tostring.h +++ b/src/common/tostring.h @@ -17,11 +17,11 @@ #ifndef DSQSS_TOSTRING_H #define DSQSS_TOSTRING_H -#include #include +#include template -std::string tostring(T const& x){ +std::string tostring(T const& x) { std::stringstream ss; ss << x; return ss.str(); diff --git a/src/dla/SPECIFIC/Boson/measure_specific.cc b/src/dla/SPECIFIC/Boson/measure_specific.cc index 5723fc61..7d2e96f3 100644 --- a/src/dla/SPECIFIC/Boson/measure_specific.cc +++ b/src/dla/SPECIFIC/Boson/measure_specific.cc @@ -9,26 +9,26 @@ void Measurement::measure(double sgn) { double MZSA = 0.0; // staggered, tau=0 double MZSB = 0.0; // staggered, integrated - const double T = 1.0 / LAT.BETA; + const double T = 1.0 / LAT.BETA; const double invV = 1.0 / LAT.NSITE; std::vector phase(LAT.NSMTYPE); - for(int m=0; m tau(NBODY); std::vector x(NBODY); @@ -60,7 +60,7 @@ void Measurement::measure(double sgn) { p[i].init(S); ++p[i]; tau[i] = p[i]->topTime(); - x[i] = p[i]->X(); + x[i] = p[i]->X(); } double t = 0.0; @@ -73,13 +73,13 @@ void Measurement::measure(double sgn) { t = tau[it]; ++p[it]; tau[it] = p[it]->topTime(); - x[it] = p[it]->X(); + x[it] = p[it]->X(); } } ACC[SGN].accumulate(sgn); - ACC[NV1].accumulate(sgn*NV); + ACC[NV1].accumulate(sgn * NV); ACC[MZUA1].accumulate(sgn * MZUA); ACC[MZUA2].accumulate(sgn * MZUA * MZUA); @@ -102,14 +102,14 @@ void Measurement::measure(double sgn) { for (int xi = 0; xi < LAT.NEDGE; xi++) { int Asite = LAT.EDGE(xi).A; int Bsite = LAT.EDGE(xi).B; - int dim = LAT.EDGE(xi).bd; + int dim = LAT.EDGE(xi).bd; - Site& SITE = LAT.S(Asite); + Site& SITE = LAT.S(Asite); Segment& S0 = SITE.first(); Site::iterator p(SITE); int xlast = S0.X(); - //count winding + // count winding while (!(++p).atOrigin()) { Segment& S = *p; @@ -138,7 +138,8 @@ void Measurement::measure(double sgn) { void Measurement::setsummary() { using namespace Specific; - double WDIAG = ALG.getBlock("WDIAG", (double)1.0); //ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 + double WDIAG = ALG.getBlock( + "WDIAG", (double)1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 std::vector X(NACC); @@ -147,15 +148,15 @@ void Measurement::setsummary() { X[i] = ACC[i].mean(); } - double B = LAT.BETA; - double T = 1.0 / B; - double V = LAT.NSITE; + double B = LAT.BETA; + double T = 1.0 / B; + double V = LAT.NSITE; double invV = 1.0 / V; - double D = LAT.D; + double D = LAT.D; double invsign = 1.0 / X[SGN]; - for(int i=0; i phase(LAT.NSMTYPE); - for(int m = 0; m < LAT.NSMTYPE; ++m){ - phase[m] = std::cos(2.0*M_PI*m/LAT.NSMTYPE); + for (int m = 0; m < LAT.NSMTYPE; ++m) { + phase[m] = std::cos(2.0 * M_PI * m / LAT.NSMTYPE); } for (int s = 0; s < LAT.NSITE; s++) { - Site& SITE = LAT.S(s); - int mt = SITE.getMTYPE(); - double ph = phase[mt]; + Site& SITE = LAT.S(s); + int mt = SITE.getMTYPE(); + double ph = phase[mt]; Segment& S0 = SITE.first(); - double mz0 = dvals[S0.X()]; + double mz0 = dvals[S0.X()]; Site::iterator p(SITE); double mza0 = 0.0; while (!(++p).atOrigin()) { Segment& S = *p; - double mz = dvals[S.X()]; + double mz = dvals[S.X()]; mza0 += mz * S.length(); } @@ -47,13 +47,13 @@ void Measurement::measure(double sgn) { double EBSAMP = -(double)NV; for (int b = 0; b < LAT.NINT; b++) { - Interaction& I = LAT.I(b); + Interaction& I = LAT.I(b); InteractionProperty& IP = I.property(); - //VertexProperty& VP = IP.getVertexProperty(); - int NBODY = IP.NBODY; + // VertexProperty& VP = IP.getVertexProperty(); + int NBODY = IP.NBODY; std::vector tau(NBODY); std::vector x(NBODY); - std::vector x2(2*NBODY); + std::vector x2(2 * NBODY); std::vector p(NBODY); for (int i = 0; i < NBODY; i++) { @@ -61,7 +61,7 @@ void Measurement::measure(double sgn) { p[i].init(S); ++p[i]; tau[i] = p[i]->topTime(); - x[i] = p[i]->X(); + x[i] = p[i]->X(); } double t = 0.0; @@ -75,14 +75,13 @@ void Measurement::measure(double sgn) { t = tau[it]; ++p[it]; tau[it] = p[it]->topTime(); - x[it] = p[it]->X(); + x[it] = p[it]->X(); } } ACC[SGN].accumulate(sgn); - ACC[NV1].accumulate(sgn*NV); - + ACC[NV1].accumulate(sgn * NV); ACC[MZUA1].accumulate(sgn * MZUA); ACC[MZUA2].accumulate(sgn * MZUA * MZUA); @@ -99,24 +98,25 @@ void Measurement::measure(double sgn) { void Measurement::setsummary() { using namespace Specific; - const double WDIAG = ALG.getBlock("WDIAG", (double)1.0); //ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 + const double WDIAG = ALG.getBlock( + "WDIAG", (double)1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 std::vector X(NACC); - for (int i = 0; i < NACC; i++){ + for (int i = 0; i < NACC; i++) { ACC[i].average(); X[i] = ACC[i].mean(); } const double B = LAT.BETA; - const double T = 1.0/B; + const double T = 1.0 / B; const double V = LAT.NSITE; - const double invV = 1.0/V; + const double invV = 1.0 / V; const double D = LAT.D; - double invsign = 1.0/X[SGN]; + double invsign = 1.0 / X[SGN]; - for (int i=0; i -#include -#include #include -#include #include #include +#include +#include +#include #ifdef MULTI #include "mpi.h" @@ -52,16 +52,15 @@ #include "name.h" #include "serialize.hpp" -class Accumulator{ -private: +class Accumulator { + private: std::string k; double value; double error; double s1, s2; int n; - -public: + public: Accumulator() : k("Unset"){}; explicit Accumulator(std::string const& s) : k(s){}; @@ -71,7 +70,7 @@ class Accumulator{ error = 0.0; s1 = 0.0; s2 = 0.0; - n = 0; + n = 0; }; void reset(std::string const& s) { reset(); @@ -104,14 +103,15 @@ class Accumulator{ const char* ckey() const { return k.c_str(); } std::string key() const { return k; } double mean() const { return value; } - double std_error() const { return error;} + double std_error() const { return error; } std::string dump() const { std::stringstream ss; - ss << k << " = " << std::setprecision(8) << std::scientific << value << " " << error; + ss << k << " = " << std::setprecision(8) << std::scientific << value << " " + << error; return ss.str(); } - void show() const { std::cout << dump() << std::endl;} + void show() const { std::cout << dump() << std::endl; } void show(FILE* F) const { std::string s = dump(); std::fprintf(F, "%s\n", s.c_str()); @@ -124,7 +124,7 @@ class Accumulator{ std::fprintf(F, "%s %s\n", prefix, s.c_str()); } - std::ofstream& save(std::ofstream& F) const{ + std::ofstream& save(std::ofstream& F) const { Serialize::save(F, k); Serialize::save(F, value); Serialize::save(F, error); @@ -133,7 +133,7 @@ class Accumulator{ Serialize::save(F, n); return F; } - std::ifstream& load(std::ifstream& F){ + std::ifstream& load(std::ifstream& F) { Serialize::load(F, k); Serialize::load(F, value); Serialize::load(F, error); @@ -144,7 +144,7 @@ class Accumulator{ } #ifdef MULTI - void allreduce(MPI_Comm comm){ + void allreduce(MPI_Comm comm) { double s1_tmp, s2_tmp; int n_tmp; MPI_Allreduce(&s1, &s1_tmp, 1, MPI_DOUBLE, MPI_SUM, comm); @@ -157,15 +157,15 @@ class Accumulator{ #endif }; -namespace Serialize{ +namespace Serialize { template <> -void save(std::ofstream& F, Accumulator const& acc){ +void save(std::ofstream& F, Accumulator const& acc) { acc.save(F); } template <> -void load(std::ifstream& F, Accumulator & acc){ +void load(std::ifstream& F, Accumulator& acc) { acc.load(F); } -} +} // namespace Serialize -#endif // ACCUMULATOR_H +#endif // ACCUMULATOR_H diff --git a/src/dla/array.h b/src/dla/array.h index fc8e1b9c..f66365d7 100644 --- a/src/dla/array.h +++ b/src/dla/array.h @@ -2,6 +2,7 @@ #define ARRAY_H #include + #include #include #include @@ -12,14 +13,14 @@ int EOL = -1; } class IndexSystem { -private: + private: bool INI; std::string LBL; // label int D; int* L; int N; -public: + public: void init(const int d, const int* l, const std::string& LBL0 = ""); IndexSystem() { INI = false; }; @@ -69,10 +70,10 @@ class IndexSystem { } return L[i]; }; - int operator()(const int* x) const ; - int operator()(std::vector const& x) const ; - int operator()(const int M, va_list& ap) const ; - int operator()(const int M, ...) const ; + int operator()(const int* x) const; + int operator()(std::vector const& x) const; + int operator()(const int M, va_list& ap) const; + int operator()(const int M, ...) const; void dump() const { if (!initialized()) { @@ -97,17 +98,16 @@ void IndexSystem::init(const int d, const int* l, const std::string& LBL0) { } INI = true; LBL = LBL0; - D = d; - L = new int[d]; - N = 1; + D = d; + L = new int[d]; + N = 1; for (int i = 0; i < d; i++) { N *= l[i]; L[i] = l[i]; } if (N == 0) { printf("IndexSystem::init> Error. N = 0.\n"); - for (int i = 0; i < d; i++) - printf(" L[%d] = %d\n", i, L[i]); + for (int i = 0; i < d; i++) printf(" L[%d] = %d\n", i, L[i]); exit(0); }; } @@ -209,10 +209,9 @@ int IndexSystem::operator()(const int M, va_list& ap) const { exit(0); } int x[D]; - //int* x = new int[D]; //edit sakakura + // int* x = new int[D]; //edit sakakura x[0] = M; - for (int i = 1; i < D; i++) - x[i] = va_arg(ap, int); + for (int i = 1; i < D; i++) x[i] = va_arg(ap, int); return (*this)(x); } @@ -228,17 +227,16 @@ int IndexSystem::operator()(const int M, ...) const { return i; } - template class Array { -private: + private: std::string LBL; // label int D; C* val; IndexSystem ID; void init(va_list& ap); -public: + public: bool isDefined(); void reset(); void init() { reset(); }; @@ -252,7 +250,7 @@ class Array { LBL = LBL0; val = 0; }; - //Array(int d, ...); + // Array(int d, ...); ~Array(); void set_all(C v); void set_value(double* v); @@ -263,8 +261,8 @@ class Array { C& operator()(std::vector const& x); C& operator[](const int i); const C& operator()(const int M, ...) const; - const C& operator()(int* x) const ; - const C& operator()(std::vector const& x) const ; + const C& operator()(int* x) const; + const C& operator()(std::vector const& x) const; const C& operator[](const int i) const; int size(); int dimension(); @@ -287,7 +285,7 @@ template void Array::init(va_list& ap) { reset(); int* L = new int[D]; - int N = 1; + int N = 1; int l; int i = 0; for (i = 0; i < D; i++) { @@ -326,7 +324,7 @@ void Array::init(int d, ...) { template void Array::init(const std::string& s, int d, ...) { LBL = s; - D = d; + D = d; va_list ap; va_start(ap, d); init(ap); diff --git a/src/dla/calctimer.hpp b/src/dla/calctimer.hpp index 8673e729..a39bc123 100644 --- a/src/dla/calctimer.hpp +++ b/src/dla/calctimer.hpp @@ -26,8 +26,8 @@ class CalcTimer { Accumulator ACC; Accumulator PHY; -public: - CalcTimer(int nmcs) : NMCS(nmcs) {PHY.reset("time");} + public: + CalcTimer(int nmcs) : NMCS(nmcs) { PHY.reset("time"); } void reset_timer() { timer.reset(); } void setinit() { ACC.reset("time"); } void measure() { ACC.accumulate(timer.elapsed() / NMCS); } @@ -37,14 +37,14 @@ class CalcTimer { } void summary() { PHY.average(); } #ifdef MULTI - void allreduce(MPI_Comm comm){ PHY.allreduce(comm);} + void allreduce(MPI_Comm comm) { PHY.allreduce(comm); } #endif - void show(FILE* F) { PHY.show(F,"R"); } - void load(std::ifstream& ifs){ + void show(FILE* F) { PHY.show(F, "R"); } + void load(std::ifstream& ifs) { ACC.load(ifs); PHY.load(ifs); } - void save(std::ofstream& ofs) const{ + void save(std::ofstream& ofs) const { ACC.save(ofs); PHY.save(ofs); } diff --git a/src/dla/cf.hpp b/src/dla/cf.hpp index 1320d016..1d2ab79b 100644 --- a/src/dla/cf.hpp +++ b/src/dla/cf.hpp @@ -17,19 +17,20 @@ #ifndef CF_H #define CF_H +#include #include #include #include -#include -#include "debug.hpp" + #include "accumulator.hpp" -#include "parameter.hpp" +#include "algorithm.hpp" +#include "debug.hpp" #include "displacement.hpp" #include "lattice.hpp" -#include "algorithm.hpp" +#include "parameter.hpp" class CF { -private: + private: bool to_be_calc; Lattice& LAT; Algorithm& ALG; @@ -44,20 +45,21 @@ class CF { std::vector > counter; -public: + public: CF(Parameter const& param, Lattice& lat, Algorithm& alg, Displacement& disp); void setinit(); void reset(); - void count(double tT, double bT, int head_site, int tail_site, double tail_tau); + void count(double tT, double bT, int head_site, int tail_site, + double tail_tau); void accumulate(int NCYC, double sgn); void setsummary(); void summary(); #ifdef MULTI void allreduce(MPI_Comm comm); -#endif +#endif void show(FILE*); - void save(std::ofstream& F) const; + void save(std::ofstream& F) const; void load(std::ifstream& F); bool calculated() { return to_be_calc; } @@ -70,8 +72,7 @@ CF::CF(Parameter const& param, Lattice& lat, Algorithm& alg, Displacement& disp) DISP(disp), nkinds(disp.nkinds), Ntau(param.NTAU), - dtau(param.BETA/param.NTAU) -{ + dtau(param.BETA / param.NTAU) { AutoDebugDump("CF::CF"); if (disp.defined) { to_be_calc = true; @@ -95,28 +96,32 @@ CF::CF(Parameter const& param, Lattice& lat, Algorithm& alg, Displacement& disp) }; inline void CF::setinit() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CF::setinit"); SIGN.reset(); for (int i = 0; i < nkinds; i++) - for (int itau = 0; itau < Ntau; itau++) - ACC[i][itau].reset(); + for (int itau = 0; itau < Ntau; itau++) ACC[i][itau].reset(); } inline void CF::show(FILE* F) { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CF::show"); - for (int i = 0; i < nkinds; i++){ - for (int it = 0; it < Ntau; it++){ - PHY[i][it].show(F,"R"); + for (int i = 0; i < nkinds; i++) { + for (int it = 0; it < Ntau; it++) { + PHY[i][it].show(F, "R"); } - std::fprintf(F,"\n"); + std::fprintf(F, "\n"); } - }; inline void CF::accumulate(int NCYC, double sgn) { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CF::accumulate"); SIGN.accumulate(sgn); const double invNCYC = 1.0 / NCYC; @@ -126,30 +131,34 @@ inline void CF::accumulate(int NCYC, double sgn) { }; inline void CF::summary() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CF::summary"); for (int i = 0; i < nkinds; i++) - for (int itau = 0; itau < Ntau; itau++) - PHY[i][itau].average(); + for (int itau = 0; itau < Ntau; itau++) PHY[i][itau].average(); } -void CF::count(double tT, double bT, int head_site, int tail_site, double tail_tau) { - if (!to_be_calc) { return; } +void CF::count(double tT, double bT, int head_site, int tail_site, + double tail_tau) { + if (!to_be_calc) { + return; + } AutoDebugDump("CF::count"); - int icf = DISP.IR[tail_site][head_site]; + int icf = DISP.IR[tail_site][head_site]; double bTr = tail_tau - tT; double tTr = tail_tau - bT; bTr += bTr < 0.0 ? LAT.BETA : 0.0; // [0,B) tTr += tTr <= 0.0 ? LAT.BETA : 0.0; // (0,B] - int bTri = bTr/dtau + 1; - int tTri = tTr/dtau; + int bTri = bTr / dtau + 1; + int tTri = tTr / dtau; if (bTr <= tTr) { for (int ktau = bTri; ktau <= tTri; ktau++) { - counter[icf][ktau%Ntau] += 1; + counter[icf][ktau % Ntau] += 1; } } else { for (int ktau = 0; ktau <= tTri; ktau++) { @@ -164,7 +173,9 @@ void CF::count(double tT, double bT, int head_site, int tail_site, double tail_t } void CF::reset() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CF::reset"); for (int icf = 0; icf < nkinds; icf++) { for (int it = 0; it < Ntau; it++) { @@ -174,13 +185,16 @@ void CF::reset() { } void CF::setsummary() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CF::setsummary"); - const double V = LAT.NSITE; - const double testDIAG = ALG.getBlock("WDIAG", (double)1.0); //ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 + const double V = LAT.NSITE; + const double testDIAG = ALG.getBlock( + "WDIAG", (double)1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 SIGN.average(); const double sgn = SIGN.mean(); - if(sgn != 0.0){ + if (sgn != 0.0) { const double invsign = 1.0 / sgn; for (int icf = 0; icf < nkinds; icf++) { const double factor = 2 * testDIAG * V / DISP.NR[icf]; @@ -212,14 +226,14 @@ void CF::load(std::ifstream& F) { Serialize::load(F, SIGN); Serialize::load(F, ACC); const int NKINDS = ACC.size(); - if(nkinds != NKINDS){ + if (nkinds != NKINDS) { std::cerr << "ERROR: nkinds is mismatched" << std::endl; std::cerr << " cfinpfile maybe changed." << std::endl; exit(1); } - if(nkinds > 0){ + if (nkinds > 0) { const int ntau = ACC[0].size(); - if(ntau != Ntau){ + if (ntau != Ntau) { std::cerr << "ERROR: Ntau is mismatched" << std::endl; std::cerr << " sfinpfile maybe changed." << std::endl; exit(1); @@ -228,4 +242,4 @@ void CF::load(std::ifstream& F) { Serialize::load(F, PHY); } -#endif //CF_H +#endif // CF_H diff --git a/src/dla/chainjob.hpp b/src/dla/chainjob.hpp index 117515fb..572549ed 100644 --- a/src/dla/chainjob.hpp +++ b/src/dla/chainjob.hpp @@ -18,23 +18,23 @@ #define CHAINJOB_HPP // BINARY FILE -#include +#include #include +#include #include -#include - #include "../common/timer.hpp" #include "dla.hpp" void Simulation::BinaryIO() { - CJOBFILE = P.OUTFILE + std::string(".") + tostring(I_PROC) + std::string(".cjob"); + CJOBFILE = + P.OUTFILE + std::string(".") + tostring(I_PROC) + std::string(".cjob"); cjobin.open(CJOBFILE.c_str(), std::ios::in | std::ios::binary); if (!cjobin) { cjobin.close(); isChainjob = false; - isEnd = true; // isEnd becomes "false" after setNCYC fuction; + isEnd = true; // isEnd becomes "false" after setNCYC fuction; cjobout.open(CJOBFILE.c_str(), std::ios::out | std::ios::binary); Serialize::save(cjobout, isEnd); cjobout.close(); @@ -69,10 +69,10 @@ void Simulation::save() { Site::iterator itp(LAT.S(site_)); while (!(++itp).atOrigin()) { Segment &S = *itp; - int ID_ = S.id(); - int VID_0 = S.V(0).id(); - int VID_1 = S.V(1).id(); - int val_ = S.X(); + int ID_ = S.id(); + int VID_0 = S.V(0).id(); + int VID_1 = S.V(1).id(); + int val_ = S.X(); save(cjobout, ID_); save(cjobout, VID_0); @@ -86,7 +86,8 @@ void Simulation::save() { end_job(); } - int NVER_ = P.NVERMAX - TheVertexPool.count() - LAT.NSITE - 1; //-1 means warm's tail + int NVER_ = + P.NVERMAX - TheVertexPool.count() - LAT.NSITE - 1; //-1 means warm's tail save(cjobout, NVER_); int NVER_count = 0; for (int interaction_ = 0; interaction_ < LAT.NINT; interaction_++) { @@ -94,11 +95,11 @@ void Simulation::save() { save(cjobout, nvertex_interaction); Interaction::iterator itp(LAT.I(interaction_)); while (!(++itp).atOrigin()) { - Vertex &V = *itp; - int ID_ = V.id(); + Vertex &V = *itp; + int ID_ = V.id(); double TIME_ = V.time(); - int VPID_ = V.type(); - int NLEG_ = V.NLEG(); + int VPID_ = V.type(); + int NLEG_ = V.NLEG(); save(cjobout, ID_); save(cjobout, TIME_); @@ -122,11 +123,11 @@ void Simulation::save() { save(cjobout, NVER_term); NVER_count = 0; for (int site_ = 0; site_ < LAT.NSITE; site_++) { - Vertex &V = LAT.S(site_).getVterm(); - int ID_ = V.id(); + Vertex &V = LAT.S(site_).getVterm(); + int ID_ = V.id(); double TIME_ = V.time(); - int VPID_ = V.type(); - int NLEG_ = V.NLEG(); + int VPID_ = V.type(); + int NLEG_ = V.NLEG(); save(cjobout, ID_); save(cjobout, TIME_); @@ -138,7 +139,7 @@ void Simulation::save() { save(cjobout, SID_); } ++NVER_count; - } //terminal vertices + } // terminal vertices if (NVER_term != NVER_count) { std::cout << "ERROR: We can't keep all vertices." << std::endl; end_job(); @@ -160,13 +161,18 @@ void Simulation::save() { void Simulation::load() { using Serialize::load; - std::map > newID2V; //first:new segmentID, second: old vertexIDs - std::map oldID_S; //first:old segmentID, second:new segment address - std::map oldID_V; //first:old vertexID, second:new vertex address + std::map > + newID2V; // first:new segmentID, second: old vertexIDs + std::map + oldID_S; // first:old segmentID, second:new segment address + std::map + oldID_V; // first:old vertexID, second:new vertex address load(cjobin, isEnd); if (isEnd) { - std::cout << "This simulation has been finished or suspended before setting Ncycle" << std::endl; + std::cout << "This simulation has been finished or suspended before " + "setting Ncycle" + << std::endl; cjobin.close(); cjobout.open(CJOBFILE.c_str(), std::ios::out | std::ios::binary); end_cjob(); @@ -179,11 +185,11 @@ void Simulation::load() { load(cjobin, RND); - int NSEG_ = load(cjobin); + int NSEG_ = load(cjobin); int NSEG_count = 0; for (int site_ = 0; site_ < LAT.NSITE; site_++) { int nsegment_site = load(cjobin); - Segment &S0 = LAT.S(site_).first(); + Segment &S0 = LAT.S(site_).first(); for (int nseg_ = 1; nseg_ < nsegment_site; nseg_++) { Segment &S1 = TheSegmentPool.pop(); S1.BareSegment::init(); @@ -194,7 +200,7 @@ void Simulation::load() { Site::iterator itp(LAT.S(site_)); while (!(++itp).atOrigin()) { Segment &S = *itp; - int ID_ = load(cjobin); + int ID_ = load(cjobin); oldID_S.insert(std::map::value_type(ID_, (&S))); int VID_0 = load(cjobin); @@ -202,7 +208,8 @@ void Simulation::load() { int VID_1 = load(cjobin); std::pair VID2(VID_0, VID_1); - newID2V.insert(std::map >::value_type(S.id(), VID2)); + newID2V.insert( + std::map >::value_type(S.id(), VID2)); int val_ = load(cjobin); S.BareSegment::setX(val_); @@ -214,11 +221,11 @@ void Simulation::load() { end_job(); } - int NVER_ = load(cjobin); + int NVER_ = load(cjobin); int NVER_count = 0; for (int interaction_ = 0; interaction_ < LAT.NINT; interaction_++) { int nvertex_interaction = load(cjobin); - Vertex &V0 = LAT.I(interaction_).first(); + Vertex &V0 = LAT.I(interaction_).first(); for (int nver_ = 0; nver_ < nvertex_interaction; nver_++) { Vertex &V1 = TheVertexPool.pop(); V1.setONINTERACTION(&LAT.I(interaction_)); @@ -227,11 +234,11 @@ void Simulation::load() { Interaction::iterator itp(LAT.I(interaction_)); while (!(++itp).atOrigin()) { Vertex &V = *itp; - int ID_ = load(cjobin); + int ID_ = load(cjobin); oldID_V.insert(std::map::value_type(ID_, (&V))); double TIME_ = load(cjobin); - int VPID_ = load(cjobin); + int VPID_ = load(cjobin); if (VPID_ == VTYPE::UNDEF) { std::cout << "VPID_<------------------" << VPID_ << std::endl; @@ -239,9 +246,11 @@ void Simulation::load() { V.BareVertex::init(TIME_, ALG.getVertexProperty(VPID_)); } int NLEG_ = load(cjobin); - if (VPID_ == VTYPE::UNDEF) { std::cout << "NLEG_" << NLEG_ << std::endl; }; + if (VPID_ == VTYPE::UNDEF) { + std::cout << "NLEG_" << NLEG_ << std::endl; + }; for (int leg = 0; leg < NLEG_; leg++) { - int SID_ = load(cjobin); + int SID_ = load(cjobin); Segment *findingS = (oldID_S.find(SID_))->second; V.setS(leg, (*findingS)); } @@ -254,38 +263,39 @@ void Simulation::load() { } int NVER_term = load(cjobin); - NVER_count = 0; + NVER_count = 0; for (int site_ = 0; site_ < LAT.NSITE; site_++) { Vertex &V = LAT.S(site_).getVterm(); - int ID_ = load(cjobin); + int ID_ = load(cjobin); oldID_V.insert(std::map::value_type(ID_, (&V))); double TIME_ = load(cjobin); - int VPID_ = load(cjobin); + int VPID_ = load(cjobin); if (VPID_ != VTYPE::UNDEF) { - std::cout << "ERROR: We don't read vertices which should be Terminal." << std::endl; + std::cout << "ERROR: We don't read vertices which should be Terminal." + << std::endl; end_job(); } int NLEG_ = load(cjobin); for (int leg = 0; leg < NLEG_; leg++) { - int SID_ = load(cjobin); + int SID_ = load(cjobin); Segment *findingS = (oldID_S.find(SID_))->second; V.setS(leg, (*findingS)); } ++NVER_count; - } //terminal vertices + } // terminal vertices if (NVER_term != NVER_count) { std::cout << "ERROR: We can't read all terminal vertices." << std::endl; end_job(); } - //set Segment._v + // set Segment._v for (int site_ = 0; site_ < LAT.NSITE; site_++) { Site::iterator itp(LAT.S(site_)); while (!(++itp).atOrigin()) { Segment &S = *itp; - int VID_0 = (newID2V.find(S.id())->second).first; - int VID_1 = (newID2V.find(S.id())->second).second; + int VID_0 = (newID2V.find(S.id())->second).first; + int VID_1 = (newID2V.find(S.id())->second).second; Vertex *V0 = (oldID_V.find(VID_0))->second; Vertex *V1 = (oldID_V.find(VID_1))->second; S.BareSegment::setBottom((*V0)); @@ -311,7 +321,7 @@ void Simulation::load() { //----------------------------------------------------------------------------------------- void Simulation::end_cjob() { cjobout.close(); - cjobout.open(CJOBFILE.c_str(), std::ios::out | std::ios::binary); //reset + cjobout.open(CJOBFILE.c_str(), std::ios::out | std::ios::binary); // reset Serialize::save(cjobout, isEnd); cjobout.close(); std::cout << "Save checkpoint file and stop the simulation." << std::endl; diff --git a/src/dla/ck.hpp b/src/dla/ck.hpp index 6652573c..fd27d588 100644 --- a/src/dla/ck.hpp +++ b/src/dla/ck.hpp @@ -20,15 +20,16 @@ #include #include #include -#include "debug.hpp" + #include "accumulator.hpp" -#include "parameter.hpp" -#include "lattice.hpp" #include "algorithm.hpp" +#include "debug.hpp" +#include "lattice.hpp" +#include "parameter.hpp" #include "wavevector.hpp" class CK { -private: + private: bool to_be_calc; Lattice& LAT; Algorithm& ALG; @@ -41,9 +42,9 @@ class CK { std::vector > ACC; std::vector > PHY; - std::vector > counterC; + std::vector > counterC; -public: + public: CK(Parameter const& param, Lattice& lat, Algorithm& alg, WaveVector& wv); void read(const char* filename, int NSITE, double BETA); void setinit(); @@ -54,12 +55,11 @@ class CK { void summary(); #ifdef MULTI void allreduce(MPI_Comm comm); -#endif +#endif void show(FILE*); void save(std::ofstream& F) const; void load(std::ifstream& F); - }; CK::CK(Parameter const& param, Lattice& lat, Algorithm& alg, WaveVector& wv) @@ -69,10 +69,9 @@ CK::CK(Parameter const& param, Lattice& lat, Algorithm& alg, WaveVector& wv) wv(wv), NK(wv.NK), Ntau(param.NTAU), - dtau(param.BETA/Ntau) -{ + dtau(param.BETA / Ntau) { AutoDebugDump("CK::CK"); - if(wv.defined){ + if (wv.defined) { to_be_calc = true; SIGN.reset(); for (int i = 0; i < NK; i++) { @@ -93,27 +92,32 @@ CK::CK(Parameter const& param, Lattice& lat, Algorithm& alg, WaveVector& wv) }; inline void CK::setinit() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CK::setinit"); SIGN.reset(); for (int i = 0; i < NK; i++) - for (int itau = 0; itau < Ntau; itau++) - ACC[i][itau].reset(); + for (int itau = 0; itau < Ntau; itau++) ACC[i][itau].reset(); } inline void CK::show(FILE* F) { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CK::show"); for (int i = 0; i < NK; i++) { for (int it = 0; it < Ntau; it++) { - PHY[i][it].show(F,"R"); + PHY[i][it].show(F, "R"); } fprintf(F, "\n"); } }; inline void CK::accumulate(int NCYC, double sgn) { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CK::accumulate"); const double invNCYC = 1.0 / NCYC; @@ -124,15 +128,18 @@ inline void CK::accumulate(int NCYC, double sgn) { }; inline void CK::summary() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CK::summary"); for (int i = 0; i < NK; i++) - for (int itau = 0; itau < Ntau; itau++) - PHY[i][itau].average(); + for (int itau = 0; itau < Ntau; itau++) PHY[i][itau].average(); } void CK::count(int s, double tT, double bT, double tail_tau) { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CK::count"); double bTr; @@ -140,15 +147,15 @@ void CK::count(int s, double tT, double bT, double tail_tau) { bTr = tail_tau - tT; tTr = tail_tau - bT; - bTr += bTr < 0.0 ? LAT.BETA : 0.0; // [0,BETA) + bTr += bTr < 0.0 ? LAT.BETA : 0.0; // [0,BETA) tTr += tTr <= 0.0 ? LAT.BETA : 0.0; // (0,BETA] int bTri = bTr / dtau + 1; - int tTri = tTr / dtau; //Relative bottom (top) time integer + int tTri = tTr / dtau; // Relative bottom (top) time integer if (bTr <= tTr) { for (int ik = 0; ik < NK; ik++) { for (int ktau = bTri; ktau <= tTri; ktau++) { - counterC[ik][ktau%Ntau] += wv.COSrk[s][ik]; + counterC[ik][ktau % Ntau] += wv.COSrk[s][ik]; } } } else { @@ -164,7 +171,9 @@ void CK::count(int s, double tT, double bT, double tail_tau) { }; void CK::reset() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CK::reset"); for (int ik = 0; ik < NK; ik++) { for (int it = 0; it < Ntau; it++) { @@ -174,13 +183,18 @@ void CK::reset() { } }; void CK::setsummary() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("CK::setsummary"); - const double factor = 2 * ALG.getBlock("WDIAG", (double)1.0); //ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 + const double factor = + 2 * ALG.getBlock( + "WDIAG", + (double)1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 SIGN.average(); const double sgn = SIGN.mean(); - if(sgn != 0.0){ - const double invsign = 1.0/sgn; + if (sgn != 0.0) { + const double invsign = 1.0 / sgn; for (int ik = 0; ik < NK; ik++) { for (int it = 0; it < Ntau; it++) { ACC[ik][it].average(); @@ -210,14 +224,14 @@ void CK::load(std::ifstream& F) { Serialize::load(F, SIGN); Serialize::load(F, ACC); const int nk = ACC.size(); - if(nk != NK){ + if (nk != NK) { std::cerr << "ERROR: NK is mismatched" << std::endl; std::cerr << " ckinpfile maybe changed." << std::endl; exit(1); } - if(nk > 0){ + if (nk > 0) { const int ntau = ACC[0].size(); - if(ntau != Ntau){ + if (ntau != Ntau) { std::cerr << "ERROR: Ntau is mismatched" << std::endl; std::cerr << " ckinpfile maybe changed." << std::endl; exit(1); diff --git a/src/dla/debug.hpp b/src/dla/debug.hpp index 13237dc6..ae8229d6 100644 --- a/src/dla/debug.hpp +++ b/src/dla/debug.hpp @@ -18,14 +18,14 @@ #define DEBUG_H #ifdef DEB -#include #include +#include class AutoDebugDump_impl { -private: + private: std::string message; -public: + public: explicit AutoDebugDump_impl(std::string const& msg) : message(msg) { std::cout << message << "> Start.\n" << std::flush; } diff --git a/src/dla/displacement.hpp b/src/dla/displacement.hpp index e40b1110..73971eb3 100644 --- a/src/dla/displacement.hpp +++ b/src/dla/displacement.hpp @@ -17,12 +17,13 @@ #ifndef DISPLACEMENT_H #define DISPLACEMENT_H +#include #include #include #include -#include -#include "debug.hpp" + #include "accumulator.hpp" +#include "debug.hpp" #include "parameter.hpp" #include "xml.h" @@ -31,15 +32,15 @@ struct Displacement { int NSITES; int nkinds; - std::vector NR; // the number of pairs with the same dR - std::vector > IR; // IR[isite][jsite] == disp_index + std::vector NR; // the number of pairs with the same dR + std::vector > IR; // IR[isite][jsite] == disp_index Displacement(Parameter const& param); void read(XML::Block const& X); }; -Displacement::Displacement(Parameter const& param) : defined(false), NSITES(0), nkinds(0) -{ +Displacement::Displacement(Parameter const& param) + : defined(false), NSITES(0), nkinds(0) { AutoDebugDump("Displacement::Displacement"); if (param.DISPFILE.length() > 0) { defined = true; @@ -48,7 +49,7 @@ Displacement::Displacement(Parameter const& param) : defined(false), NSITES(0), NSITES = X["NumberOfSites"].getInteger(); nkinds = X["NumberOfKinds"].getInteger(); - NR.resize(nkinds,0); + NR.resize(nkinds, 0); for (int i = 0; i < NSITES; i++) { IR.push_back(std::vector(NSITES, nkinds)); @@ -57,7 +58,7 @@ Displacement::Displacement(Parameter const& param) : defined(false), NSITES(0), for (int i = 0; i < X.NumberOfBlocks(); i++) { XML::Block& B = X[i]; if (B.getName() == "R") { - int kind = B.getInteger(0); + int kind = B.getInteger(0); int isite = B.getInteger(1); int jsite = B.getInteger(2); IR[isite][jsite] = kind; @@ -67,4 +68,4 @@ Displacement::Displacement(Parameter const& param) : defined(false), NSITES(0), } }; -#endif //DISPLACEMENT_H +#endif // DISPLACEMENT_H diff --git a/src/dla/dla.cc b/src/dla/dla.cc index 6f43c674..393d6a03 100644 --- a/src/dla/dla.cc +++ b/src/dla/dla.cc @@ -32,17 +32,15 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include "dla.hpp" #include #include #include "../common/version.h" -#include "util.hpp" - -#include "dla.hpp" -#include "debug.hpp" - #include "chainjob.hpp" +#include "debug.hpp" +#include "util.hpp" //###################################################################### @@ -54,8 +52,9 @@ int main(int argc, char* argv[]) { MPI_Comm_size(MPI_COMM_WORLD, &N_PROC); MPI_Comm_rank(MPI_COMM_WORLD, &I_PROC); - if(I_PROC==0){ - printf(">>> The program is being run with MPI mode.( N_PROC = %d ) \n\n", N_PROC); + if (I_PROC == 0) { + printf(">>> The program is being run with MPI mode.( N_PROC = %d ) \n\n", + N_PROC); } #else N_PROC = 1; @@ -104,7 +103,7 @@ Simulation::Simulation(Parameter& P0) isChainjob = false; } if (!isChainjob) { - if(I_PROC==0){ + if (I_PROC == 0) { std::cout << "Determining hyperparameter NCYC : "; set_NCYC(); } @@ -113,26 +112,28 @@ Simulation::Simulation(Parameter& P0) MPI_Bcast(&ncyc, 1, MPI_INT, 0, MPI_COMM_WORLD); P.NCYC = ncyc; #endif - if(I_PROC==0){ + if (I_PROC == 0) { std::cout << P.NCYC << std::endl; } } else { - std::cout << "Reading checkpoint file takes " << cjob_timer.elapsed() << " sec." << std::endl; + std::cout << "Reading checkpoint file takes " << cjob_timer.elapsed() + << " sec." << std::endl; } isEnd = false; - if(I_PROC==0){ + if (I_PROC == 0) { std::cout << "Start main calculation." << std::endl; } Timer timer; for (ISET = ISETstart; ISET < P.NSET; ISET++) { - Set((ISET==0 ? P.NTHERM : P.NDECOR), P.NMCS); + Set((ISET == 0 ? P.NTHERM : P.NDECOR), P.NMCS); double elapsed = timer.elapsed(); - double ETR = elapsed*(P.NSET-ISET-1)/(ISET-ISETstart+1); - if(I_PROC==0){ - std::cout << ISET+1 << " / " << P.NSET << " done. [Elapsed: " << elapsed << " sec. ETR: " << ETR << " sec.]" << std::endl; + double ETR = elapsed * (P.NSET - ISET - 1) / (ISET - ISETstart + 1); + if (I_PROC == 0) { + std::cout << ISET + 1 << " / " << P.NSET << " done. [Elapsed: " << elapsed + << " sec. ETR: " << ETR << " sec.]" << std::endl; } } ISETstart = 0; @@ -150,7 +151,7 @@ Simulation::Simulation(Parameter& P0) cf.summary(); ck.summary(); - if(I_PROC == 0){ + if (I_PROC == 0) { P.openfile(); fprintf(P.FOUT, "C This is DSQSS ver.%s\n\n", DSQSS_VERSION); fprintf(P.FOUT, "I N_PROC = %d\n", N_PROC); @@ -159,12 +160,15 @@ Simulation::Simulation(Parameter& P0) MSR.show(P.FOUT); calctimer.show(P.FOUT); - int ns_used = TheSegmentPool.number_of_used_elements(); - int nv_used = TheVertexPool.number_of_used_elements(); + int ns_used = TheSegmentPool.number_of_used_elements(); + int nv_used = TheVertexPool.number_of_used_elements(); int nrvi_used = TheRVIPool.number_of_used_elements(); - fprintf(P.FOUT, "I [the maximum number of segments] = %d\n", ns_used); - fprintf(P.FOUT, "I [the maximum number of vertices] = %d\n", nv_used); - fprintf(P.FOUT, "I [the maximum number of reg. vertex info.] = %d\n", nrvi_used); + fprintf(P.FOUT, "I [the maximum number of segments] = %d\n", + ns_used); + fprintf(P.FOUT, "I [the maximum number of vertices] = %d\n", + nv_used); + fprintf(P.FOUT, "I [the maximum number of reg. vertex info.] = %d\n", + nrvi_used); if (P.FOUT4CF) { cf.summary(); @@ -195,21 +199,21 @@ Simulation::Simulation(Parameter& P0) if (P.SIMTIME > 0.0) { isEnd = true; - cjobout.open(CJOBFILE.c_str(), std::ios::out | std::ios::binary); //reset + cjobout.open(CJOBFILE.c_str(), std::ios::out | std::ios::binary); // reset end_cjob(); } } void Simulation::reset_counters() { - ISET = -1; + ISET = -1; IMCSE = -1; IMCSD = -1; - IMCS = -1; - ICYC = -1; + IMCS = -1; + ICYC = -1; - ISETstart = 0; + ISETstart = 0; IMCSDstart = 0; - IMCSstart = 0; + IMCSstart = 0; } void Simulation::set_NCYC() { @@ -217,7 +221,7 @@ void Simulation::set_NCYC() { double vol = P.BETA * LAT.NSITE; double path; - int ncyc = 1; + int ncyc = 1; int NSAMP = P.NPRE / 10; std::vector ncycSAMP(NSAMP); @@ -328,7 +332,7 @@ bool Simulation::PlaceWorm() { W.setCurrentVertex(Vorg); // timespace where worm will be inserted - int s = RND.Int(LAT.NSITE); + int s = RND.Int(LAT.NSITE); Site& ST = LAT.S(s); double t = ST.getBeta() * RND.Uniform(); @@ -350,11 +354,13 @@ bool Simulation::PlaceWorm() { if (r < IC.CH[c].PROB) break; } ScatteringChannel& CH = IC.CH[c]; - int out = CH.OUT; + int out = CH.OUT; int xout = CH.XOUT; // fail to insert - if (out == DIR::UNDEF) { return false; } + if (out == DIR::UNDEF) { + return false; + } Segment& S1 = S0.cut(Vorg, 0); @@ -366,7 +372,7 @@ bool Simulation::PlaceWorm() { W.setXBEHIND(xout); - tail_tau = t; + tail_tau = t; tail_site = s; return true; @@ -374,10 +380,10 @@ bool Simulation::PlaceWorm() { double Simulation::MoveHead(bool thermalized) { AutoDebugDump("Simulation::MoveHead"); - double len = 0.0; + double len = 0.0; double len0 = 0.0; double len1 = 0.0; - EndOfCycle = false; + EndOfCycle = false; while (true) { if (W.getUORD()) { @@ -415,7 +421,7 @@ double Simulation::UP_ONESTEP(bool thermalized) { Site& c_Site = (*c_S.getONSITE()); Interaction** CI = c_Site.getCI(); - const int NCI = c_Site.getNCI(); // the number of Interaction: + const int NCI = c_Site.getNCI(); // the number of Interaction: Vertex& c_V = W.getCurrentVertex(); Vertex& n_V = W.getNextVertex(); @@ -427,25 +433,26 @@ double Simulation::UP_ONESTEP(bool thermalized) { UniformInterval* UI = new UniformInterval[NCI]; Ring RingRVI; - RingRVI.ROOT.V_x = &V4REF; + RingRVI.ROOT.V_x = &V4REF; const double n_Vtime = n_V.isTerminal() ? LAT.BETA : n_V.time(); - const double c_time = c_V.isTerminal() ? 0.0 : c_V.time(); - const double n_time = n_Vtime - c_time; + const double c_time = c_V.isTerminal() ? 0.0 : c_V.time(); + const double n_time = n_Vtime - c_time; if (c_V.isTerminal()) { for (int iCI = 0; iCI < NCI; iCI++) { UniformInterval& ui = UI[iCI]; ui.init(CI[iCI], xinc); for (int i_body = 0; i_body < ui.nbody; i_body++) { if (&(CI[iCI]->site(i_body)) == &c_Site) { - ui.inc = 2 * i_body; + ui.inc = 2 * i_body; ui.n_S[i_body] = &c_S; } else { ui.n_S[i_body] = &(CI[iCI]->site(i_body).head()); - Vertex& near_V = ui.n_S[i_body]->top(); + Vertex& near_V = ui.n_S[i_body]->top(); const double V_time = near_V.time(); - if ((!near_V.isTerminal()) && (V_time < n_time) && (&near_V != &n_V)) { + if ((!near_V.isTerminal()) && (V_time < n_time) && + (&near_V != &n_V)) { RegVInfo& RVI = TheRVIPool.pop(); RVI.setRVI(&near_V, iCI, i_body, V_time); RingRVI.add_tail(RVI); @@ -455,7 +462,9 @@ double Simulation::UP_ONESTEP(bool thermalized) { ui.setx(); ui.setVIC(); - if (ui.DefinedVIC) { RHO += ui.VIC->dRHO; } + if (ui.DefinedVIC) { + RHO += ui.VIC->dRHO; + } } } else { for (int iCI = 0; iCI < NCI; iCI++) { @@ -463,7 +472,7 @@ double Simulation::UP_ONESTEP(bool thermalized) { ui.init(CI[iCI], xinc); for (int i_body = 0; i_body < ui.nbody; i_body++) { if (&(CI[iCI]->site(i_body)) == &c_Site) { - ui.inc = 2 * i_body; + ui.inc = 2 * i_body; ui.n_S[i_body] = &c_S; } else { if (CI[iCI] == c_V.getONINTERACTION()) { @@ -471,9 +480,10 @@ double Simulation::UP_ONESTEP(bool thermalized) { } else { ui.n_S[i_body] = &(CI[iCI]->site(i_body).findS(c_time)); } - Vertex& near_V = ui.n_S[i_body]->top(); + Vertex& near_V = ui.n_S[i_body]->top(); const double V_time = near_V.time() - c_time; - if ((!near_V.isTerminal()) && (V_time < n_time) && (&near_V != &n_V)) { + if ((!near_V.isTerminal()) && (V_time < n_time) && + (&near_V != &n_V)) { RegVInfo& RVI = TheRVIPool.pop(); RVI.setRVI(&near_V, iCI, i_body, V_time); RingRVI.add_tail(RVI); @@ -483,11 +493,13 @@ double Simulation::UP_ONESTEP(bool thermalized) { ui.setx(); ui.setVIC(); - if (ui.DefinedVIC) { RHO += ui.VIC->dRHO; } + if (ui.DefinedVIC) { + RHO += ui.VIC->dRHO; + } } } double near_tau = 0.0; - double try_tau = 0.0; + double try_tau = 0.0; int out, xout; while (true) { @@ -501,8 +513,8 @@ double Simulation::UP_ONESTEP(bool thermalized) { len += try_tau; double RHORND = RHO * RND.Uniform(); - int i_UI = 0; - int s_UI = 0; + int i_UI = 0; + int s_UI = 0; double iRHO = 0.0; double sRHO = 0.0; do { @@ -520,7 +532,7 @@ double Simulation::UP_ONESTEP(bool thermalized) { ScatteringChannel& CH = (*ui.VIC).getScatteringChannel(RHORND); const double setVtime = c_time + len; - Vertex& setV = TheVertexPool.pop(); + Vertex& setV = TheVertexPool.pop(); setV.BareVertex::init(ui.I_n, setVtime, (*ui.VP)); for (int ibody = 0; ibody < ui.nbody; ++ibody) { ui.n_S[ibody]->cut(setV, ibody); @@ -528,7 +540,9 @@ double Simulation::UP_ONESTEP(bool thermalized) { ui.I_n->add_tail(setV); setV.S(ui.inc).setX(xinc); - if (!(c_V.isTerminal() || c_V.isKink())) { c_V.erase(); } + if (!(c_V.isTerminal() || c_V.isKink())) { + c_V.erase(); + } W.setCurrentVertex(setV); W.setCurrentSegment(setV.S(CH.OUT)); W.setXBEHIND(CH.XOUT); @@ -540,17 +554,19 @@ double Simulation::UP_ONESTEP(bool thermalized) { W.setCurrentVertex(n_V); const int inc = n_V.which(c_S); if (n_V.isTerminal()) { - out = 1 - inc; + out = 1 - inc; xout = xinc; } else { VertexInitialConfiguration& IC = n_V.getInitialConfiguration(inc, xinc); - ScatteringChannel& CH = IC.getScatteringChannel(); - out = CH.OUT; - xout = CH.XOUT; + ScatteringChannel& CH = IC.getScatteringChannel(); + out = CH.OUT; + xout = CH.XOUT; } c_S.setX(xinc); - if (!(c_V.isTerminal() || c_V.isKink())) { c_V.erase(); } + if (!(c_V.isTerminal() || c_V.isKink())) { + c_V.erase(); + } if (out == DIR::UNDEF) { EndOfCycle = true; } else { @@ -561,20 +577,24 @@ double Simulation::UP_ONESTEP(bool thermalized) { break; } - //UPDATE RegVI and UI + // UPDATE RegVI and UI Vertex* changeV = it->V_x; do { - RegVInfo& RVImin = *it; + RegVInfo& RVImin = *it; UniformInterval& ui = UI[RVImin.i_UI]; - if (ui.DefinedVIC) { RHO -= ui.VIC->dRHO; } + if (ui.DefinedVIC) { + RHO -= ui.VIC->dRHO; + } ui.n_S[RVImin.i_body] = &(ui.n_S[RVImin.i_body]->next()); ui.setx(RVImin.i_body); ui.setVIC(); - if (ui.DefinedVIC) { RHO += ui.VIC->dRHO; } + if (ui.DefinedVIC) { + RHO += ui.VIC->dRHO; + } - //add RegVI - Vertex& near_V = (*ui.n_S[RVImin.i_body]).top(); + // add RegVI + Vertex& near_V = (*ui.n_S[RVImin.i_body]).top(); const double V_time = near_V.time() - c_time; if ((!near_V.isTerminal()) && (V_time < n_time) && (&near_V != &n_V)) { RegVInfo& RVI = TheRVIPool.pop(); @@ -598,7 +618,8 @@ double Simulation::UP_ONESTEP(bool thermalized) { if (thermalized) { const int head_site = c_Site.id() - 1; cf.count(c_time + len, c_time, head_site, tail_site, tail_tau); - ck.count((head_site - tail_site + LAT.NSITE) % LAT.NSITE, c_time + len, c_time, tail_tau); + ck.count((head_site - tail_site + LAT.NSITE) % LAT.NSITE, c_time + len, + c_time, tail_tau); } delete[] UI; @@ -614,8 +635,9 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { Segment& c_S = W.getCurrentSegment(); Site& c_Site = (*c_S.getONSITE()); - Interaction** CI = c_Site.getCI(); // Interaction* CI [n_int]; which belong to curSite - const int NCI = c_Site.getNCI(); // the number of Interaction: + Interaction** CI = + c_Site.getCI(); // Interaction* CI [n_int]; which belong to curSite + const int NCI = c_Site.getNCI(); // the number of Interaction: Vertex& c_V = W.getCurrentVertex(); Vertex& n_V = W.getNextVertex(); @@ -627,10 +649,10 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { UniformInterval* UI = new UniformInterval[NCI]; Ring RingRVI; - RingRVI.ROOT.V_x = &V4REF; + RingRVI.ROOT.V_x = &V4REF; const double n_Vtime = (n_V.isTerminal()) ? 0.0 : n_V.time(); - const double c_time = c_V.isTerminal() ? LAT.BETA : c_V.time(); - const double n_time = c_time - n_Vtime; + const double c_time = c_V.isTerminal() ? LAT.BETA : c_V.time(); + const double n_time = c_time - n_Vtime; if (c_V.isTerminal()) { for (int iCI = 0; iCI < NCI; iCI++) { @@ -639,13 +661,14 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { ui.init(CI[iCI], xinc); for (int i_body = 0; i_body < ui.nbody; i_body++) { if (&(CI[iCI]->site(i_body)) == &c_Site) { - ui.inc = 2 * i_body + 1; + ui.inc = 2 * i_body + 1; ui.n_S[i_body] = &c_S; } else { - ui.n_S[i_body] = &(CI[iCI]->site(i_body).tail()); - Vertex& near_V = ui.n_S[i_body]->bottom(); + ui.n_S[i_body] = &(CI[iCI]->site(i_body).tail()); + Vertex& near_V = ui.n_S[i_body]->bottom(); const double V_time = c_time - near_V.time(); - if ((!near_V.isTerminal()) && (V_time < n_time) && (&near_V != &n_V)) { + if ((!near_V.isTerminal()) && (V_time < n_time) && + (&near_V != &n_V)) { RegVInfo& RVI = TheRVIPool.pop(); RVI.setRVI(&near_V, iCI, i_body, V_time); RingRVI.add_tail(RVI); @@ -654,7 +677,9 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { } ui.setx(); ui.setVIC(); - if (ui.DefinedVIC) { RHO += (*(ui.VIC)).dRHO; } + if (ui.DefinedVIC) { + RHO += (*(ui.VIC)).dRHO; + } } } else { @@ -664,7 +689,7 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { ui.init(CI[iCI], xinc); for (int i_body = 0; i_body < ui.nbody; i_body++) { if (&(CI[iCI]->site(i_body)) == &c_Site) { - ui.inc = 2 * i_body + 1; + ui.inc = 2 * i_body + 1; ui.n_S[i_body] = &c_S; } else { if (CI[iCI] == c_V.getONINTERACTION()) { @@ -672,9 +697,10 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { } else { ui.n_S[i_body] = &(CI[iCI]->site(i_body).findS(c_time)); } - Vertex& near_V = ui.n_S[i_body]->bottom(); + Vertex& near_V = ui.n_S[i_body]->bottom(); const double V_time = c_time - near_V.time(); - if ((!near_V.isTerminal()) && (V_time < n_time) && (&near_V != &n_V)) { + if ((!near_V.isTerminal()) && (V_time < n_time) && + (&near_V != &n_V)) { RegVInfo& RVI = TheRVIPool.pop(); RVI.setRVI(&near_V, iCI, i_body, V_time); RingRVI.add_tail(RVI); @@ -683,11 +709,13 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { } ui.setx(); ui.setVIC(); - if (ui.DefinedVIC) { RHO += ui.VIC->dRHO; } + if (ui.DefinedVIC) { + RHO += ui.VIC->dRHO; + } } } double near_tau = 0.0; - double try_tau = 0.0; + double try_tau = 0.0; int out, xout; while (true) { @@ -700,10 +728,10 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { if (try_tau < near_tau) { len += try_tau; double RHORND = RHO * RND.Uniform(); - int i_UI = 0; - int s_UI = 0; - double iRHO = 0.0; - double sRHO = 0.0; + int i_UI = 0; + int s_UI = 0; + double iRHO = 0.0; + double sRHO = 0.0; do { sRHO = iRHO; if (UI[i_UI].DefinedVIC) { @@ -714,11 +742,11 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { } while (RHORND >= iRHO); RHORND -= sRHO; - UniformInterval& ui = UI[s_UI]; + UniformInterval& ui = UI[s_UI]; ScatteringChannel& CH = ui.VIC->getScatteringChannel(RHORND); double setVtime = c_time - len; - Vertex& setV = TheVertexPool.pop(); + Vertex& setV = TheVertexPool.pop(); setV.BareVertex::init(ui.I_n, setVtime, *ui.VP); for (int ibody = 0; ibody < ui.nbody; ++ibody) { ui.n_S[ibody]->cut(setV, ibody); @@ -726,7 +754,9 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { ui.I_n->add_tail(setV); setV.S(ui.inc).setX(xinc); - if (!(c_V.isTerminal() || c_V.isKink())) { c_V.erase(); } + if (!(c_V.isTerminal() || c_V.isKink())) { + c_V.erase(); + } W.setCurrentVertex(setV); W.setCurrentSegment(setV.S(CH.OUT)); W.setXBEHIND(CH.XOUT); @@ -738,17 +768,19 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { W.setCurrentVertex(n_V); const int inc = n_V.which(c_S); if (n_V.isTerminal()) { - out = 1 - inc; + out = 1 - inc; xout = xinc; } else { VertexInitialConfiguration& IC = n_V.getInitialConfiguration(inc, xinc); - ScatteringChannel& CH = IC.getScatteringChannel(); - out = CH.OUT; - xout = CH.XOUT; + ScatteringChannel& CH = IC.getScatteringChannel(); + out = CH.OUT; + xout = CH.XOUT; } c_S.setX(xinc); - if (!(c_V.isTerminal() || c_V.isKink())) { c_V.erase(); } + if (!(c_V.isTerminal() || c_V.isKink())) { + c_V.erase(); + } if (out == DIR::UNDEF) { EndOfCycle = true; } else { @@ -759,20 +791,24 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { break; } - //UPDATE RegVI and UI + // UPDATE RegVI and UI Vertex* changeV = it->V_x; do { - RegVInfo& RVImin = *it; + RegVInfo& RVImin = *it; UniformInterval& ui = UI[RVImin.i_UI]; - if (ui.DefinedVIC) { RHO -= ui.VIC->dRHO; } + if (ui.DefinedVIC) { + RHO -= ui.VIC->dRHO; + } ui.n_S[it->i_body] = &(ui.n_S[(*it).i_body]->prev()); // ui.setx(it->i_body); ui.setVIC(); - if (ui.DefinedVIC) { RHO += ui.VIC->dRHO; } + if (ui.DefinedVIC) { + RHO += ui.VIC->dRHO; + } - //add RegVI - Vertex& near_V = ui.n_S[(*it).i_body]->bottom(); + // add RegVI + Vertex& near_V = ui.n_S[(*it).i_body]->bottom(); const double V_time = c_time - near_V.time(); if ((!near_V.isTerminal()) && (V_time < n_time) && (&near_V != &n_V)) { RegVInfo& RVI = TheRVIPool.pop(); @@ -796,37 +832,38 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { if (thermalized) { const int head_site = c_Site.id() - 1; cf.count(c_time, c_time - len, head_site, tail_site, tail_tau); - ck.count((head_site - tail_site + LAT.NSITE) % LAT.NSITE, c_time, c_time - len, tail_tau); + ck.count((head_site - tail_site + LAT.NSITE) % LAT.NSITE, c_time, + c_time - len, tail_tau); } delete[] UI; return len; } -double Simulation::calculate_sign(){ +double Simulation::calculate_sign() { double sgn = 1.0; for (int b = 0; b < LAT.NINT; ++b) { - Interaction& I = LAT.I(b); + Interaction& I = LAT.I(b); InteractionProperty& IP = I.property(); - int NLEG = 2*IP.NBODY; + int NLEG = 2 * IP.NBODY; std::vector x(NLEG); Interaction::iterator itv(I.root()); ++itv; - for(;!itv.atOrigin(); ++itv){ + for (; !itv.atOrigin(); ++itv) { Vertex& v = *itv; - for(int l=0; l>> %s (iset=%d imcse=%d imcsd=%d imcs=%d icyc= %d)", s, ISET, IMCSE, IMCSD, IMCS, ICYC); + printf("\n>>> %s (iset=%d imcse=%d imcsd=%d imcs=%d icyc= %d)", s, ISET, + IMCSE, IMCSD, IMCS, ICYC); LAT.dump(); W.dump(); } diff --git a/src/dla/dla.hpp b/src/dla/dla.hpp index 7e292fee..9daddcb4 100644 --- a/src/dla/dla.hpp +++ b/src/dla/dla.hpp @@ -35,11 +35,12 @@ #ifndef DLA_HPP #define DLA_HPP +#include + #include #include #include #include -#include #ifdef MULTI #include "mpi.h" @@ -69,21 +70,21 @@ bool ALERT = false; #include "algorithm.hpp" #include "array.h" +#include "cf.hpp" +#include "ck.hpp" +#include "displacement.hpp" #include "io.h" #include "lattice.hpp" #include "link.hpp" -#include "wavevector.hpp" -#include "displacement.hpp" #include "measure.hpp" -#include "sf.hpp" -#include "cf.hpp" -#include "ck.hpp" #include "name.h" #include "objects.hpp" #include "parameter.hpp" +#include "sf.hpp" +#include "wavevector.hpp" class Simulation { -private: + private: int ISET; int IMCSE; int IMCSD; @@ -97,7 +98,7 @@ class Simulation { double AMP; // the average mean path of the worm per cycle bool EndOfCycle; // set to be true when the cycle ends -public: + public: int np; Simulation(Parameter& P0); @@ -137,9 +138,9 @@ class Simulation { void Check(); void dump(const char*); -private: + private: bool isChainjob; - bool isEnd; //true->exit(0); false-> read cjob.bin + bool isEnd; // true->exit(0); false-> read cjob.bin std::string CJOBFILE; Timer cjob_timer; std::ofstream cjobout; @@ -151,4 +152,4 @@ class Simulation { void end_job(); }; -#endif // DLA_HPP +#endif // DLA_HPP diff --git a/src/dla/generators/boson_B.h b/src/dla/generators/boson_B.h index 8196e590..cef44b87 100644 --- a/src/dla/generators/boson_B.h +++ b/src/dla/generators/boson_B.h @@ -4,7 +4,7 @@ //============================================================================ class BosonOperator { -public: + public: int K; int D; cmatrix I; @@ -35,13 +35,13 @@ BosonOperator::BosonOperator(int K0) { Y.zero(); Z.zero(); for (int i = 0; i < D - 1; i++) { - UP.re(i + 1, i) = sqrt((double)(i + 1)); //sqrt((double)((i+1)*(K-i))); + UP.re(i + 1, i) = sqrt((double)(i + 1)); // sqrt((double)((i+1)*(K-i))); } DN = t(UP); // X = 0.5 * (UP + DN); cmatrix temp = UP + DN; - X = 0.5 * temp; - Y = ((-0.5) * IUNIT) * (UP - DN); + X = 0.5 * temp; + Y = ((-0.5) * IUNIT) * (UP - DN); for (int i = 0; i < D; i++) { I.re(i, i) = 1.0; Z.re(i, i) = (double)i; @@ -51,7 +51,7 @@ BosonOperator::BosonOperator(int K0) { //---------------------------------------------------------------------------- class BosonOperatorSet { -public: + public: int DS; // the dimension of the 1-spin Hilbert space int N; // "N" in SU(N) int K; // the number of bosons on each site @@ -68,7 +68,7 @@ class BosonOperatorSet { BosonOperatorSet(int K0, int NSITE0) { printf("BosonSet> start.\n"); - K = K0; + K = K0; NSITE = NSITE0; BosonOperator S(K); @@ -76,9 +76,9 @@ class BosonOperatorSet { DS = S.D; UP = new cmatrix[NSITE]; DN = new cmatrix[NSITE]; - X = new cmatrix[NSITE]; - Y = new cmatrix[NSITE]; - Z = new cmatrix[NSITE]; + X = new cmatrix[NSITE]; + Y = new cmatrix[NSITE]; + Z = new cmatrix[NSITE]; printf(" definig spins ...\n"); DIM = 1; @@ -99,22 +99,22 @@ class BosonOperatorSet { if (i == j) { up = (S.UP) ^ up; dn = (S.DN) ^ dn; - x = (S.X) ^ x; - y = (S.Y) ^ y; - z = (S.Z) ^ z; + x = (S.X) ^ x; + y = (S.Y) ^ y; + z = (S.Z) ^ z; } else { up = (S.I) ^ up; dn = (S.I) ^ dn; - x = (S.I) ^ x; - y = (S.I) ^ y; - z = (S.I) ^ z; + x = (S.I) ^ x; + y = (S.I) ^ y; + z = (S.I) ^ z; } UP[i] = up; DN[i] = dn; - X[i] = x; - Y[i] = y; - Z[i] = z; + X[i] = x; + Y[i] = y; + Z[i] = z; } printf(" ... done.\n"); diff --git a/src/dla/generators/canonical.h b/src/dla/generators/canonical.h index 804e0be0..4f8e623c 100644 --- a/src/dla/generators/canonical.h +++ b/src/dla/generators/canonical.h @@ -12,8 +12,7 @@ dgematrix DensityMatrix(double B, vector& V, dgematrix& U) { double emin = V[0]; for (int i = 0; i < DIM; i++) if (emin > V[i]) emin = V[i]; - for (int i = 0; i < DIM; i++) - W(i, i) = exp(-B * (V[i] - emin)); + for (int i = 0; i < DIM; i++) W(i, i) = exp(-B * (V[i] - emin)); return U * W * UT; } @@ -34,18 +33,17 @@ double chi(double B, double E1, double E0) { // --> -^2 (in the classical or the high-T limit) // double Susceptibility(double B, vector& V, dgematrix& U, dgematrix& Q) { - int DIM = V.size(); - double* E = new double[DIM]; + int DIM = V.size(); + double* E = new double[DIM]; double emin = V[0]; for (int i = 0; i < DIM; i++) if (V[i] < emin) emin = V[i]; - for (int i = 0; i < DIM; i++) - E[i] = V[i] - emin; + for (int i = 0; i < DIM; i++) E[i] = V[i] - emin; dgematrix UT(DIM, DIM); dgematrix W(DIM, DIM); UT = t(U); - W = UT * Q * U; + W = UT * Q * U; double Z0 = 0.0; double Z1 = 0.0; @@ -69,7 +67,7 @@ double Susceptibility(double B, vector& V, dgematrix& U, dgematrix& Q) { double CanonicalAverage(dgematrix& R, dgematrix& Q) { double z0 = 0.0; double z1 = 0.0; - int n = R.n; + int n = R.n; dgematrix W(n, n); W = R * Q; for (int i = 0; i < n; i++) { diff --git a/src/dla/generators/cfgene.cc b/src/dla/generators/cfgene.cc index 54c27dac..85e7f6a2 100644 --- a/src/dla/generators/cfgene.cc +++ b/src/dla/generators/cfgene.cc @@ -7,9 +7,9 @@ #include #include #include -#include #include #include +#include using namespace std; @@ -28,13 +28,13 @@ void ShowUsage(std::string const& exename) { void WriteXML(int D, int L[], int Ntau, std::string const& filename) { ofstream fout(filename.c_str()); fout.precision(15); - int N = 1; //number of sites. + int N = 1; // number of sites. for (int i = 0; i < D; i++) { N *= L[i]; } int NumberOfElements = N * N; - int NumberOfKinds = N; + int NumberOfKinds = N; fout << "" << endl << endl; fout << "" << endl; @@ -49,8 +49,8 @@ void WriteXML(int D, int L[], int Ntau, std::string const& filename) { fout << "" << endl << endl; - int NB = 0; //3 * N ; // number of bonds - int* x = new int[D]; + int NB = 0; // 3 * N ; // number of bonds + int* x = new int[D]; int* dx = new int[D]; int kind = 0; @@ -91,11 +91,11 @@ void WriteXML(int D, int L[], int Ntau, std::string const& filename) { int main(int argc, char** argv) { std::string exename(argv[0]); std::string filename("cf.xml"); - if(argc < 3){ + if (argc < 3) { ShowUsage(exename); exit(0); } - if(std::strcmp(argv[1], "-o")==0){ + if (std::strcmp(argv[1], "-o") == 0) { filename = argv[2]; argc -= 2; argv += 2; @@ -105,7 +105,7 @@ int main(int argc, char** argv) { ShowUsage(exename); exit(0); } - int iarg = 1; + int iarg = 1; const int D = atoi(argv[iarg]); iarg++; if (argc != D + 3) { @@ -129,7 +129,9 @@ int main(int argc, char** argv) { EvenOrOdd += L[i] % 2; } - if (EvenOrOdd) { cout << "Warnig: L should be an even number." << endl; } + if (EvenOrOdd) { + cout << "Warnig: L should be an even number." << endl; + } WriteXML(D, L, Ntau, filename); cout << "... done." << endl; diff --git a/src/dla/generators/dla_alg.cc b/src/dla/generators/dla_alg.cc index b137224a..198797d8 100644 --- a/src/dla/generators/dla_alg.cc +++ b/src/dla/generators/dla_alg.cc @@ -1,8 +1,8 @@ #include "dla_alg.h" -bool isdiagonal(int *x, int NBODY){ - for(int i=0; i 1) { HFILE = argv[1]; } - if (argc > 2) { AFILE = argv[2]; } + if (argc > 1) { + HFILE = argv[1]; + } + if (argc > 2) { + AFILE = argv[2]; + } printf("HFILE= %s\n", HFILE); printf("AFILE= %s\n", AFILE); XML::Block X(HFILE, "Hamiltonian"); FALG = fopen(AFILE, "w"); - //FALG = stdout; + // FALG = stdout; XML::Block& XGEN = X["General"]; GENERAL G(XGEN); - Site = new SITE[NSTYPE]; - Source = new SOURCE[NSTYPE]; + Site = new SITE[NSTYPE]; + Source = new SOURCE[NSTYPE]; Interaction = new INTERACTION[NITYPE]; - Vertex = new VERTEX[NVTYPE]; + Vertex = new VERTEX[NVTYPE]; for (int i = 0; i < X.NumberOfBlocks(); i++) { - XML::Block& B = X[i]; + XML::Block& B = X[i]; const std::string& name = B.getName(); if (name == "Site") { int id = B["STYPE"].getInteger(); @@ -64,18 +68,17 @@ int main(int argc, char** argv) { for (int i = 0; i < NSTYPE; i++) { VERTEX& V = Site[i].V(); - V.EBASE = 2.0 * G.WeightDiagonal; + V.EBASE = 2.0 * G.WeightDiagonal; } // Interaction vertex has the own EBASE for (int i = 0; i < NITYPE; i++) { VERTEX& V = Interaction[i].V(); - V.EBASE = V.ComputeEBASE(); + V.EBASE = V.ComputeEBASE(); } - for (int i = 0; i < NVTYPE; i++) - Vertex[i].ComputeScatteringProbability(); + for (int i = 0; i < NVTYPE; i++) Vertex[i].ComputeScatteringProbability(); for (int i = 0; i < NSTYPE; i++) { Site[i].SetInitialHeadTypeProbability(); @@ -85,15 +88,11 @@ int main(int argc, char** argv) { Interaction[i].SetVertexDensity(); } - fprintf(FALG, "\n"); G.write(); - for (int i = 0; i < NSTYPE; i++) - Site[i].write(); - for (int i = 0; i < NITYPE; i++) - Interaction[i].write(); - for (int i = 0; i < NVTYPE; i++) - Vertex[i].write(); + for (int i = 0; i < NSTYPE; i++) Site[i].write(); + for (int i = 0; i < NITYPE; i++) Interaction[i].write(); + for (int i = 0; i < NVTYPE; i++) Vertex[i].write(); fprintf(FALG, "\n\n"); delete[] Site; @@ -106,13 +105,13 @@ int main(int argc, char** argv) { GENERAL::GENERAL(XML::Block& X) { NHTYPE = 0; - NXMAX = 0; + NXMAX = 0; comment = X["Comment"].getJoinedString(); - NSTYPE = X["NSTYPE"].getInteger(); - NITYPE = X["NITYPE"].getInteger(); - NXMAX = X["NXMAX"].getInteger(); - NVTYPE = NSTYPE + NITYPE; + NSTYPE = X["NSTYPE"].getInteger(); + NITYPE = X["NITYPE"].getInteger(); + NXMAX = X["NXMAX"].getInteger(); + NVTYPE = NSTYPE + NITYPE; } //====================================================================== @@ -135,10 +134,10 @@ void GENERAL::write() { //###################################################################### void SITE::load(XML::Block& X) { - ID = X["STYPE"].getInteger(); + ID = X["STYPE"].getInteger(); TTYPE = X["TTYPE"].getInteger(); - NX = X["NX"].getInteger(); - _T = &Source[TTYPE]; + NX = X["NX"].getInteger(); + _T = &Source[TTYPE]; } //====================================================================== @@ -155,21 +154,21 @@ void SITE::SetInitialHeadTypeProbability() { WormCreationProbability.init(2, NXMAX, 2 * NXMAX); WormCreationProbability.set_all(0.0); NumberOfChannels = new int[NX]; - VERTEX& V = Vertex[VTYPE]; + VERTEX& V = Vertex[VTYPE]; for (int i = 0; i < V.NICG; i++) { InitialConfigurationGroup& icg = V.ICG(i); for (int j = 0; j < icg.NIC; j++) { InitialConfiguration& ic = icg.IC[j]; if (ic.INC == DIR::UNDEF) { - int x0 = ic.State[0]; - int NCH = ic.NCH; + int x0 = ic.State[0]; + int NCH = ic.NCH; NumberOfChannels[x0] = NCH; for (int c = 0; c < NCH; c++) { - int st = ic.FinalState[c]; - int out = ic.FinalDirection[c]; - double p = ic.ScatteringProbability[c]; - WormCreationNewState(x0, c) = st; - WormCreationDirection(x0, c) = out; + int st = ic.FinalState[c]; + int out = ic.FinalDirection[c]; + double p = ic.ScatteringProbability[c]; + WormCreationNewState(x0, c) = st; + WormCreationDirection(x0, c) = out; WormCreationProbability(x0, c) = p; } } @@ -185,8 +184,8 @@ void SITE::write() { fprintf(FALG, " %d \n", ID); fprintf(FALG, " %d \n", NX); fprintf(FALG, " %d \n", VTYPE); - //printf(" %24.16f \n", V().EBASE ); - //fprintf(FALG," %24.16f \n", V().EBASE ); + // printf(" %24.16f \n", V().EBASE ); + // fprintf(FALG," %24.16f \n", V().EBASE ); for (int x0 = 0; x0 < NX; x0++) { fprintf(FALG, " \n"); fprintf(FALG, " %d \n", x0); @@ -228,12 +227,12 @@ void SITE::dump() { //###################################################################### void SOURCE::load(XML::Block& X) { - ID = X["TTYPE"].getInteger(); - VTYPE = ID; - VERTEX& V = Vertex[VTYPE]; - _V = &V; - V.ID = VTYPE; - V.NBODY = 1; + ID = X["TTYPE"].getInteger(); + VTYPE = ID; + VERTEX& V = Vertex[VTYPE]; + _V = &V; + V.ID = VTYPE; + V.NBODY = 1; V.CATEGORY = VCAT::WORM; V.load(X); } @@ -245,33 +244,32 @@ void SOURCE::dump() { printf("SOURCE[%d]> vt=%2d\n", ID, VTYPE); } //###################################################################### void INTERACTION::load(XML::Block& X) { - ID = X["ITYPE"].getInteger(); - VTYPE = ID + NSTYPE; - _V = &(Vertex[VTYPE]); - NBODY = X["NBODY"].getInteger(); + ID = X["ITYPE"].getInteger(); + VTYPE = ID + NSTYPE; + _V = &(Vertex[VTYPE]); + NBODY = X["NBODY"].getInteger(); - int NLEG = 2*NBODY; + int NLEG = 2 * NBODY; Sign.init("Weight", NLEG, NXMAX, ARRAY::EOL); Sign.set_all(0.0); - + int* x = new int[NLEG]; for (int i = 0; i < X.NumberOfBlocks(); i++) { - XML::Block& B = X[i]; + XML::Block& B = X[i]; const std::string& name = B.getName(); if (name == "Weight") { - for (int i = 0; i < NLEG; i++) - x[i] = B.getInteger(i); + for (int i = 0; i < NLEG; i++) x[i] = B.getInteger(i); double w = B.getDouble(NLEG); - if (w < 0.0 && !isdiagonal(x,NBODY)){ + if (w < 0.0 && !isdiagonal(x, NBODY)) { Sign(x) = -1.0; } } } delete[] x; - V().ID = VTYPE; - V().NBODY = NBODY; + V().ID = VTYPE; + V().NBODY = NBODY; V().CATEGORY = VCAT::INT; V().load(X); } @@ -279,23 +277,22 @@ void INTERACTION::load(XML::Block& X) { //====================================================================== void INTERACTION::SetVertexDensity() { - VERTEX& V = Vertex[VTYPE]; + VERTEX& V = Vertex[VTYPE]; IndexSystem& I = V.Weight.index_system(); - int* x = new int[I.dimension()]; + int* x = new int[I.dimension()]; VertexDensity.init(NBODY, NXMAX, ARRAY::EOL); IndexSystem& J = VertexDensity.index_system(); - int* y = new int[J.dimension()]; //edit sakakura + int* y = new int[J.dimension()]; // edit sakakura VertexDensity.set_all(0.0); for (int g = 0; g < V.NICG; g++) { InitialConfigurationGroup& G = V.ICG(g); for (int c = 0; c < G.NIC; c++) { InitialConfiguration& C = G.IC[c]; if (!C.isKink()) { - int sti = C.STI; + int sti = C.STI; double w = C.vertex_weight(); I.coord(sti, x); - for (int i = 0; i < NBODY; i++) - y[i] = x[2 * i]; + for (int i = 0; i < NBODY; i++) y[i] = x[2 * i]; VertexDensity(y) = w; } } @@ -321,8 +318,7 @@ void INTERACTION::write() { if (d > 0.0) { I.coord(i, x); fprintf(FALG, " "); - for (int j = 0; j < NBODY; j++) - fprintf(FALG, " %2d", x[j]); + for (int j = 0; j < NBODY; j++) fprintf(FALG, " %2d", x[j]); fprintf(FALG, " %24.16lf \n", d); } } @@ -331,17 +327,17 @@ void INTERACTION::write() { // fprintf(FALG," VertexDensity is not defined.\n"); } - int NLEG = 2*NBODY; - Array & Weight = V().Weight; + int NLEG = 2 * NBODY; + Array& Weight = V().Weight; IndexSystem& I = Weight.index_system(); - int* x = new int[2*NBODY]; - for (int i=0; i 0.0 ? 1.0 : -1.0; fprintf(FALG, " "); - for (int j = 0; j<2*NBODY; ++j){ + for (int j = 0; j < 2 * NBODY; ++j) { fprintf(FALG, " %2d", x[j]); } fprintf(FALG, " %24.16lf \n", sgn); @@ -367,8 +363,7 @@ void INTERACTION::dump() { if (VertexDensity[i] > 0.0) { I.coord(i, x); printf(" x= ("); - for (int j = 0; j < I.dimension(); j++) - printf(" %1d", x[j]); + for (int j = 0; j < I.dimension(); j++) printf(" %1d", x[j]); printf(")"); printf(" density= %8.3f\n", VertexDensity[i]); printf("\n"); @@ -392,19 +387,18 @@ void VERTEX::load(XML::Block& X) { SiteTypeOfLeg.init("STYPE", 1, NLEG); SiteTypeOfLeg.set_all(STYPE::UNDEF); for (int i = 0; i < NBODY; i++) { - int st = X["STYPE"].getInteger(i); - SiteTypeOfLeg[2 * i] = st; + int st = X["STYPE"].getInteger(i); + SiteTypeOfLeg[2 * i] = st; SiteTypeOfLeg[2 * i + 1] = st; } int* x = new int[NLEG]; for (int i = 0; i < X.NumberOfBlocks(); i++) { - XML::Block& B = X[i]; + XML::Block& B = X[i]; const std::string& name = B.getName(); if (name == "Weight") { - for (int i = 0; i < NLEG; i++) - x[i] = B.getInteger(i); + for (int i = 0; i < NLEG; i++) x[i] = B.getInteger(i); double w = B.getDouble(NLEG); - if (w < 0.0 && !isdiagonal(x,NBODY)){ + if (w < 0.0 && !isdiagonal(x, NBODY)) { w *= -1.0; } Weight(x) = w; @@ -428,9 +422,9 @@ int VERTEX::NumberOfValidInitialConfigurations() { //====================================================================== void VERTEX::Grouping() { - //printf("VERTEX::Grouping> Start ID=%d\n", ID); - //printf("VERTEX::Grouping> Start.\n"); - //printf("VERTEX::Grouping> Pass 1\n"); + // printf("VERTEX::Grouping> Start ID=%d\n", ID); + // printf("VERTEX::Grouping> Start.\n"); + // printf("VERTEX::Grouping> Pass 1\n"); int NICmax = 2 * NBODY * NXMAX + 1; checked.init(3, NST, NLEG, NXMAX); @@ -442,12 +436,13 @@ void VERTEX::Grouping() { for (int sti = 0; sti < NST; sti++) { if (testForbidden(sti)) continue; if (testKink(sti)) continue; - int inc = DIR::UNDEF; - int xinc = STATE::UNDEF; + int inc = DIR::UNDEF; + int xinc = STATE::UNDEF; InitialConfigurationGroup& icg = *(new InitialConfigurationGroup); icg.init(*this, NBODY, sti, inc, xinc); add_ICG(icg); - //printf("VERTEX::Grouping> New initial configuration group. ID= %d\n", NICG); + // printf("VERTEX::Grouping> New initial configuration group. ID= %d\n", + // NICG); NICG++; } } else { @@ -456,15 +451,16 @@ void VERTEX::Grouping() { if (testForbidden(sti)) continue; for (int inc = 0; inc < NLEG; inc++) { int xinc_old = x[inc]; - int st = SiteTypeOfLeg[inc]; - SOURCE& W = Source[Site[st].TTYPE]; + int st = SiteTypeOfLeg[inc]; + SOURCE& W = Source[Site[st].TTYPE]; for (int xinc = 0; xinc < NXMAX; xinc++) { - //W.V().Weight.index_system().dump(); + // W.V().Weight.index_system().dump(); double ww = W.Weight(xinc_old, xinc); if (ww == 0.0) continue; if (checked(sti, inc, xinc) == 1) continue; - //printf("VERTEX::Grouping> New initial configuration group. ID= %d\n", NICG); + // printf("VERTEX::Grouping> New initial configuration group. ID= + // %d\n", NICG); InitialConfigurationGroup& icg = *(new InitialConfigurationGroup); icg.init(*this, NBODY, sti, inc, xinc); add_ICG(icg); @@ -472,7 +468,7 @@ void VERTEX::Grouping() { } } } - //printf(" NICG= %d, icg.size()= %d\n", NICG, icg.size()); + // printf(" NICG= %d, icg.size()= %d\n", NICG, icg.size()); } delete[] x; } @@ -493,8 +489,7 @@ double VERTEX::ComputeEBASE() { // as long as no offdiagonal bounce occurs. // - for (int icg = 0; icg < NICG; icg++) - ICG(icg).ResetWeight(); + for (int icg = 0; icg < NICG; icg++) ICG(icg).ResetWeight(); double eb; if (CATEGORY == VCAT::TERM) { @@ -521,14 +516,14 @@ double VERTEX::ComputeEBASE() { //====================================================================== void VERTEX::ComputeScatteringProbability() { - //printf("\nVERTEX::ComputeScatteringProbability> Start.\n"); + // printf("\nVERTEX::ComputeScatteringProbability> Start.\n"); NICV = 0; for (int icg = 0; icg < NICG; icg++) { ICG(icg).ResetWeight(); ICG(icg).numbering(NICV); ICG(icg).ScatteringProbability(); } - //printf("\nVERTEX::ComputeScatteringProbability> End.\n"); + // printf("\nVERTEX::ComputeScatteringProbability> End.\n"); } //====================================================================== @@ -540,10 +535,9 @@ void VERTEX::dump() { printf(" ncig= %d", NICG); printf(" eb= %8.3f", EBASE); printf(" st= ("); - for (int i = 0; i < NLEG; i++) - printf(" %1d", SiteTypeOfLeg(i)); + for (int i = 0; i < NLEG; i++) printf(" %1d", SiteTypeOfLeg(i)); printf(")\n"); - int* x = new int[NLEG]; //edit sakakura + int* x = new int[NLEG]; // edit sakakura // int x[NLEG]; for (int i = 0; i < NST; i++) { if ((!testKink(i)) || Weight[i] != 0.0) { @@ -559,8 +553,7 @@ void VERTEX::dump() { } INDX().coord(i, x); printf(" ("); - for (int j = 0; j < NLEG; j++) - printf(" %1d", x[j]); + for (int j = 0; j < NLEG; j++) printf(" %1d", x[j]); printf(") --> w= %8.3f\n", Weight[i]); } } @@ -584,15 +577,14 @@ void VERTEX::write() { " %d " "\n", NICW); - for (int i = 0; i < NICG; i++) - ICG(i).write(); + for (int i = 0; i < NICG; i++) ICG(i).write(); fprintf(FALG, "\n \n"); } //====================================================================== bool VERTEX::testKink(int ist) { - //printf("VERTEX::testKink> D = %d\n", D); + // printf("VERTEX::testKink> D = %d\n", D); int* x = new int[NLEG]; INDX().coord(ist, x); bool ans = false; @@ -618,21 +610,21 @@ void InitialConfigurationGroup::init(VERTEX& v, int nbody, int sti, int inc, // handling a group of initial configurations // that scatters into each other - //printf("InitialConfigurationGroup::init> Start. icg=%d\n", ID); + // printf("InitialConfigurationGroup::init> Start. icg=%d\n", ID); /* printf("nbody= %d, nicmax= %d, sti= %d, inc= %d, xinc= %d\n", nbody, NICmax, sti, inc, xinc); */ - _V = &v; + _V = &v; NBODY = nbody; - NLEG = 2 * nbody; + NLEG = 2 * nbody; - //int x[NLEG]; - //int y[NLEG]; - int* x = new int[NLEG]; //edit sakakura - int* y = new int[NLEG]; + // int x[NLEG]; + // int y[NLEG]; + int* x = new int[NLEG]; // edit sakakura + int* y = new int[NLEG]; IndexSystem& INDX = V().INDX(); INDX.coord(sti, x); if (inc != DIR::UNDEF) x[inc] = xinc; @@ -651,17 +643,15 @@ printf("), hti= %d, inc= %d\n", hti, inc); */ int sitei = inc / 2; - int diri = inc % 2; - + int diri = inc % 2; NIC = 0; if (inc == DIR::UNDEF) NIC = 1; // generate worm for (int out = 0; out < NLEG; out++) { for (int xout = 0; xout < NXMAX; xout++) { // xout is the new local state on the outgoing leg - for (int d = 0; d < NLEG; d++) - y[d] = x[d]; - y[out] = xout; + for (int d = 0; d < NLEG; d++) y[d] = x[d]; + y[out] = xout; int stf = INDX(y); if (stf == STATE::UNDEF) continue; if (V().testForbidden(stf)) continue; @@ -685,8 +675,7 @@ printf("), hti= %d, inc= %d\n", hti, inc); for (int out = 0; out < NLEG; out++) { for (int xout = 0; xout < NXMAX; xout++) { // xout is the new local state on the outgoing leg - for (int d = 0; d < NLEG; d++) - y[d] = x[d]; + for (int d = 0; d < NLEG; d++) y[d] = x[d]; y[out] = xout; /* printf(" ("); @@ -703,7 +692,7 @@ printf(")\n"); } delete[] x; delete[] y; - //if (MON) printf("InitialConfigurationGroup::init> End.\n"); + // if (MON) printf("InitialConfigurationGroup::init> End.\n"); } //====================================================================== @@ -786,8 +775,7 @@ double InitialConfigurationGroup::maximum_offdiagonal_weight() { double InitialConfigurationGroup::sum_of_all_weights() { double sum = 0.0; - for (int i = 0; i < NIC; i++) - sum += U[i]; + for (int i = 0; i < NIC; i++) sum += U[i]; return sum; } @@ -803,7 +791,7 @@ double max(double& d0, double& d1, double& d2) { //====================================================================== double InitialConfigurationGroup::ebase() { - //if ( MON ) printf("InitialConfigurationGroup::ebase> Start.\n"); + // if ( MON ) printf("InitialConfigurationGroup::ebase> Start.\n"); double eb, eb0, eb1, eb2; @@ -815,10 +803,11 @@ double InitialConfigurationGroup::ebase() { double dmax = maximum_diagonal_weight(); double dmin = minimum_diagonal_weight(); double omax = maximum_offdiagonal_weight(); - double sum = sum_of_all_weights(); + double sum = sum_of_all_weights(); // eb0 ... minimum EBASE to avoid negative diagonal elements // eb1 ... minimum EBASE to avoid offdiagonal bounce - // eb2 ... minimum EBASE to avoid direct transition between offdiagonal states + // eb2 ... minimum EBASE to avoid direct transition between offdiagonal + // states eb0 = -dmin; eb1 = (2.0 * omax - sum) / (double)nd; // eb2 = -INF; @@ -829,7 +818,8 @@ double InitialConfigurationGroup::ebase() { eb = eb1; } - // Above we calculate EBASE from Hamilonian weights producted by worm weights + // Above we calculate EBASE from Hamilonian weights producted by worm + // weights double ww = 0.0; for (int i = 0; i < NIC; i++) { if (!IC[i].isKink()) { @@ -846,7 +836,7 @@ double InitialConfigurationGroup::ebase() { eb /= ww; } - //if ( MON ) printf("InitialConfigurationGroup::ebase> End.\n"); + // if ( MON ) printf("InitialConfigurationGroup::ebase> End.\n"); return eb; } @@ -875,8 +865,8 @@ void InitialConfigurationGroup::numbering(int& ic) { //====================================================================== void InitialConfigurationGroup::ScatteringProbability() { - //printf("\nInitialConfigurationGroup::ScatteringProbability> Start. ICG= %d\n", ID); - //if (MON) dump(); + // printf("\nInitialConfigurationGroup::ScatteringProbability> Start. ICG= + // %d\n", ID); if (MON) dump(); // NIC : # of initial state // U : weights of initial states @@ -901,8 +891,8 @@ void InitialConfigurationGroup::ScatteringProbability() { SolveWeightEquation(NIC, UP, WP); /* - for (int i=0; i EPS) { double p = P(I, J); - int stf = IC[J].STI; - int out = IC[J].INC; + int stf = IC[J].STI; + int out = IC[J].INC; int xout = STATE::UNDEF; - if (out != DIR::UNDEF) { xout = INDX.coord(stf, out); } - IC[I].FinalDirection[nc] = out; - IC[I].FinalState[nc] = xout; + if (out != DIR::UNDEF) { + xout = INDX.coord(stf, out); + } + IC[I].FinalDirection[nc] = out; + IC[I].FinalState[nc] = xout; IC[I].ScatteringProbability[nc] = p; nc++; } @@ -931,7 +923,7 @@ void InitialConfigurationGroup::ScatteringProbability() { IC[I].NCH = nc; } - //if (MON) printf(" ==>\n"); + // if (MON) printf(" ==>\n"); } //====================================================================== @@ -976,15 +968,15 @@ void InitialConfiguration::init(VERTEX& v, int sti, int inc, int xinc, // the new state on the leg after the passage of the worm head is "xinc" setV(v); - STI = sti; - INC = inc; - XINC = xinc; - NLEG = V().NLEG; - NBODY = 2 * NLEG; - State = new int[NLEG]; + STI = sti; + INC = inc; + XINC = xinc; + NLEG = V().NLEG; + NBODY = 2 * NLEG; + State = new int[NLEG]; ScatteringProbability = new double[NICmax]; - FinalState = new int[NICmax]; - FinalDirection = new int[NICmax]; + FinalState = new int[NICmax]; + FinalDirection = new int[NICmax]; V().INDX().coord(STI, State); NCH = 0; } @@ -1026,7 +1018,7 @@ double InitialConfiguration::worm_weight() { int stype = V().SiteTypeOfLeg[INC]; int ttype = Site[stype].TTYPE; SOURCE& T = Source[ttype]; - ww = T.Weight(XINC, State[INC]); + ww = T.Weight(XINC, State[INC]); } return ww; } @@ -1063,17 +1055,17 @@ void InitialConfiguration::write() { fprintf(FALG, "\n"); fprintf(FALG, " \n"); fprintf(FALG, " "); - for (int i = 0; i < NLEG; i++) - fprintf(FALG, " %d", State[i]); + for (int i = 0; i < NLEG; i++) fprintf(FALG, " %d", State[i]); fprintf(FALG, " \n"); fprintf(FALG, " %d \n", INC); fprintf(FALG, " %d \n", XINC); fprintf(FALG, " %d \n", NCH); for (int ch = 0; ch < NCH; ch++) { - int out = FinalDirection[ch]; + int out = FinalDirection[ch]; int xout = FinalState[ch]; double p = ScatteringProbability[ch]; - fprintf(FALG, " %4d %4d %24.16lf \n", out, xout, p); + fprintf(FALG, " %4d %4d %24.16lf \n", out, xout, + p); } fprintf(FALG, " \n"); } @@ -1081,7 +1073,7 @@ void InitialConfiguration::write() { //###################################################################### void QUANTITY::load(XML::Block& X) { - ID = X["QTYPE"].getInteger(); + ID = X["QTYPE"].getInteger(); NAME = X["Name"].getString(); Value.init(2, NSTYPE, NXMAX); Value.set_all(0.0); @@ -1090,11 +1082,11 @@ void QUANTITY::load(XML::Block& X) { for (int i = 0; i < X.NumberOfBlocks(); i++) { XML::Block& B = X[i]; if (B.getName() == "Value") { - int st = B.getInteger(0); - int x = B.getInteger(1); - double v = B.getDouble(2); + int st = B.getInteger(0); + int x = B.getInteger(1); + double v = B.getDouble(2); isDefined(st, x) = true; - Value(st, x) = v; + Value(st, x) = v; } } } @@ -1147,7 +1139,7 @@ void SolveWeightEquation(int N, Array& V, Array& W) { N_first = p; if (p == N) { V_second = 0.0; - V_third = 0.0; + V_third = 0.0; N_second = 0; } else { V_second = V[p]; @@ -1172,15 +1164,15 @@ void SolveWeightEquation(int N, Array& V, Array& W) { double x = V_first - V_second; double y = (double)(N_second - 1) * (V_second - V_third); if (x < y) { - dw1 = (V_first - V_second) / (1.0 - 1.0 / (double)(N_second)); - dw2 = dw1 / (double)N_second; + dw1 = (V_first - V_second) / (1.0 - 1.0 / (double)(N_second)); + dw2 = dw1 / (double)N_second; V_second_new = V_second - dw2; - V_first_new = V_second_new; + V_first_new = V_second_new; } else { - dw2 = V_second - V_third; - dw1 = dw2 * (double)N_second; + dw2 = V_second - V_third; + dw1 = dw2 * (double)N_second; V_second_new = V_third; - V_first_new = V_first - dw1; + V_first_new = V_first - dw1; } V[0] = V_first_new; for (int i = 1; i < 1 + N_second; i++) { @@ -1211,14 +1203,13 @@ void SolveWeightEquation(int N, Array& V, Array& W) { //====================================================================== void bubble_sort(int N, Array& V, Array& I) { - for (int i = 0; i < N; i++) - I[i] = i; + for (int i = 0; i < N; i++) I[i] = i; for (int i = 0; i < N - 1; i++) { for (int j = i + 1; j < N; j++) { if (V[I[i]] < V[I[j]]) { int ii = I[i]; - I[i] = I[j]; - I[j] = ii; + I[i] = I[j]; + I[j] = ii; } } } diff --git a/src/dla/generators/dla_alg.h b/src/dla/generators/dla_alg.h index e9957eb6..db27916f 100644 --- a/src/dla/generators/dla_alg.h +++ b/src/dla/generators/dla_alg.h @@ -6,6 +6,7 @@ #include #include + #include "array.h" #include "io.h" #include "name.h" @@ -30,7 +31,7 @@ void bubble_sort(int N, Array& V, Array& I); //###################################################################### class GENERAL { -public: + public: std::string comment; // "WeightDiagonal" // the artificial weight attached to the diagonal state @@ -44,7 +45,7 @@ class GENERAL { //###################################################################### class SITE { -public: + public: int ID; int TTYPE; // the SOURCE type of the worm tail int VTYPE; // the VERTEX type of the worm tail @@ -58,11 +59,11 @@ class SITE { Array WormCreationProbability; SITE() { - _T = 0; - ID = STYPE::UNDEF; - TTYPE = TTYPE::UNDEF; - VTYPE = VTYPE::UNDEF; - NX = 0; + _T = 0; + ID = STYPE::UNDEF; + TTYPE = TTYPE::UNDEF; + VTYPE = VTYPE::UNDEF; + NX = 0; NumberOfChannels = 0; }; @@ -82,10 +83,10 @@ class SITE { //###################################################################### class VERTEX { -private: + private: IndexSystem* _INDX; -public: + public: int ID; std::vector icg; InitialConfigurationGroup& ICG(int i) { return *(icg[i]); }; @@ -93,9 +94,10 @@ class VERTEX { int NBODY; // the number of sites interacting int NLEG; - int NICG; // number of initial configuration group - int NICV; // total number of initial configurations - int NST; // the number of initial states (not including worm type or direction) + int NICG; // number of initial configuration group + int NICV; // total number of initial configurations + int NST; // the number of initial states (not including worm type or + // direction) int CATEGORY; // =0 (TERM), =1 (WORM), =2 (INTERACTION) double EBASE; Array Weight; @@ -106,14 +108,14 @@ class VERTEX { IndexSystem& INDX() { return *_INDX; }; VERTEX() { - ID = VTYPE::UNDEF; - NBODY = 0; - NLEG = 0; - NICG = 0; - NICV = 0; - NST = 0; + ID = VTYPE::UNDEF; + NBODY = 0; + NLEG = 0; + NICG = 0; + NICV = 0; + NST = 0; CATEGORY = VCAT::UNDEF; - EBASE = 0.0; + EBASE = 0.0; }; ~VERTEX(){}; @@ -135,16 +137,16 @@ class VERTEX { //###################################################################### class SOURCE { -public: + public: int ID; int STYPE; int VTYPE; VERTEX* _V; SOURCE() { - ID = TTYPE::UNDEF; + ID = TTYPE::UNDEF; STYPE = STYPE::UNDEF; VTYPE = VTYPE::UNDEF; - _V = 0; + _V = 0; }; VERTEX& V() { if (_V == 0) { @@ -161,7 +163,7 @@ class SOURCE { //###################################################################### class INTERACTION { -public: + public: int ID; int VTYPE; int NBODY; @@ -171,7 +173,7 @@ class INTERACTION { Array Sign; INTERACTION() { - ID = ITYPE::UNDEF; + ID = ITYPE::UNDEF; VTYPE = VTYPE::UNDEF; NBODY = 0; }; @@ -186,11 +188,11 @@ class INTERACTION { //###################################################################### class InitialConfiguration { -private: + private: static int LastID; int ID; -public: + public: friend class InitialConfigurationGroup; int NBODY; @@ -209,9 +211,9 @@ class InitialConfiguration { InitialConfiguration() { ID = LastID; LastID++; - State = 0; - FinalState = 0; - FinalDirection = 0; + State = 0; + FinalState = 0; + FinalDirection = 0; ScatteringProbability = 0; }; @@ -240,11 +242,11 @@ int InitialConfiguration::LastID = 0; //###################################################################### class InitialConfigurationGroup { -private: + private: static int LastID; int ID; -public: + public: int NIC; int NDIAG; Array U; @@ -299,11 +301,11 @@ int InitialConfigurationGroup::LastID = 0; //###################################################################### class QUANTITY { -private: + private: int ID; std::string NAME; -public: + public: Array Value; Array isDefined; int getID() { return ID; }; diff --git a/src/dla/generators/exact_B.cc b/src/dla/generators/exact_B.cc index e0d35fcc..4156f4d8 100644 --- a/src/dla/generators/exact_B.cc +++ b/src/dla/generators/exact_B.cc @@ -1,23 +1,23 @@ -#include #include +#include #include #include using namespace std; -#include "matrix.h" #include "boson_B.h" #include "canonical.h" +#include "matrix.h" //---------------------------------------------------------------------- // Bose-Hubbard Model -//H= - J\sum_{} b_i b_j + V\sum_{} n_i n_j +// H= - J\sum_{} b_i b_j + V\sum_{} n_i n_j // + u/2z \sum_{}( n_i (n_i + 1) + n_j (n_j + 1) ) // - mu/z \sum_{}( n_i + n_j ). -//F=mu/z, -//U=u/z +// F=mu/z, +// U=u/z class BoseHubbardModel { -public: + public: int M; // Number of bosons ( [M]-representaion ) int NSITE; double J; // the bilinear coupling for XY @@ -34,13 +34,13 @@ class BoseHubbardModel { BoseHubbardModel(int M0, int NSITE0, double J0, double V0, double U0, double F0) { - M = M0; + M = M0; NSITE = NSITE0; - J = J0; - V = V0; - U = U0; - F = F0; - //double Vh=V*0.5; + J = J0; + V = V0; + U = U0; + F = F0; + // double Vh=V*0.5; BosonOperatorSet S(M, NSITE); @@ -51,7 +51,7 @@ class BoseHubbardModel { for (int k = 0; k < NSITE; k++) { int l = (k + 1) % NSITE; printf(" k= %d\n", k); - //h += (-J) * ( S.X[k] * S.X[l] + S.Y[k] * S.Y[l] ); + // h += (-J) * ( S.X[k] * S.X[l] + S.Y[k] * S.Y[l] ); h += (-J) * (S.UP[k] * S.DN[l]); h += (+V) * (S.Z[k] * S.Z[l]); } @@ -81,12 +81,12 @@ class BoseHubbardModel { } printf(" ... done.\n"); - H = h.re; + H = h.re; MXU = mxu.re; MZU = mzu.re; MXS = mxs.re; MZS = mzs.re; - I = S.I.re; + I = S.I.re; }; }; @@ -94,7 +94,7 @@ class BoseHubbardModel { void Average(int DIM, dgematrix& R, dgematrix& Q, double& Ave, double& Var) { dgematrix W(DIM, DIM); - W = Q * Q; + W = Q * Q; Ave = CanonicalAverage(R, Q); Var = CanonicalAverage(R, W); Var = Var - Ave * Ave; @@ -102,10 +102,10 @@ void Average(int DIM, dgematrix& R, dgematrix& Q, double& Ave, double& Var) { //============================================================================ -void WriteXML(int M, dgematrix& Q, dgematrix& H, std::string const & filename) { +void WriteXML(int M, dgematrix& Q, dgematrix& H, std::string const& filename) { FILE* FOUT = fopen(filename.c_str(), "w"); - int D = M + 1; - int DD = D * D; + int D = M + 1; + int DD = D * D; fprintf(FOUT, "\n"); fprintf(FOUT, " \n"); fprintf(FOUT, @@ -143,8 +143,8 @@ void WriteXML(int M, dgematrix& Q, dgematrix& H, std::string const & filename) { int i0 = i % D; int i1 = i / D; for (int j = 0; j < DD; j++) { - int j0 = j % D; - int j1 = j / D; + int j0 = j % D; + int j1 = j / D; double x = -H(i, j); if (abs(x) > 1.0e-8) { // if (i != j) x = abs(x); @@ -157,13 +157,15 @@ void WriteXML(int M, dgematrix& Q, dgematrix& H, std::string const & filename) { fprintf(FOUT, "\n"); } -void ShowUsage(std::string const& exename){ +void ShowUsage(std::string const& exename) { printf("usage:\n"); printf(" %s [-o filename] M J V U F\n", exename.c_str()); printf("arguments:\n"); printf(" M ... the maxmum number of bosons on each site \n"); printf(" J ... the hopping constant (positive)\n"); - printf(" V ... the nearest neighbor interaction (positive for " "replusive)\n"); + printf( + " V ... the nearest neighbor interaction (positive for " + "replusive)\n"); printf(" U ... the on-site interaction (positive for replusive)\n"); printf(" ( = u/z if the field u is the field per site.)\n"); printf(" F ... the chemical potential in the pair Hamiltonian\n"); @@ -181,11 +183,11 @@ void ShowUsage(std::string const& exename){ int main(int argc, char** argv) { string exename = argv[0]; string filename("hamiltonian.xml"); - if(argc < 3){ + if (argc < 3) { ShowUsage(exename); exit(0); } - if(std::strcmp(argv[1], "-o")==0){ + if (std::strcmp(argv[1], "-o") == 0) { filename = argv[2]; argc -= 2; argv += 2; @@ -196,7 +198,7 @@ int main(int argc, char** argv) { ShowUsage(exename); exit(0); } - int M = atoi(argv[1]); + int M = atoi(argv[1]); double J = (double)atof(argv[2]); double V = (double)atof(argv[3]); double U = (double)atof(argv[4]); diff --git a/src/dla/generators/exact_H.cc b/src/dla/generators/exact_H.cc index b9fcb8bb..b2feed9b 100644 --- a/src/dla/generators/exact_H.cc +++ b/src/dla/generators/exact_H.cc @@ -1,10 +1,10 @@ -#include #include +#include #include #include using namespace std; -#include "matrix.h" #include "canonical.h" +#include "matrix.h" #include "spin_H.h" //---------------------------------------------------------------------- @@ -12,7 +12,7 @@ using namespace std; // Heisenberg Model class HeisenbergModel { -public: + public: int M; // Number of bosons ( [M]-representaion ) int NSITE; double J; // the bilinear coupling @@ -26,10 +26,10 @@ class HeisenbergModel { dgematrix I; HeisenbergModel(int M0, int NSITE0, double J0, double F0) { - M = M0; + M = M0; NSITE = NSITE0; - J = J0; - F = F0; + J = J0; + F = F0; HeisenbergSpinSet S(M, NSITE); @@ -67,12 +67,12 @@ class HeisenbergModel { } printf(" ... done.\n"); - H = h.re; + H = h.re; MXU = mxu.re; MZU = mzu.re; MXS = mxs.re; MZS = mzs.re; - I = S.I.re; + I = S.I.re; }; }; @@ -80,7 +80,7 @@ class HeisenbergModel { void Average(int DIM, dgematrix& R, dgematrix& Q, double& Ave, double& Var) { dgematrix W(DIM, DIM); - W = Q * Q; + W = Q * Q; Ave = CanonicalAverage(R, Q); Var = CanonicalAverage(R, W); Var = Var - Ave * Ave; @@ -90,8 +90,8 @@ void Average(int DIM, dgematrix& R, dgematrix& Q, double& Ave, double& Var) { void WriteXML(int M, dgematrix& Q, dgematrix& H, std::string const& filename) { FILE* FOUT = fopen(filename.c_str(), "w"); - int D = M + 1; - int DD = D * D; + int D = M + 1; + int DD = D * D; fprintf(FOUT, "\n"); fprintf(FOUT, " \n"); fprintf(FOUT, " SU(2) Heisenberg model with S=%d/2 \n", @@ -128,8 +128,8 @@ void WriteXML(int M, dgematrix& Q, dgematrix& H, std::string const& filename) { int i0 = i % D; int i1 = i / D; for (int j = 0; j < DD; j++) { - int j0 = j % D; - int j1 = j / D; + int j0 = j % D; + int j1 = j / D; double x = -H(i, j); if (abs(x) > 1.0e-8) { // if (i != j) x = abs(x); @@ -142,7 +142,7 @@ void WriteXML(int M, dgematrix& Q, dgematrix& H, std::string const& filename) { fprintf(FOUT, "\n"); } -void ShowUsage(std::string const& exename){ +void ShowUsage(std::string const& exename) { printf("usage:\n"); printf(" %s [-o filename] M J F\n", exename.c_str()); printf("arguments:\n"); @@ -162,15 +162,14 @@ void ShowUsage(std::string const& exename){ //============================================================================ int main(int argc, char** argv) { - string exename = argv[0]; string filename("hamiltonian.xml"); - if(argc < 3){ + if (argc < 3) { ShowUsage(exename); exit(0); } - if(std::strcmp(argv[1], "-o")==0){ + if (std::strcmp(argv[1], "-o") == 0) { filename = argv[2]; argc -= 2; argv += 2; @@ -181,7 +180,7 @@ int main(int argc, char** argv) { ShowUsage(exename); exit(0); } - int M = atoi(argv[1]); + int M = atoi(argv[1]); double J = (double)atof(argv[2]); double F = (double)atof(argv[3]); printf(" M = %4d\n", M); diff --git a/src/dla/generators/lattgene_C.cc b/src/dla/generators/lattgene_C.cc index 940d4f33..82372c71 100644 --- a/src/dla/generators/lattgene_C.cc +++ b/src/dla/generators/lattgene_C.cc @@ -4,12 +4,12 @@ ----------------------------------------------*/ -#include #include +#include +#include #include #include #include -#include using namespace std; @@ -29,17 +29,17 @@ void ShowUsage(std::string const& exename) { void WriteXML(int D, int L[], std::string const& filename) { ofstream fout(filename.c_str()); fout.precision(15); - int N = 1; //number of sites. + int N = 1; // number of sites. for (int i = 0; i < D; i++) { N *= L[i]; } - int NumberOfInteractions = N * D; - int NumberOfSiteTypes = 1; + int NumberOfInteractions = N * D; + int NumberOfSiteTypes = 1; int NumberOfInteractionTypes = 1; int NumberOfEdgeInteractions = 0; - //Hypercubic + // Hypercubic int* Lext = new int[D]; for (int di = 0; di < D; di++) { @@ -49,10 +49,9 @@ void WriteXML(int D, int L[], std::string const& filename) { } } - for (int di = 0; di < D; di++) - NumberOfEdgeInteractions += Lext[di]; + for (int di = 0; di < D; di++) NumberOfEdgeInteractions += Lext[di]; - int BD = D; //Hypercubic + int BD = D; // Hypercubic fout << "" << endl << endl; fout << "" << endl; @@ -84,9 +83,9 @@ void WriteXML(int D, int L[], std::string const& filename) { int mtype = 0; for (int id = 0; id < N; id++) { - int p = id; + int p = id; int Nt = N; - mtype = 0; + mtype = 0; for (int q = D - 1; q >= 0; q--) { Nt /= L[q]; mtype += p / Nt; @@ -102,11 +101,11 @@ void WriteXML(int D, int L[], std::string const& filename) { << endl << endl; - int NB = D * N; // number of bonds - int* x = new int[D]; + int NB = D * N; // number of bonds + int* x = new int[D]; int itype = 0; int nbody = 2; - NB = 0; + NB = 0; int etype; int eid = 0; @@ -124,7 +123,7 @@ void WriteXML(int D, int L[], std::string const& filename) { } else etype = -1; - x[p] = (x[p] + 1) % L[p]; + x[p] = (x[p] + 1) % L[p]; int j = 0; for (int q = D - 1; q >= 0; q--) { j *= L[q]; @@ -159,15 +158,15 @@ void WriteXML(int D, int L[], std::string const& filename) { int main(int argc, char** argv) { std::string exename(argv[0]); - if (argc < 3 ){ + if (argc < 3) { ShowUsage(exename); exit(0); } std::string filename("lattice.xml"); - if (std::strcmp(argv[1], "-o") == 0){ + if (std::strcmp(argv[1], "-o") == 0) { filename = argv[2]; argc -= 2; - argv = argv+2; + argv = argv + 2; } int NARG = 3; if (argc < NARG) { @@ -176,7 +175,7 @@ int main(int argc, char** argv) { } const int D = atoi(argv[1]); // int L[D] ; - int* L = new int[D]; //edit sakakura + int* L = new int[D]; // edit sakakura if (argc == NARG) { int lx = atoi(argv[2]); @@ -201,7 +200,9 @@ int main(int argc, char** argv) { EvenOrOdd += L[i] % 2; } - if (EvenOrOdd) { cout << "Warnig: L should be an even number." << endl; } + if (EvenOrOdd) { + cout << "Warnig: L should be an even number." << endl; + } WriteXML(D, L, filename); cout << "... done." << endl; diff --git a/src/dla/generators/lattgene_T.cc b/src/dla/generators/lattgene_T.cc index dac4da67..18fe7215 100644 --- a/src/dla/generators/lattgene_T.cc +++ b/src/dla/generators/lattgene_T.cc @@ -4,8 +4,8 @@ ----------------------------------------------*/ -#include #include +#include #include #include #include @@ -28,15 +28,15 @@ void WriteXML(std::vector const& L, std::string const& filename) { const int D = L.size(); ofstream fout(filename.c_str()); fout.precision(15); - int N = 1; //number of sites. + int N = 1; // number of sites. for (int i = 0; i < D; i++) { N *= L[i]; } - int BD = 3; //Triangular + int BD = 3; // Triangular - int NumberOfInteractions = N * BD; - int NumberOfSiteTypes = 1; + int NumberOfInteractions = N * BD; + int NumberOfSiteTypes = 1; int NumberOfInteractionTypes = 1; int NumberOfEdgeInteractions = 0; @@ -53,7 +53,7 @@ void WriteXML(std::vector const& L, std::string const& filename) { NumberOfEdgeInteractions += Lext[di]; } - NumberOfEdgeInteractions--; //double count of the corner site. + NumberOfEdgeInteractions--; // double count of the corner site. fout << "" << endl << endl; fout << "" << endl; @@ -68,10 +68,14 @@ void WriteXML(std::vector const& L, std::string const& filename) { } fout << "" << endl; fout << " " << N << " " << endl; - fout << " " << NumberOfInteractions << " " << endl; - fout << " " << NumberOfSiteTypes << " " << endl; - fout << " " << NumberOfInteractionTypes << " " << endl; - fout << " " << NumberOfEdgeInteractions << " " << endl; + fout << " " << NumberOfInteractions + << " " << endl; + fout << " " << NumberOfSiteTypes << " " + << endl; + fout << " " << NumberOfInteractionTypes + << " " << endl; + fout << " " << NumberOfEdgeInteractions + << " " << endl; fout << endl; @@ -79,8 +83,8 @@ void WriteXML(std::vector const& L, std::string const& filename) { std::vector x(D); for (int id = 0; id < N; id++) { - x[0] = id % L[0]; - x[1] = id / L[0]; + x[0] = id % L[0]; + x[1] = id / L[0]; int stype = 0; int mtype = (x[0] + x[1]) % 3; @@ -88,7 +92,9 @@ void WriteXML(std::vector const& L, std::string const& filename) { } fout << endl; - fout << "" << endl << endl; + fout << "" + << endl + << endl; int NB = 0; // number of bonds int itype = 0; @@ -100,36 +106,36 @@ void WriteXML(std::vector const& L, std::string const& filename) { for (int i = 0; i < N; i++) { int k = i; - x[0] = k % L[0]; - x[1] = k / L[0]; + x[0] = k % L[0]; + x[1] = k / L[0]; etype = -1; - p = -1; - j = (x[0] + 1) % L[0] + x[1] * L[0]; + p = -1; + j = (x[0] + 1) % L[0] + x[1] * L[0]; if (x[0] == L[0] - 1) { etype = eid; eid++; p = 0; } - fout << " " << NB << " " << itype << " " << nbody << " " << i << " " << j << " " << etype << " " << p << " " - << endl; + fout << " " << NB << " " << itype << " " << nbody << " " << i << " " << j + << " " << etype << " " << p << " " << endl; NB++; etype = -1; - p = -1; - j = x[0] + ((x[1] + 1) % L[1]) * L[0]; + p = -1; + j = x[0] + ((x[1] + 1) % L[1]) * L[0]; if (x[1] == L[1] - 1) { etype = eid; eid++; p = 1; } - fout << " " << NB << " " << itype << " " << nbody << " " << i << " " << j << " " << etype << " " << p << " " - << endl; + fout << " " << NB << " " << itype << " " << nbody << " " << i << " " << j + << " " << etype << " " << p << " " << endl; NB++; etype = -1; - p = -1; - j = (x[0] + 1) % L[0] + ((x[1] + 1) % L[1]) * L[0]; + p = -1; + j = (x[0] + 1) % L[0] + ((x[1] + 1) % L[1]) * L[0]; if (x[0] == L[0] - 1 && x[1] == L[1] - 1) { etype = eid; eid++; @@ -144,8 +150,8 @@ void WriteXML(std::vector const& L, std::string const& filename) { p = 1; } - fout << " " << NB << " " << itype << " " << nbody << " " << i << " " << j << " " << etype << " " << p << " " - << endl; + fout << " " << NB << " " << itype << " " << nbody << " " << i << " " << j + << " " << etype << " " << p << " " << endl; NB++; } @@ -186,7 +192,7 @@ int main(int argc, char** argv) { for (int i = 0; i < D; i++) { L[i] = lx; } - } else if (argc == D + NARG-1) { + } else if (argc == D + NARG - 1) { for (int i = 0; i < D; i++) { L[i] = atoi(argv[1 + i]); } diff --git a/src/dla/generators/matrix.h b/src/dla/generators/matrix.h index e0e2da06..4e3fd960 100644 --- a/src/dla/generators/matrix.h +++ b/src/dla/generators/matrix.h @@ -4,6 +4,7 @@ //============================================================================ #include + #include #include #include @@ -47,10 +48,10 @@ void dgemm_(const char* transa, const char* transb, const DSQSS_INT* M, //============================================================================ class dgematrix { -private: + private: vector index; -public: + public: int n, m; //////////////// @@ -234,10 +235,10 @@ dgematrix operator*(const dgematrix& dA, const dgematrix& dB) { // class dsymatrix { -private: + private: double* index; -public: + public: int n; inline double& operator()(const int& i, const int& j) { @@ -250,7 +251,7 @@ class dsymatrix { DSQSS_INT dsyev(vector&); dsymatrix(int N) { - n = N; + n = N; index = new double[N * N]; }; @@ -262,11 +263,11 @@ class dsymatrix { DSQSS_INT dsymatrix::dsyev(vector& E) { //////////////////// DSQSS_INT info; - char jobz = 'V'; - char uplo = 'I'; + char jobz = 'V'; + char uplo = 'I'; DSQSS_INT w_size = -1; - DSQSS_INT size = n; - DSQSS_INT size2 = size * size; + DSQSS_INT size = n; + DSQSS_INT size2 = size * size; double* work; work = new double[size * 20]; double* vr; @@ -276,15 +277,12 @@ DSQSS_INT dsymatrix::dsyev(vector& E) { // wr //eigen value // vr //eigen vector - for (int i = 0; i < (int)size2; i++) - vr[i] = index[i]; + for (int i = 0; i < (int)size2; i++) vr[i] = index[i]; dsyev_(&jobz, &uplo, &size, vr, &size, wr, work, &w_size, &info); - for (int i = 0; i < (int)size; i++) - E[i] = wr[i]; - for (int i = 0; i < (int)size2; i++) - index[i] = vr[i]; + for (int i = 0; i < (int)size; i++) E[i] = wr[i]; + for (int i = 0; i < (int)size2; i++) index[i] = vr[i]; /////////////// delete[] work; @@ -406,7 +404,7 @@ dgematrix operator^(const dgematrix& A, const dgematrix& B) { for (int j0 = 0; j0 < A.n; j0++) { for (int j1 = 0; j1 < B.n; j1++) { - int j = j0 + A.n * j1; + int j = j0 + A.n * j1; C(i, j) = A(i0, j0) * B(i1, j1); } } @@ -420,7 +418,7 @@ dgematrix operator^(const dgematrix& A, const dgematrix& B) { //============================================================================ class cmatrix { -public: + public: long m; long n; @@ -470,8 +468,8 @@ class cmatrix { }; cmatrix& operator=(const cmatrix& A) { - m = A.m; - n = A.n; + m = A.m; + n = A.n; re = A.re; im = A.im; return *this; diff --git a/src/dla/generators/sfgene.cc b/src/dla/generators/sfgene.cc index 0824a077..9657925f 100644 --- a/src/dla/generators/sfgene.cc +++ b/src/dla/generators/sfgene.cc @@ -8,19 +8,19 @@ #include #include #include -#include #include -#include #include -#include +#include #include +#include +#include #include "../util.hpp" using namespace std; -std::vector index2coord(int i, std::vector L){ - if(i < 0){ +std::vector index2coord(int i, std::vector L) { + if (i < 0) { std::stringstream ss; ss << "invalid index i="; ss << i; @@ -29,12 +29,12 @@ std::vector index2coord(int i, std::vector L){ const int D = L.size(); int N = 1; std::vector r(D); - for(int d=0; d= N){ + if (i >= N) { std::stringstream ss; ss << "ERROR: invalid index i="; ss << i; @@ -45,25 +45,30 @@ std::vector index2coord(int i, std::vector L){ void ShowUsage(std::string const& exename) { cout << "usage:\n"; - cout << " " << exename << " [-o filename] D L_1 ... L_D Ntau Ntau_cutoff KTYPE\n"; + cout << " " << exename + << " [-o filename] D L_1 ... L_D Ntau Ntau_cutoff KTYPE\n"; cout << "arguments:\n"; cout << " D ... dimension of lattice\n"; cout << " L_d ... the liner size of the lattice\n"; cout << " (must be even)\n"; cout << " Ntau ... number of discretized imaginary time\n"; - cout << " Ntau_cutoff ... maximum distance in imaginary time between two spacetime points\n"; + cout << " Ntau_cutoff ... maximum distance in imaginary time between " + "two spacetime points\n"; cout << " KTYPE ... type of wavenumbers\n"; cout << " 0: kx=pi n/L, n=0, 2, ..., L" << endl; - cout << " 1: k/pi = (0,0), (1,0), (0,1), (1,1) [example in D=2 case]" << endl; + cout << " 1: k/pi = (0,0), (1,0), (0,1), (1,1) [example " + "in D=2 case]" + << endl; cout << "options:\n"; cout << " -o filename ... output file (default: sf.xml)"; } -void WriteXML(std::vector const& L, int Ntau, int CutoffOfNtau, int KTYPE, std::string const& filename) { +void WriteXML(std::vector const& L, int Ntau, int CutoffOfNtau, int KTYPE, + std::string const& filename) { const int D = L.size(); ofstream fout(filename.c_str()); fout.precision(15); - int N = 1; //number of sites. + int N = 1; // number of sites. for (int i = 0; i < D; i++) { N *= L[i]; } @@ -71,11 +76,11 @@ void WriteXML(std::vector const& L, int Ntau, int CutoffOfNtau, int KTYPE, std::vector Q(D, 2); - if (KTYPE == 0){ + if (KTYPE == 0) { KMAX = L[0] / 2 + 1; - } else if (KTYPE == 1){ + } else if (KTYPE == 1) { KMAX = 1; - for(int d=0; d const& L, int Ntau, int CutoffOfNtau, int KTYPE, << endl << endl; - int NB = 0; //3 * N ; // number of bonds + int NB = 0; // 3 * N ; // number of bonds for (int i = 0; i < N; i++) { std::vector r = index2coord(i, L); for (int q = 0; q < KMAX; q++) { - double phase=0; - if (KTYPE == 0){ + double phase = 0; + if (KTYPE == 0) { phase = (r[0] * 2 * q * M_PI) / L[0]; // r_x * q_x } else if (KTYPE == 1) { - std::vector k = index2coord(q,Q); - for(int d=0; d k = index2coord(q, Q); + for (int d = 0; d < D; ++d) { phase += r[d] * k[d]; } phase *= M_PI; @@ -135,11 +140,11 @@ void WriteXML(std::vector const& L, int Ntau, int CutoffOfNtau, int KTYPE, int main(int argc, char** argv) { std::string exename(argv[0]); std::string filename("sf.xml"); - if(argc < 3){ + if (argc < 3) { ShowUsage(exename); exit(0); } - if(std::strcmp(argv[1], "-o")==0){ + if (std::strcmp(argv[1], "-o") == 0) { filename = argv[2]; argc -= 2; argv += 2; @@ -149,7 +154,7 @@ int main(int argc, char** argv) { ShowUsage(exename); exit(0); } - int iarg = 1; + int iarg = 1; const int D = atoi(argv[iarg]); iarg++; if (argc != D + 5) { @@ -175,11 +180,13 @@ int main(int argc, char** argv) { cout.precision(15); cout << "D = " << D << endl; for (int i = 0; i < D; i++) { - cout << "L_" << i+1 << " = " << L[i] << endl; + cout << "L_" << i + 1 << " = " << L[i] << endl; EvenOrOdd += L[i] % 2; } - if (EvenOrOdd) { cout << "Warnig: L should be an even number." << endl; } + if (EvenOrOdd) { + cout << "Warnig: L should be an even number." << endl; + } WriteXML(L, Ntau, Ntcut, KTYPE, filename); cout << "... done." << endl; diff --git a/src/dla/generators/spin_H.h b/src/dla/generators/spin_H.h index cfe64d03..38dbb18e 100644 --- a/src/dla/generators/spin_H.h +++ b/src/dla/generators/spin_H.h @@ -4,7 +4,7 @@ //============================================================================ class HeisenbergSpin { -public: + public: int K; int D; cmatrix I; @@ -40,8 +40,8 @@ HeisenbergSpin::HeisenbergSpin(int K0) { DN = t(UP); // X = 0.5 * (UP + DN); cmatrix temp = UP + DN; - X = 0.5 * temp; - Y = ((-0.5) * IUNIT) * (UP - DN); + X = 0.5 * temp; + Y = ((-0.5) * IUNIT) * (UP - DN); for (int i = 0; i < D; i++) { I.re(i, i) = 1.0; Z.re(i, i) = -0.5 * (double)K + (double)i; @@ -51,7 +51,7 @@ HeisenbergSpin::HeisenbergSpin(int K0) { //---------------------------------------------------------------------------- class HeisenbergSpinSet { -public: + public: int DS; // the dimension of the 1-spin Hilbert space int N; // "N" in SU(N) int K; // the number of bosons on each site @@ -66,15 +66,15 @@ class HeisenbergSpinSet { HeisenbergSpinSet(int K0, int NSITE0) { printf("SpinSet> start.\n"); - K = K0; + K = K0; NSITE = NSITE0; HeisenbergSpin S(K); DS = S.D; - X = new cmatrix[NSITE]; - Y = new cmatrix[NSITE]; - Z = new cmatrix[NSITE]; + X = new cmatrix[NSITE]; + Y = new cmatrix[NSITE]; + Z = new cmatrix[NSITE]; printf(" definig spins ...\n"); DIM = 1; diff --git a/src/dla/io.h b/src/dla/io.h index 3a014260..c11c74d1 100644 --- a/src/dla/io.h +++ b/src/dla/io.h @@ -4,20 +4,19 @@ //###################################################################### +#include #include #include -#include #include #include #include #include #include +#include -#include - -#include "util.hpp" -#include "array.h" #include "../common/tostring.h" +#include "array.h" +#include "util.hpp" #define BLEN 256 @@ -28,7 +27,7 @@ std::string EOL = "_E_O_L_"; //====================================================================== inline void reform_end_of_line(std::string& line) { - int n = line.size(); + int n = line.size(); const char* a = line.c_str(); if (a[n - 1] == 13) { // 13 stands for ^M line.replace(n - 1, 1, 1, '\n'); @@ -82,20 +81,19 @@ inline void get_nbl(FILE* F, char* line) { // get the next non-blank line inline int break_into_words(char* line, char* delim, char** word) { char* last = line + strlen(line) - 1; - //printf( "line = '%s'\n", line); - //printf( "delimiter = '%s'\n", delim); + // printf( "line = '%s'\n", line); + // printf( "delimiter = '%s'\n", delim); char* w = line; - int n = 0; + int n = 0; while (w != last) { - while (w == strpbrk(w, delim)) - w++; + while (w == strpbrk(w, delim)) w++; char* p = strpbrk(w, delim); if (p == 0) p = last; - //printf("\nw= %s", w); - //printf("p= %d, (*p) = '%c' (%d)\n", p, *p, *p); + // printf("\nw= %s", w); + // printf("p= %d, (*p) = '%c' (%d)\n", p, *p, *p); strncpy(word[n], w, p - w); strcat(word[n], "\0"); - //printf("word[%d] = '%s'\n", n, word[n]); + // printf("word[%d] = '%s'\n", n, word[n]); n++; w = p; } @@ -105,7 +103,7 @@ inline int break_into_words(char* line, char* delim, char** word) { //###################################################################### class FileReader { -private: + private: char NAME[BLEN]; char LINE[BLEN]; int IL; @@ -115,7 +113,7 @@ class FileReader { std::streampos top; std::streampos mark; -public: + public: void open(const char* name) { strcpy(NAME, name); INS.open(NAME); @@ -146,7 +144,9 @@ class FileReader { bool read() { bool b = static_cast(INS.getline(LINE, BLEN)); - if (b) { IL++; } + if (b) { + IL++; + } return b; }; @@ -194,9 +194,8 @@ inline void FileReader::getWordList(int& NW, std::string*& W) { NW = 0; rewind(); - while (read()) - NW += split(); - W = new std::string[NW + 1]; + while (read()) NW += split(); + W = new std::string[NW + 1]; int iw = 0; rewind(); while (read()) { @@ -264,7 +263,7 @@ inline int FileReader::makeIndex(const char* scope, const char* field, set_mark(); bool active = false; while (read()) { - //show(); + // show(); int nw = split(); if (nw == 0) continue; std::string k = word(0); @@ -272,7 +271,7 @@ inline int FileReader::makeIndex(const char* scope, const char* field, if (k == inactivate) active = false; if (active) { if (k == key) { - //printf(" %s:%s:%s> %s\n", scope, field, k0, LINE); + // printf(" %s:%s:%s> %s\n", scope, field, k0, LINE); n++; } } diff --git a/src/dla/lattice.hpp b/src/dla/lattice.hpp index 2d8b9ec7..1e7ab0d2 100644 --- a/src/dla/lattice.hpp +++ b/src/dla/lattice.hpp @@ -19,11 +19,12 @@ //###################################################################### +#include #include #include #include #include -#include + #include "debug.hpp" #include "io.h" #include "objects.hpp" @@ -32,13 +33,13 @@ //###################################################################### class Lattice { -public: + public: class Edge { - public: + public: void init(int _d, int _a, int _b) { bd = _d; - A = _a; - B = _b; + A = _a; + B = _b; }; int A; @@ -46,7 +47,7 @@ class Lattice { int bd; }; -private: + private: Site* site; // the list of the poiters to sites Interaction* interaction; // the list of the pointers to interactions Edge* edge; // the list of the poiters to sites @@ -54,7 +55,7 @@ class Lattice { XML::Block X; Algorithm& ALG; -public: + public: int D; // dimension int BD; // bond dimension int* L; // linear size @@ -113,7 +114,7 @@ inline Lattice::Lattice(Parameter const& P, Algorithm& A) : ALG(A) { X.initialize(P.LATFILE, "LATTICE"); read(); - if(boost::math::isfinite(P.BETA)){ + if (boost::math::isfinite(P.BETA)) { setBeta(P.BETA); } @@ -132,19 +133,19 @@ void Lattice::read() { } BETA = 1.0; - NSITE = X["NumberOfSites"].getInteger(); - NINT = X["NumberOfInteractions"].getInteger(); + NSITE = X["NumberOfSites"].getInteger(); + NINT = X["NumberOfInteractions"].getInteger(); NSTYPE = X["NumberOfSiteTypes"].getInteger(); NITYPE = X["NumberOfInteractionTypes"].getInteger(); - site = new Site[NSITE]; + site = new Site[NSITE]; interaction = new Interaction[NINT]; bool INIT_I = true; bool INIT_V = true; - BD = -1; - edge = NULL; - vec = NULL; + BD = -1; + edge = NULL; + vec = NULL; for (int i = 0; i < X.NumberOfBlocks(); i++) { XML::Block& B = X[i]; @@ -169,12 +170,12 @@ void Lattice::read() { if (B.NumberOfValues() > 3 + nb) { if (INIT_I) { - NEDGE = X["NumberOfEdgeInteractions"].getInteger(); - edge = new Edge[NEDGE]; + NEDGE = X["NumberOfEdgeInteractions"].getInteger(); + edge = new Edge[NEDGE]; INIT_I = false; } - int eid = B.getInteger(3 + nb); + int eid = B.getInteger(3 + nb); int edim = B.getInteger(4 + nb); if (eid >= 0 && nb == 2) { EDGE(eid).init(edim, I(id).site(0).id() - 1, I(id).site(1).id() - 1); @@ -184,7 +185,7 @@ void Lattice::read() { } if (B.getName() == "Direction") { if (INIT_V) { - BD = X["NumberOfBondDirections"].getInteger(); + BD = X["NumberOfBondDirections"].getInteger(); vec = new double*[D]; for (int di = 0; di < D; di++) { vec[di] = new double[BD]; @@ -196,7 +197,7 @@ void Lattice::read() { int bd = B.getInteger(0); for (int di = 0; di < D; di++) { double length = B.getDouble(1 + di); - vec[di][bd] = length; + vec[di][bd] = length; } } } @@ -209,7 +210,7 @@ void Lattice::read() { void Lattice::initialize() { AutoDebugDump("Lattice::initialize"); - //set InteractionOnEachSite[NSITE]; + // set InteractionOnEachSite[NSITE]; std::set* InteractionOnEachSite; InteractionOnEachSite = new std::set[NSITE]; @@ -224,7 +225,7 @@ void Lattice::initialize() { for (int sid = 0; sid < NSITE; sid++) { S(sid).setNCI(InteractionOnEachSite[sid].size()); - int counter = 0; + int counter = 0; std::set::iterator it = InteractionOnEachSite[sid].begin(); while (it != InteractionOnEachSite[sid].end()) { @@ -243,11 +244,19 @@ void Lattice::initialize() { inline Lattice::~Lattice() { // printf("*** Destroying Lattice\n"); - if (L != 0) { delete[] L; } - if (site != 0) { delete[] site; } - if (interaction != 0) { delete[] interaction; } + if (L != 0) { + delete[] L; + } + if (site != 0) { + delete[] site; + } + if (interaction != 0) { + delete[] interaction; + } - if (edge != NULL) { delete[] edge; } + if (edge != NULL) { + delete[] edge; + } if (vec != NULL) { for (int i = 0; i < D; i++) { delete[] vec[i]; @@ -291,14 +300,14 @@ inline void Lattice::dump() { } void Lattice::setBeta(double beta) { - if(beta < 0.0){ + if (beta < 0.0) { std::string msg("ERROR: invalid BETA, "); msg += tostring(beta); util::ERROR(msg.c_str()); } BETA = beta; - for(int i=0;i class Linked : public C { -private: + private: Linked* p; Linked* n; -public: + public: void init() { C::init(); p = this; @@ -68,8 +68,8 @@ class Linked : public C { template class RingIterator { -private: -public: + private: + public: C* org; C* cur; @@ -146,9 +146,9 @@ template class Ring { friend class RingIterator; -private: + private: // C ROOT; -public: + public: C ROOT; C& head() { return ROOT.next(); }; C& tail() { return ROOT.prev(); }; @@ -195,8 +195,7 @@ class Ring { RingIterator p(*this); printf("Root: "); printf(" %p -> %p -> %p\n", &(p->prev()), &(*p), &(p->next())); - while (!(++p).atOrigin()) - p->dump(); + while (!(++p).atOrigin()) p->dump(); } }; @@ -204,12 +203,12 @@ class Ring { template class Pool : public Ring { -private: + private: int size_max; int size_min; int size; -public: + public: Pool() : Ring() { size = 0; }; ~Pool(); @@ -262,7 +261,7 @@ inline void Linked::insert_before(Linked& x) { template inline void Linked::remove() { - //if (ALERT) { + // if (ALERT) { // printf("\nLinked::remove> BEFORE\n"); // printf("Linked::remove> *this:\n"); // this->dump(); @@ -273,7 +272,7 @@ inline void Linked::remove() { //} prev().set_next(next()); next().set_prev(prev()); - //if (ALERT) { + // if (ALERT) { // printf("\nLinked::remove> AFTER\n"); // printf("Linked::remove> *this:\n"); // this->dump(); @@ -296,8 +295,7 @@ template inline int Ring::count() { int c = 0; RingIterator p(*this); - while (!(++p).atOrigin()) - c++; + while (!(++p).atOrigin()) c++; return c; } @@ -335,7 +333,7 @@ void Ring::move_to_head(RingIterator it) { template inline void Pool::init(int N) { // +++ edit sakakura +++ - //if ( ! Ring::empty() ) { + // if ( ! Ring::empty() ) { // printf("Pool: ERROR. Attempt to initialize the pool twice.\n"); // exit(0); //} @@ -345,7 +343,7 @@ inline void Pool::init(int N) { C& x = *(new C); this->add_tail(x); } - size = N; + size = N; size_max = N; size_min = N; } diff --git a/src/dla/measure.hpp b/src/dla/measure.hpp index 5734bd4a..25745b36 100644 --- a/src/dla/measure.hpp +++ b/src/dla/measure.hpp @@ -19,33 +19,40 @@ #include #include -#include "name.h" + #include "accumulator.hpp" -#include "parameter.hpp" -#include "measure_specific.h" #include "algorithm.hpp" #include "lattice.hpp" -#include "wavevector.hpp" +#include "measure_specific.h" +#include "name.h" +#include "parameter.hpp" #include "serialize.hpp" +#include "wavevector.hpp" -struct ACC_smag{ +struct ACC_smag { Accumulator A1; Accumulator A2; Accumulator B1; Accumulator B2; - void reset(){ - A1.reset(); A2.reset(); B1.reset(); B2.reset(); + void reset() { + A1.reset(); + A2.reset(); + B1.reset(); + B2.reset(); } - void average(){ - A1.average(); A2.average(); B1.average(); B2.average(); + void average() { + A1.average(); + A2.average(); + B1.average(); + B2.average(); } }; -namespace Serialize{ +namespace Serialize { template <> -void save(std::ofstream & ofs, const ACC_smag& val){ +void save(std::ofstream& ofs, const ACC_smag& val) { save(ofs, val.A1); save(ofs, val.A2); save(ofs, val.B1); @@ -53,48 +60,61 @@ void save(std::ofstream & ofs, const ACC_smag& val){ } template <> -void load(std::ifstream & ofs, ACC_smag& val){ +void load(std::ifstream& ofs, ACC_smag& val) { load(ofs, val.A1); load(ofs, val.A2); load(ofs, val.B1); load(ofs, val.B2); } -} +} // namespace Serialize -struct PHY_smag{ +struct PHY_smag { Accumulator A; Accumulator B; Accumulator S; Accumulator X; - void reset(int k) - { - std::string names[4] = {"amzs", "bmzs", "smzs", "xmzs",}; + void reset(int k) { + std::string names[4] = { + "amzs", + "bmzs", + "smzs", + "xmzs", + }; Accumulator* Q[4] = {&A, &B, &S, &X}; - for(int i=0; i<4; ++i){ + for (int i = 0; i < 4; ++i) { std::stringstream ss; ss << names[i]; ss << k; Q[i]->reset(ss.str()); } } - void average(){ - A.average(); B.average(); S.average(); X.average(); + void average() { + A.average(); + B.average(); + S.average(); + X.average(); } - void show(FILE* F, const char* prefix){ - A.show(F,prefix); B.show(F,prefix); S.show(F,prefix); X.show(F,prefix); + void show(FILE* F, const char* prefix) { + A.show(F, prefix); + B.show(F, prefix); + S.show(F, prefix); + X.show(F, prefix); } #ifdef MULTI - void allreduce(MPI_Comm comm){ - A.allreduce(comm); B.allreduce(comm); S.allreduce(comm); X.allreduce(comm); + void allreduce(MPI_Comm comm) { + A.allreduce(comm); + B.allreduce(comm); + S.allreduce(comm); + X.allreduce(comm); } #endif }; -namespace Serialize{ +namespace Serialize { template <> -void save(std::ofstream & ofs, const PHY_smag& val){ +void save(std::ofstream& ofs, const PHY_smag& val) { save(ofs, val.A); save(ofs, val.B); save(ofs, val.S); @@ -102,17 +122,16 @@ void save(std::ofstream & ofs, const PHY_smag& val){ } template <> -void load(std::ifstream & ofs, PHY_smag& val){ +void load(std::ifstream& ofs, PHY_smag& val) { load(ofs, val.A); load(ofs, val.B); load(ofs, val.S); load(ofs, val.X); } -} - +} // namespace Serialize class Measurement { -private: + private: int NACC; int NPHY; Parameter& P; @@ -121,12 +140,12 @@ class Measurement { WaveVector& WV; std::vector Q; -public: - std::vector ACC; // accumurator of snapshot values - std::vector PHY; // accumurator of set averages + public: + std::vector ACC; // accumurator of snapshot values + std::vector PHY; // accumurator of set averages - std::vector ACC_SMAG; // accumurator of snapshot of stagmag - std::vector PHY_SMAG; // accumurator of stagmag + std::vector ACC_SMAG; // accumurator of snapshot of stagmag + std::vector PHY_SMAG; // accumurator of stagmag double ediag; int nkink; @@ -152,7 +171,8 @@ class Measurement { void load(std::ifstream& F); }; -inline Measurement::Measurement(Parameter& P0, Lattice& L, Algorithm& A, WaveVector& W) +inline Measurement::Measurement(Parameter& P0, Lattice& L, Algorithm& A, + WaveVector& W) : NACC(Specific::NACC), NPHY(Specific::NPHY), P(P0), @@ -163,8 +183,7 @@ inline Measurement::Measurement(Parameter& P0, Lattice& L, Algorithm& A, WaveVec ACC(NACC), PHY(NPHY), ACC_SMAG(WV.NK), - PHY_SMAG(WV.NK) -{ + PHY_SMAG(WV.NK) { AutoDebugDump("Measurement::Measurement"); for (int i = 0; i < NACC; i++) { @@ -177,7 +196,7 @@ inline Measurement::Measurement(Parameter& P0, Lattice& L, Algorithm& A, WaveVec PHY[i].set_key(Specific::PNAME[i]); } - for (int k=0; k < WV.NK; ++k){ + for (int k = 0; k < WV.NK; ++k) { ACC_SMAG[k].reset(); PHY_SMAG[k].reset(k); } @@ -187,16 +206,16 @@ inline Measurement::Measurement(Parameter& P0, Lattice& L, Algorithm& A, WaveVec EBASE = 0.0; for (int i = 0; i < LAT.NINT; i++) { InteractionProperty& IP = LAT.I(i).property(); - double eb = IP.EBASE; + double eb = IP.EBASE; EBASE += eb; } } inline void Measurement::setinit() { - for (int i = 0; i < NACC; i++){ + for (int i = 0; i < NACC; i++) { ACC[i].reset(); } - for (int k=0; k < WV.NK; ++k){ + for (int k = 0; k < WV.NK; ++k) { ACC_SMAG[k].reset(); } } @@ -205,17 +224,17 @@ inline void Measurement::summary() { for (int i = 0; i < NPHY; i++) { PHY[i].average(); } - for (int k=0; k < WV.NK; ++k){ + for (int k = 0; k < WV.NK; ++k) { PHY_SMAG[k].average(); } } #ifdef MULTI -inline void Measurement::allreduce(MPI_Comm comm){ - for (int i=0; i MZSA(WV.NK); // staggered, tau=0 std::vector MZSB(WV.NK); // staggered, integrated - const double T = 1.0 / LAT.BETA; + const double T = 1.0 / LAT.BETA; const double invV = 1.0 / LAT.NSITE; for (int s = 0; s < LAT.NSITE; s++) { - Site& SITE = LAT.S(s); + Site& SITE = LAT.S(s); SiteProperty& SP = SITE.Property(); Segment& S0 = SITE.first(); - double mz0 = SP.XVALS[S0.X()]; + double mz0 = SP.XVALS[S0.X()]; Site::iterator p(SITE); double mza0 = 0.0; - std::vector const &ph = WV.COSrk[s]; + std::vector const& ph = WV.COSrk[s]; while (!(++p).atOrigin()) { Segment& S = *p; - double mz = SP.XVALS[S.X()]; + double mz = SP.XVALS[S.X()]; mza0 += mz * S.length(); } MZUA += mz0; MZUB += mza0; - for(int k=0; k tau(NBODY); std::vector x(NBODY); @@ -333,7 +354,7 @@ void Measurement::measure(double sgn) { p[i].init(S); ++p[i]; tau[i] = p[i]->topTime(); - x[i] = p[i]->X(); + x[i] = p[i]->X(); } double t = 0.0; @@ -346,20 +367,20 @@ void Measurement::measure(double sgn) { t = tau[it]; ++p[it]; tau[it] = p[it]->topTime(); - x[it] = p[it]->X(); + x[it] = p[it]->X(); } } ACC[SGN].accumulate(sgn); - ACC[NV1].accumulate(sgn*NV); + ACC[NV1].accumulate(sgn * NV); ACC[MZUA1].accumulate(sgn * MZUA); ACC[MZUA2].accumulate(sgn * MZUA * MZUA); ACC[MZUB1].accumulate(sgn * MZUB); ACC[MZUB2].accumulate(sgn * MZUB * MZUB); - for(int k=0; k X(NACC); @@ -423,18 +445,18 @@ void Measurement::setsummary() { X[i] = ACC[i].mean(); } - double B = LAT.BETA; - double T = 1.0 / B; - double V = LAT.NSITE; + double B = LAT.BETA; + double T = 1.0 / B; + double V = LAT.NSITE; double invV = 1.0 / V; - double D = LAT.D; + double D = LAT.D; const double sgn = X[SGN]; - if (sgn != 0.0){ + if (sgn != 0.0) { const double invsign = 1.0 / sgn; - for(int i=0; i. #if 0 -#if defined(MEASURE_BOSON) && !defined(MEASURE_SPIN) && !defined(MEASURE_USER_SPECIFIC) +#if defined(MEASURE_BOSON) && !defined(MEASURE_SPIN) && \ + !defined(MEASURE_USER_SPECIFIC) #include "SPECIFIC/Boson/measure_specific.cc" -#elif !defined(MEASURE_BOSON) && defined(MEASURE_SPIN) && !defined(MEASURE_USER_SPECIFIC) +#elif !defined(MEASURE_BOSON) && defined(MEASURE_SPIN) && \ + !defined(MEASURE_USER_SPECIFIC) #include "SPECIFIC/Heisenberg/measure_specific.cc" -#elif !defined(MEASURE_BOSON) && !defined(MEASURE_SPIN) && defined(MEASURE_USER_SPECIFIC) +#elif !defined(MEASURE_BOSON) && !defined(MEASURE_SPIN) && \ + defined(MEASURE_USER_SPECIFIC) #include "SPECIFIC/User/measure_specific.cc" #else #error You should define ONE of the following tokens: MEASURE_BOSON, MEASURE_SPIN, or MEASURE_USER_SPECIFIC. @@ -38,26 +41,26 @@ void Measurement::measure(double sgn) { double MZSA = 0.0; // staggered, tau=0 double MZSB = 0.0; // staggered, integrated - const double T = 1.0 / LAT.BETA; + const double T = 1.0 / LAT.BETA; const double invV = 1.0 / LAT.NSITE; std::vector phase(LAT.NSMTYPE); - for(int m=0; m tau(NBODY); std::vector x(NBODY); @@ -89,7 +92,7 @@ void Measurement::measure(double sgn) { p[i].init(S); ++p[i]; tau[i] = p[i]->topTime(); - x[i] = p[i]->X(); + x[i] = p[i]->X(); } double t = 0.0; @@ -102,13 +105,13 @@ void Measurement::measure(double sgn) { t = tau[it]; ++p[it]; tau[it] = p[it]->topTime(); - x[it] = p[it]->X(); + x[it] = p[it]->X(); } } ACC[SGN].accumulate(sgn); - ACC[NV1].accumulate(sgn*NV); + ACC[NV1].accumulate(sgn * NV); ACC[MZUA1].accumulate(sgn * MZUA); ACC[MZUA2].accumulate(sgn * MZUA * MZUA); @@ -131,14 +134,14 @@ void Measurement::measure(double sgn) { for (int xi = 0; xi < LAT.NEDGE; xi++) { int Asite = LAT.EDGE(xi).A; int Bsite = LAT.EDGE(xi).B; - int dim = LAT.EDGE(xi).bd; + int dim = LAT.EDGE(xi).bd; - Site& SITE = LAT.S(Asite); + Site& SITE = LAT.S(Asite); Segment& S0 = SITE.first(); Site::iterator p(SITE); int xlast = S0.X(); - //count winding + // count winding while (!(++p).atOrigin()) { Segment& S = *p; @@ -167,7 +170,8 @@ void Measurement::measure(double sgn) { void Measurement::setsummary() { using namespace Specific; - double WDIAG = ALG.getBlock("WDIAG", (double)1.0); //ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 + double WDIAG = ALG.getBlock( + "WDIAG", (double)1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 std::vector X(NACC); @@ -176,15 +180,15 @@ void Measurement::setsummary() { X[i] = ACC[i].mean(); } - double B = LAT.BETA; - double T = 1.0 / B; - double V = LAT.NSITE; + double B = LAT.BETA; + double T = 1.0 / B; + double V = LAT.NSITE; double invV = 1.0 / V; - double D = LAT.D; + double D = LAT.D; double invsign = 1.0 / X[SGN]; - for(int i=0; i. #if 0 -#if defined(MEASURE_BOSON) && !defined(MEASURE_SPIN) && !defined(MEASURE_USER_SPECIFIC) +#if defined(MEASURE_BOSON) && !defined(MEASURE_SPIN) && \ + !defined(MEASURE_USER_SPECIFIC) #include "SPECIFIC/Boson/measure_specific.h" -#elif !defined(MEASURE_BOSON) && defined(MEASURE_SPIN) && !defined(MEASURE_USER_SPECIFIC) +#elif !defined(MEASURE_BOSON) && defined(MEASURE_SPIN) && \ + !defined(MEASURE_USER_SPECIFIC) #include "SPECIFIC/Heisenberg/measure_specific.h" -#elif !defined(MEASURE_BOSON) && !defined(MEASURE_SPIN) && defined(MEASURE_USER_SPECIFIC) +#elif !defined(MEASURE_BOSON) && !defined(MEASURE_SPIN) && \ + defined(MEASURE_USER_SPECIFIC) #include "SPECIFIC/User/measure_specific.h" #else #error You should define ONE of the following tokens: MEASURE_BOSON, MEASURE_SPIN, or MEASURE_USER_SPECIFIC. @@ -51,17 +54,18 @@ enum { Wxy2, NACC, // number of quantities measured at each MC step }; -static std::string ANAME[NACC] = {"sgn", "nv1", "eb1", "eb2", "le1", "mzua1", "mzua2", "mzub1", "mzub2", - "nh1", "wxy2"}; +static std::string ANAME[NACC] = {"sgn", "nv1", "eb1", "eb2", + "le1", "mzua1", "mzua2", "mzub1", + "mzub2", "nh1", "wxy2"}; // observable specifier enum { - SIGN, // Sign of weight - ANV, // (site) Average of the Number of Vertices - ENE, // ENErgy per site - SPE, // SPEcific heat - SOM, // SOMmerfeld coeff - LEN, // LENgth of worm pair + SIGN, // Sign of weight + ANV, // (site) Average of the Number of Vertices + ENE, // ENErgy per site + SPE, // SPEcific heat + SOM, // SOMmerfeld coeff + LEN, // LENgth of worm pair XMX, // observables about Magnetization Z per site @@ -83,7 +87,8 @@ enum { NPHY, // number of quantities computed at each set }; -static std::string PNAME[NPHY] = {"sign", "anv", "ene", "spe", "som", "len", "xmx", "amzu", "bmzu", "smzu", "xmzu", - "ds1", "wi2", "rhos", "rhof", "comp"}; +static std::string PNAME[NPHY] = {"sign", "anv", "ene", "spe", "som", "len", + "xmx", "amzu", "bmzu", "smzu", "xmzu", "ds1", + "wi2", "rhos", "rhof", "comp"}; } // namespace Specific diff --git a/src/dla/name.h b/src/dla/name.h index facc01e0..a56a38bf 100644 --- a/src/dla/name.h +++ b/src/dla/name.h @@ -6,7 +6,7 @@ namespace STYPE { int UNDEF = -1; } namespace HTYPE { -int UNDEF = -1; +int UNDEF = -1; int ABSENT = -2; } // namespace HTYPE namespace TTYPE { @@ -32,15 +32,15 @@ int UNDEF = -1; } namespace UORD { int UNDEF = -1; -int UP = 0; -int DOWN = 1; +int UP = 0; +int DOWN = 1; } // namespace UORD namespace VCAT { int UNDEF = -1; -int TERM = 0; -int WORM = 1; -int INT = 2; +int TERM = 0; +int WORM = 1; +int INT = 2; } // namespace VCAT const double INF = 1.0e+14; diff --git a/src/dla/objects.hpp b/src/dla/objects.hpp index 464987ec..7edd7fea 100644 --- a/src/dla/objects.hpp +++ b/src/dla/objects.hpp @@ -4,6 +4,7 @@ //###################################################################### #include + #include "algorithm.hpp" #include "name.h" #include "xml.h" @@ -23,23 +24,23 @@ class RegisteredVertexInfo; //###################################################################### class BareSegment { -private: + private: static int lastID; int IDX; Vertex* _v[2]; int val; // the local state (0, 1, 2, ... , NX-1) Site* ONSITE; -public: + public: void init() { - val = 0; - _v[0] = 0; - _v[1] = 0; + val = 0; + _v[0] = 0; + _v[1] = 0; ONSITE = 0; }; void set(int x, Vertex& v0, Vertex& v1) { - val = x; + val = x; _v[0] = &v0; _v[1] = &v1; }; @@ -80,7 +81,7 @@ int BareSegment::lastID = 0; //###################################################################### class Segment : public Linked { -public: + public: Segment& cut(Vertex& V, int side); void erase(); void absorbNext(); @@ -92,7 +93,7 @@ class Segment : public Linked { //###################################################################### class BareVertex { -private: + private: static int lastID; int ID; VertexProperty* _VP; @@ -100,9 +101,9 @@ class BareVertex { Array _s; Interaction* ONINTERACTION; -public: + public: void init() { - _VP = 0; + _VP = 0; TIME = -1.0; _s.init(); }; @@ -111,7 +112,7 @@ class BareVertex { void init_TERM(Segment& S); - //Used when PlaceWorm + // Used when PlaceWorm void init(double t, VertexProperty& VP) { TIME = t; _s.init(1, VP.NLEG); // koko !!! @@ -123,13 +124,13 @@ class BareVertex { TIME = t; _s.init(1, VP.NLEG); // koko !!! _s.set_all(0); - _VP = &VP; + _VP = &VP; ONINTERACTION = O_I; }; BareVertex() { _s.setLabel("BareVertex::_s"); lastID++; - ID = lastID; + ID = lastID; ONINTERACTION = 0; init(); }; @@ -221,7 +222,7 @@ int BareVertex::lastID = 0; //###################################################################### class Vertex : public Linked { -public: + public: void reconnect(); // reconnect the segments attached to the vertex void erase(); // remove from the linked list and push back to the pool Vertex& prev() { return (Vertex&)Linked::prev(); }; @@ -232,13 +233,13 @@ class Vertex : public Linked { //###################################################################### class Worm { -private: + private: int x_behind; // the local state just after a passage of the worm head Vertex* _vorg; // the vertex sitting at the creation point Vertex* _vcur; // the current vertex Segment* _scur; // the current segment -public: + public: Worm(); ~Worm(); @@ -277,7 +278,7 @@ class Worm { bool getUORD() { return (_vcur == &((*_scur).top())); - }; //up -> false 0, down -> true 1 + }; // up -> false 0, down -> true 1 void getV() { printf("top,bottom = %d, %d ", (*_scur).top().id(), (*_scur).bottom().id()); }; @@ -290,7 +291,7 @@ class Worm { //###################################################################### class Site : public Ring { -private: + private: static int lastID; int ID; SiteProperty* _SP; @@ -298,19 +299,17 @@ class Site : public Ring { int NCI; // the number of connected interactions Interaction** - ConnectedInteraction; //Interaction* ConnectedInteraction [ NCI ]; -public: + ConnectedInteraction; // Interaction* ConnectedInteraction [ NCI ]; + public: void setNCI(int ni) { - NCI = ni; + NCI = ni; ConnectedInteraction = new Interaction*[ni]; } int getNCI() { return NCI; } void setCI(int nth, Interaction* CI) { ConnectedInteraction[nth] = CI; } Interaction** getCI() { return ConnectedInteraction; } - void init(SiteProperty& SP) { - _SP = &SP; - } + void init(SiteProperty& SP) { _SP = &SP; } Site(); @@ -342,7 +341,7 @@ class Site : public Ring { }; void idclear() { lastID = 0; }; - //void idclear() { cout << "dddd " << endl; }; + // void idclear() { cout << "dddd " << endl; }; Vertex& getVterm() { return (*_vterm); }; }; @@ -352,22 +351,24 @@ int Site::lastID = 0; //###################################################################### class Interaction : public Ring { -private: + private: static int lastID; int ID; InteractionProperty* _IP; Site** _s; -public: + public: void init() { _IP = 0; - if (_s != 0) { delete[] _s; } + if (_s != 0) { + delete[] _s; + } }; void init(InteractionProperty& IP) { init(); _IP = &IP; - _s = new Site*[(*_IP).NBODY]; + _s = new Site*[(*_IP).NBODY]; }; Interaction(); @@ -413,8 +414,7 @@ class Interaction : public Ring { if (_s[i] != 0) sid[i] = site(i).id(); } printf("Interaction(%2d) = (", id()); - for (int i = 0; i < NBODY(); i++) - printf(" %2d", sid[i]); + for (int i = 0; i < NBODY(); i++) printf(" %2d", sid[i]); printf(" ), type= %2d | ", type()); Ring::dump(); delete[] sid; @@ -459,15 +459,15 @@ inline void BareSegment::dump() { // printf("\nBareSegment::dump> Start.\n"); fprintf(FERR, " Segment [%3d] : ", id()); double bt = 0.0; - int bid = -1; + int bid = -1; if (_v[0] != 0) { - bt = bottomTime(); + bt = bottomTime(); bid = bottom().id(); } double tt = 0.0; - int tid = -1; + int tid = -1; if (_v[1] != 0) { - tt = topTime(); + tt = topTime(); tid = top().id(); } if (bt >= tt) bt = 0.0; @@ -491,10 +491,10 @@ inline Segment& Segment::cut(Vertex& V, int side) { // // after: -----[S0]------[S1]------> tau // - int x = X(); //int X() { return val; }; + int x = X(); // int X() { return val; }; - Vertex& V0 = bottom(); //Vertex& bottom() { return *_v[0]; }; Vertex* _v[2]; - Vertex& V1 = top(); // Vertex& top() { return *_v[1]; }; + Vertex& V0 = bottom(); // Vertex& bottom() { return *_v[0]; }; Vertex* _v[2]; + Vertex& V1 = top(); // Vertex& top() { return *_v[1]; }; Segment& S0 = *this; Segment& S1 = TheSegmentPool.pop(); insert_after(S1); @@ -509,7 +509,7 @@ inline Segment& Segment::cut(Vertex& V, int side) { // Since S1 is always below we need investigate only even V1 for (int l = 0; l < V1.NLEG(); l += 2) { if (V1.S(l) == S0) { - //printf(" gotcha!\n"); + // printf(" gotcha!\n"); V1.setS(l, S1); } } @@ -528,7 +528,7 @@ inline void Segment::erase() { inline void Segment::absorbNext() { Segment& S0 = *this; Segment& S1 = S0.next(); - Vertex& V1 = S1.top(); + Vertex& V1 = S1.top(); S0.setTop(V1); V1.replace(S1, S0); S1.erase(); @@ -551,8 +551,8 @@ inline void BareVertex::init_TERM( init(); _s.init(1, 2); _s.set_all(0); - _s[0] = &S; - _s[1] = &S; + _s[0] = &S; + _s[1] = &S; ONINTERACTION = &TerminalOfWorldline; } //====================================================================== @@ -617,10 +617,9 @@ inline VertexInitialConfiguration& BareVertex::getInitialConfiguration( VertexProperty& P = property(); // int NLEG = 2 * P.NBODY; int NDIM = P.NLEG + 2; - int* x = new int[NDIM]; //edit sakakura - // int x[NDIM]; - for (int i = 0; i < P.NLEG; i++) - x[i] = X(i); + int* x = new int[NDIM]; // edit sakakura + // int x[NDIM]; + for (int i = 0; i < P.NLEG; i++) x[i] = X(i); int st = P.StateCode(x); #ifdef DEB @@ -628,8 +627,7 @@ inline VertexInitialConfiguration& BareVertex::getInitialConfiguration( printf("BareVertex::getInitialConfiguration> Error.\n"); printf(" An forbidden state has been encountered.\n"); printf(" x= ("); - for (int i = 0; i < P.NLEG; i++) - printf(" %d", x[i]); + for (int i = 0; i < P.NLEG; i++) printf(" %d", x[i]); printf(") \n"); dump(); P.dump(); @@ -672,20 +670,19 @@ void BareVertex::dump() { //###################################################################### inline void Vertex::reconnect() { - for (int l = 0; l < size(); l += 2) - S(l).absorbNext(); + for (int l = 0; l < size(); l += 2) S(l).absorbNext(); } //====================================================================== inline void Vertex::erase() { reconnect(); - //if (ALERT) { + // if (ALERT) { // printf("\nVertex::erase> ### Erasing\n"); // dump(); //} Linked::remove(); - //if (ALERT) { + // if (ALERT) { // printf("\nVertex::erase> ### Done\n"); // dump(); //} @@ -696,7 +693,8 @@ inline void Vertex::erase() { inline Worm::Worm() { Vertex& V = TheVertexPool.pop(); - V.init_WORM(); // initialization is the same as TERM, since Worm is a two leg vertex + V.init_WORM(); // initialization is the same as TERM, since Worm is a two leg + // vertex _vorg = &V; _vcur = 0; _scur = 0; @@ -726,7 +724,7 @@ inline void Worm::dump() { fprintf(FERR, " _vorg (the worm tail) is not defined.\n"); } else { fprintf(FERR, " Tail:\n"); - _vorg->dump(); //barevertex.dump() + _vorg->dump(); // barevertex.dump() } if (_vcur == 0) { fprintf(FERR, " _vcur (the current vertex) is not defined.\n"); @@ -745,11 +743,11 @@ inline void Worm::dump() { //###################################################################### inline Site::Site() { - //printf("Site::Site> Start.\n"); + // printf("Site::Site> Start.\n"); lastID++; - ID = lastID; - _SP = 0; - Vertex& v = TheVertexPool.pop(); + ID = lastID; + _SP = 0; + Vertex& v = TheVertexPool.pop(); Segment& s = TheSegmentPool.pop(); v.BareVertex::init_TERM(s); s.set(0, v, v); @@ -779,7 +777,8 @@ inline Site::~Site() { inline Segment& Site::findS(double t) { iterator p(*this); - while ((++p)->topTime() < t) {} + while ((++p)->topTime() < t) { + } return *p; } @@ -788,9 +787,9 @@ inline Segment& Site::findS(double t) { inline Interaction::Interaction() { lastID++; - ID = lastID; + ID = lastID; _IP = 0; - _s = 0; + _s = 0; } //====================================================================== @@ -807,36 +806,36 @@ inline Interaction::~Interaction() { //##########################katou####################################### class UniformInterval { -public: + public: Interaction* I_n; VertexInitialConfiguration* VIC; // VertexProperty* VP; - //Segment* n_S[nbody] + // Segment* n_S[nbody] Segment** n_S; - //int x[nbody] + // int x[nbody] int* x; int inc; // int xinc; int nbody; - bool DefinedVIC; //Defined StateCode yes no + bool DefinedVIC; // Defined StateCode yes no void init(Interaction* Ia, int xbehind) { - I_n = Ia; + I_n = Ia; nbody = (*I_n).NBODY(); - VP = &((*I_n).property().getVertexProperty()); + VP = &((*I_n).property().getVertexProperty()); - n_S = new Segment*[nbody]; - x = new int[nbody]; - xinc = xbehind; + n_S = new Segment*[nbody]; + x = new int[nbody]; + xinc = xbehind; DefinedVIC = false; } void setVIC() { int st = (*VP).SCNK(x); if (st < 0) { - VIC = 0; + VIC = 0; DefinedVIC = false; } else { - VIC = &((*VP).getIC(st, inc, xinc)); + VIC = &((*VP).getIC(st, inc, xinc)); DefinedVIC = true; } } @@ -854,14 +853,14 @@ class UniformInterval { }; //###################################################################### class RegisteredVertexInfo { -public: + public: Vertex* V_x; int i_UI; int i_body; double V_time; void setRVI(Vertex* Vx, int iUI, int ibody, double Vtime) { - V_x = Vx; - i_UI = iUI; + V_x = Vx; + i_UI = iUI; i_body = ibody; V_time = Vtime; } @@ -880,7 +879,7 @@ inline bool operator>(const RegisteredVertexInfo& obj0, //###################################################################### class RegVInfo : public Linked { -public: + public: void erase(); RegVInfo& prev() { return (RegVInfo&)Linked::prev(); }; RegVInfo& next() { return (RegVInfo&)Linked::next(); }; diff --git a/src/dla/parameter.hpp b/src/dla/parameter.hpp index 67cd0862..a36fd785 100644 --- a/src/dla/parameter.hpp +++ b/src/dla/parameter.hpp @@ -1,30 +1,28 @@ #ifndef PARAMETER_H #define PARAMETER_H +#include +#include +#include +#include #include -#include +#include #include -#include +#include #include #include -#include -#include #include -#include - -#include -#include +#include +#include "../common/read_keyvalues.h" #include "debug.hpp" #include "util.hpp" -#include "../common/read_keyvalues.h" #define PNUM 22 class Parameter { -private: - -public: + private: + public: Parameter(int, char**); void dump(FILE*); void dump(); @@ -63,22 +61,30 @@ class Parameter { } } void closefile() { - if (FOUT) { fclose(FOUT); } - if (FOUT4CF) { fclose(FOUT4CF); } - if (FOUT4SF) { fclose(FOUT4SF); } - if (FOUT4CK) { fclose(FOUT4CK); } + if (FOUT) { + fclose(FOUT); + } + if (FOUT4CF) { + fclose(FOUT4CF); + } + if (FOUT4SF) { + fclose(FOUT4SF); + } + if (FOUT4CK) { + fclose(FOUT4CK); + } } - void readfile(std::string const &filename); + void readfile(std::string const& filename); - void init(std::map &dict); + void init(std::map& dict); double BETA; // inversed temperature int RUNTYPE; // runtype number int NSET; // number of sets - int NPRE; // number of sweeps for determining NCYC - int NTHERM; // number of sweeps for initial thermalization + int NPRE; // number of sweeps for determining NCYC + int NTHERM; // number of sweeps for initial thermalization int NDECOR; // number of sweeps for decorrelating two subsequent sets int NMCS; // number of sweeps for measurement in a set int SEED; // seed for the random number generator @@ -90,27 +96,27 @@ class Parameter { double SIMTIME; // time [sec] to save a snapshot and stop simulation // if <= 0, never stop until finish - std::string ALGFILE; // algorithm file name - std::string LATFILE; // lattice file name - std::string OUTFILE; // output file name - std::string WVFILE; // wavevector file name - std::string DISPFILE; // displacement file name - int NCYC; // number of cycles in a sweep (not provided from the file) + std::string ALGFILE; // algorithm file name + std::string LATFILE; // lattice file name + std::string OUTFILE; // output file name + std::string WVFILE; // wavevector file name + std::string DISPFILE; // displacement file name + int NCYC; // number of cycles in a sweep (not provided from the file) FILE* FOUT; // file handler for the output file std::string CFOUTFILE; // output file name - FILE* FOUT4CF; // file handler for the output file + FILE* FOUT4CF; // file handler for the output file std::string SFOUTFILE; // output file name - FILE* FOUT4SF; // file handler for the output file + FILE* FOUT4SF; // file handler for the output file std::string CKOUTFILE; // output file name - FILE* FOUT4CK; // file handler for the output file + FILE* FOUT4CK; // file handler for the output file }; void Parameter::readfile(std::string const& filename) { - using std::string; using boost::lexical_cast; + using std::string; double val; std::map dict; init(dict); @@ -121,16 +127,16 @@ void Parameter::readfile(std::string const& filename) { deprecated_parameter(dict, "ntherm", "nmcsd"); BETA = lexical_cast(dict["beta"]); - if(boost::math::isinf(BETA) || BETA <= 0.0){ + if (boost::math::isinf(BETA) || BETA <= 0.0) { util::ERROR("\"beta\" is not specified or invalid."); } NMCS = lexical_cast(dict["nmcs"]); NTHERM = lexical_cast(dict["ntherm"]); NPRE = lexical_cast(dict["npre"]); - if(dict.find("ndecor") != dict.end()){ + if (dict.find("ndecor") != dict.end()) { NDECOR = lexical_cast(dict["ndecor"]); - }else{ + } else { NDECOR = NTHERM; } NSET = lexical_cast(dict["nset"]); @@ -169,7 +175,8 @@ inline Parameter::Parameter(int NP, char** PLIST) { } #ifdef MULTI - if (RUNTYPE >= 3) { // runtype == 3 --> each processor must read its own parameter file + if (RUNTYPE >= + 3) { // runtype == 3 --> each processor must read its own parameter file char FILENAME[128]; sprintf(FILENAME, "%s.%03d", PLIST[1], I_PROC); printf("[%2d] input file name = %s\n", I_PROC, FILENAME); @@ -182,7 +189,7 @@ inline Parameter::Parameter(int NP, char** PLIST) { } #endif - if(I_PROC==0){ + if (I_PROC == 0) { dump(); } @@ -192,25 +199,25 @@ inline Parameter::Parameter(int NP, char** PLIST) { void Parameter::init(std::map& dict) { dict.clear(); - dict["beta"] = "inf"; - dict["nmcs"] = "1000"; - dict["nset"] = "10"; - dict["npre"] = "1000"; - dict["ntherm"] = "1000"; + dict["beta"] = "inf"; + dict["nmcs"] = "1000"; + dict["nset"] = "10"; + dict["npre"] = "1000"; + dict["ntherm"] = "1000"; dict["simulationtime"] = "0.0"; - dict["seed"] = "198212240"; - dict["nvermax"] = "10000"; - dict["nsegmax"] = "10000"; - dict["ntau"] = 10; - dict["algfile"] = "algorithm.xml"; - dict["latfile"] = "lattice.xml"; - dict["wvfile"] = "wavevector.xml"; - dict["dispfile"] = "displacement.xml"; - dict["outfile"] = "sample.log"; - dict["sfoutfile"] = "sf.dat"; - dict["cfoutfile"] = "cf.dat"; - dict["ckoutfile"] = "ck.dat"; - dict["runtype"] = "0"; + dict["seed"] = "198212240"; + dict["nvermax"] = "10000"; + dict["nsegmax"] = "10000"; + dict["ntau"] = 10; + dict["algfile"] = "algorithm.xml"; + dict["latfile"] = "lattice.xml"; + dict["wvfile"] = "wavevector.xml"; + dict["dispfile"] = "displacement.xml"; + dict["outfile"] = "sample.log"; + dict["sfoutfile"] = "sf.dat"; + dict["cfoutfile"] = "cf.dat"; + dict["ckoutfile"] = "ck.dat"; + dict["runtype"] = "0"; } inline void Parameter::dump() { diff --git a/src/dla/random.cc b/src/dla/random.cc index 65535b08..6b51af3e 100644 --- a/src/dla/random.cc +++ b/src/dla/random.cc @@ -19,6 +19,7 @@ */ #include "random.h" + #include #include double Random::Dicex(void) { return (double)rand() / RAND_MAX; } @@ -28,10 +29,8 @@ void Random::InitRand() { srand((unsigned)time(NULL)); } double Random::Uniform(void) { if (navr == 0) { Rint i; - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; iptr = 0; navr = IPP; } @@ -42,10 +41,8 @@ double Random::Uniform(void) { Rint Random::Int(Rint ilimit) { if (navr == 0) { Rint i; - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; iptr = 0; navr = IPP; } @@ -57,10 +54,8 @@ Rint Random::Int(Rint ilimit) { Rint Random::Int(void) { if (navr == 0) { Rint i; - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; iptr = 0; navr = IPP; } @@ -70,12 +65,11 @@ Rint Random::Int(void) { // Random Permutation void Random::Perm(Rint N, int *Index) { - for (Rint i = 0; i < N; i++) - Index[i] = i; + for (Rint i = 0; i < N; i++) Index[i] = i; for (Rint i = 0; i < N - 1; i++) { - Rint x = Index[i]; - Rint ix = i + Int(N - i); - Index[i] = Index[ix]; + Rint x = Index[i]; + Rint ix = i + Int(N - i); + Index[i] = Index[ix]; Index[ix] = x; } /* @@ -86,8 +80,8 @@ void Random::Perm(Rint N, int *Index) { while(ind < N) { n = (Rint) (Int()*rx); if (Index[n] == -1) { - Index[n] = ind; - ind++; + Index[n] = ind; + ind++; } } */ @@ -95,9 +89,9 @@ void Random::Perm(Rint N, int *Index) { void Random::Scramble(Rint N, int *Index) { for (Rint i = 0; (i + 1) < N; i++) { - Rint x = Index[i]; - Rint ix = i + Int(N - i); - Index[i] = Index[ix]; + Rint x = Index[i]; + Rint ix = i + Int(N - i); + Index[i] = Index[ix]; Index[ix] = x; } } @@ -120,10 +114,9 @@ void Random::initialize(Rint irand0, Rint nrbit0) { nrbit = nrbit0; imask = 1; - for (i = 0; i < nrbit - 1; i++) - imask = (imask << 1) + 1; + for (i = 0; i < nrbit - 1; i++) imask = (imask << 1) + 1; runit = 1e0 / (imask + 1e0); - ix = irand0; + ix = irand0; for (i = 0; i < IPP; i++) { ix = (ix * 1812433253 + 1) & 0xffffffff; if (ix & 0x80000000) @@ -143,7 +136,7 @@ void Random::initialize(Rint irand0, Rint nrbit0) { ib[j] = mj; } for (j = 0; j < IPP; j++) { - ih = ((j * 16) % IPP); + ih = ((j * 16) % IPP); iri[j] = imask & ib[ih]; for (i = 0; i < 16; i++) { ii = (ih + i) % IPP; @@ -165,11 +158,9 @@ void Random::setSeed(Rint *seed, Rint nrbit0) { Rint i; nrbit = nrbit0; imask = 1; - for (i = 0; i < nrbit - 1; i++) - imask = (imask << 1) + 1; + for (i = 0; i < nrbit - 1; i++) imask = (imask << 1) + 1; runit = 1e0 / (imask + 1e0); - for (i = 0; i < IPP; i++) - iri[i] = imask & seed[i]; + for (i = 0; i < IPP; i++) iri[i] = imask & seed[i]; navr = IPP; iptr = 0; return; @@ -195,21 +186,17 @@ void Random::Uniform(Rint nr, Rint *ir) { Rint i, nrec, n1, iptd; nrec = nr; - n1 = (navr > nrec ? nrec : navr); - for (i = 0; i < n1; i++) - ir[i] = iri[iptr + i]; + n1 = (navr > nrec ? nrec : navr); + for (i = 0; i < n1; i++) ir[i] = iri[iptr + i]; iptd = n1; iptr += n1; navr -= n1; nrec -= n1; while (nrec > 0) { - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; n1 = (IPP > nrec ? nrec : IPP); - for (i = 0; i < n1; i++) - ir[iptd + i] = iri[i]; + for (i = 0; i < n1; i++) ir[iptd + i] = iri[i]; iptd += n1; iptr = n1; navr = IPP - n1; @@ -233,21 +220,17 @@ void Random::Uniform(Rint nr, double *rx) { Rint i, nrec, n1, iptd; nrec = nr; - n1 = (navr > nrec ? nrec : navr); - for (i = 0; i < n1; i++) - rx[i] = runit * iri[iptr + i]; + n1 = (navr > nrec ? nrec : navr); + for (i = 0; i < n1; i++) rx[i] = runit * iri[iptr + i]; iptd = n1; iptr += n1; navr -= n1; nrec -= n1; while (nrec > 0) { - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; n1 = (IPP > nrec ? nrec : IPP); - for (i = 0; i < n1; i++) - rx[iptd + i] = runit * iri[i]; + for (i = 0; i < n1; i++) rx[iptd + i] = runit * iri[i]; iptd += n1; iptr = n1; navr = IPP - n1; @@ -273,22 +256,18 @@ void Random::Int(Rint nr, Rint *ir, Rint ilimit) { double runitx; runitx = runit * ilimit; - nrec = nr; - n1 = (navr > nrec ? nrec : navr); - for (i = 0; i < n1; i++) - ir[i] = (Rint)(runitx * iri[iptr + i]); + nrec = nr; + n1 = (navr > nrec ? nrec : navr); + for (i = 0; i < n1; i++) ir[i] = (Rint)(runitx * iri[iptr + i]); iptd = n1; iptr += n1; navr -= n1; nrec -= n1; while (nrec > 0) { - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; n1 = (IPP > nrec ? nrec : IPP); - for (i = 0; i < n1; i++) - ir[iptd + i] = (Rint)(runitx * iri[i]); + for (i = 0; i < n1; i++) ir[iptd + i] = (Rint)(runitx * iri[i]); iptd += n1; iptr = n1; navr = IPP - n1; diff --git a/src/dla/random.h b/src/dla/random.h index c9a85d12..f2d0a140 100644 --- a/src/dla/random.h +++ b/src/dla/random.h @@ -31,37 +31,37 @@ typedef unsigned int Rint; // using M series method // X(t) := X(t-32) xor X(t-521) class Random { -private: + private: Rint nrbit, iptr, navr; Rint iri[IPP]; double runit; -private: + private: void initialize(Rint irand0, Rint nrbit0); //: Initialization - //!param: irand0 - seed for 521 initial random numbers - //!param: nrbit0 - precision (number of bit) + //! param: irand0 - seed for 521 initial random numbers + //! param: nrbit0 - precision (number of bit) -public: + public: Random(Rint *seed, Rint nrbit0); //: Constructor - //!param: seed - 521 initial random numbers - //!param: nrbit0 - precision (number of bit) + //! param: seed - 521 initial random numbers + //! param: nrbit0 - precision (number of bit) Random(Rint irand0 = 20000101, Rint nrbit0 = 32); //: Constructor - //!param: irand0 - seed for 521 initial random numbers - //!param: nrbit0 - precision (number of bit) + //! param: irand0 - seed for 521 initial random numbers + //! param: nrbit0 - precision (number of bit) void setSeed(Rint irand0, Rint nrbit0 = 32); //: Reset - //!param: irand0 - seed for 521 initial random numbers - //!param: nrbit0 - precision (number of bit) + //! param: irand0 - seed for 521 initial random numbers + //! param: nrbit0 - precision (number of bit) void setSeed(Rint *seed, Rint nrbit0); //: Reset - //!param: seed - 521 initial random numbers - //!param: nrbit0 - precision (number of bit) + //! param: seed - 521 initial random numbers + //! param: nrbit0 - precision (number of bit) Rint getSeed(Rint *seed); //: Return seed and nrbit0 @@ -77,19 +77,19 @@ class Random { void Uniform(Rint nr, Rint *ir); //: Uniform integers - //!param: nr - the number of random numbers to be generated - //!param: ir - pointer to store outputs + //! param: nr - the number of random numbers to be generated + //! param: ir - pointer to store outputs void Uniform(Rint nr, double *rx); //: Uniform reals - //!param: nr - the number of random numbers to be generated - //!param: rx - pointer to store outputs + //! param: nr - the number of random numbers to be generated + //! param: rx - pointer to store outputs void Int(Rint nr, Rint *ir, Rint ilimit); //: Uniform integers - //!param: nr - the number of random numbers to be generated - //!param: ir - pointer to store outputs - //!param: ilimit - maximum + //! param: nr - the number of random numbers to be generated + //! param: ir - pointer to store outputs + //! param: ilimit - maximum double Gauss() { double theta; diff --git a/src/dla/serialize.hpp b/src/dla/serialize.hpp index 7e6fa21e..1c513e5e 100644 --- a/src/dla/serialize.hpp +++ b/src/dla/serialize.hpp @@ -17,46 +17,45 @@ #ifndef SERIALIZE_H #define SERIALIZE_H -#include -#include #include +#include #include +#include #include namespace Serialize { template -void save(std::ofstream & ofs, const T& val){ +void save(std::ofstream& ofs, const T& val) { ofs.write(reinterpret_cast(&val), sizeof(T)); } template -void load(std::ifstream & ifs, T& val){ +void load(std::ifstream& ifs, T& val) { ifs.read(reinterpret_cast(&val), sizeof(T)); } template -T load(std::ifstream & ifs){ +T load(std::ifstream& ifs) { T val; load(ifs, val); return val; } - template <> -void save(std::ofstream & ofs, const std::string& val){ +void save(std::ofstream& ofs, const std::string& val) { const size_t N = val.size(); save(ofs, N); - for(size_t i=0; i -void load(std::ifstream & ifs, std::string& val){ +void load(std::ifstream& ifs, std::string& val) { size_t N; load(ifs, N); std::stringstream ss; char c; - for(size_t i=0; i -void save(std::ofstream& ofs, const std::vector& val){ +void save(std::ofstream& ofs, const std::vector& val) { const size_t N = val.size(); save(ofs, N); - for(size_t i=0; i -void load(std::ifstream& ifs, std::vector& val){ +void load(std::ifstream& ifs, std::vector& val) { size_t N = 0; load(ifs, N); val.clear(); - for(size_t i=0; i #include #include #include -#include "debug.hpp" +#include + #include "accumulator.hpp" -#include "parameter.hpp" -#include "wavevector.hpp" #include "algorithm.hpp" +#include "debug.hpp" #include "lattice.hpp" +#include "parameter.hpp" +#include "wavevector.hpp" class SF { -private: + private: bool to_be_calc; Lattice& LAT; Algorithm& ALG; @@ -45,7 +46,7 @@ class SF { std::vector > counterC; std::vector > counterS; -public: + public: SF(Parameter const& param, Lattice& lat, Algorithm& alg, WaveVector& wv); void setinit(); void measure(double sgn); @@ -79,10 +80,9 @@ SF::SF(Parameter const& param, Lattice& lat, Algorithm& alg, WaveVector& wv) wv(wv), NK(wv.NK), Ntau(param.NTAU), - dtau(param.BETA/param.NTAU) -{ + dtau(param.BETA / param.NTAU) { AutoDebugDump("SF::SF"); - if (wv.defined){ + if (wv.defined) { to_be_calc = true; SIGN.reset(); for (int i = 0; i < NK; i++) { @@ -103,16 +103,19 @@ SF::SF(Parameter const& param, Lattice& lat, Algorithm& alg, WaveVector& wv) }; inline void SF::setinit() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("SF::setinit"); SIGN.reset(); for (int i = 0; i < NK; i++) - for (int itau = 0; itau < Ntau; itau++) - ACC[i][itau].reset(); + for (int itau = 0; itau < Ntau; itau++) ACC[i][itau].reset(); } void SF::measure(double sgn) { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("SF::measure"); reset(); @@ -122,12 +125,12 @@ void SF::measure(double sgn) { Site::iterator p(SITE); double bTri = 0.0; - double tau = 0.0; - int it = 0; + double tau = 0.0; + int it = 0; while (!(++p).atOrigin()) { Segment& S = *p; - double mz = SP.XVALS[S.X()]; + double mz = SP.XVALS[S.X()]; double tTri = bTri + S.length(); @@ -152,8 +155,8 @@ void SF::measure(double sgn) { for (int it = 0; it < Ntau; it++) { double SZKT = 0.0; for (int tt = 0; tt < Ntau; tt++) { - SZKT += counterC[ik][tt] * counterC[ik][(tt + it) % Ntau] - + counterS[ik][tt] * counterS[ik][(tt + it) % Ntau]; + SZKT += counterC[ik][tt] * counterC[ik][(tt + it) % Ntau] + + counterS[ik][tt] * counterS[ik][(tt + it) % Ntau]; } ACC[ik][it].accumulate(sgn * SZKT * invNtau); } @@ -161,32 +164,37 @@ void SF::measure(double sgn) { } inline void SF::show(FILE* F) { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("SF::show"); for (int i = 0; i < NK; i++) { for (int it = 0; it < Ntau; it++) { - PHY[i][it].show(F,"R"); + PHY[i][it].show(F, "R"); } fprintf(F, "\n"); } }; inline void SF::summary() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("SF::summary"); for (int i = 0; i < NK; i++) - for (int itau = 0; itau < Ntau; itau++) - PHY[i][itau].average(); + for (int itau = 0; itau < Ntau; itau++) PHY[i][itau].average(); } void SF::setsummary() { - if (!to_be_calc) { return; } + if (!to_be_calc) { + return; + } AutoDebugDump("SF::setsummary"); const double invV = 1.0 / LAT.NSITE; SIGN.average(); const double sgn = SIGN.mean(); - if (sgn != 0.0){ - const double invsign = 1.0/sgn; + if (sgn != 0.0) { + const double invsign = 1.0 / sgn; for (int ik = 0; ik < NK; ik++) { for (int it = 0; it < Ntau; it++) { ACC[ik][it].average(); @@ -198,7 +206,7 @@ void SF::setsummary() { } #ifdef MULTI -void SF::allreduce(MPI_Comm comm){ +void SF::allreduce(MPI_Comm comm) { for (int ik = 0; ik < NK; ik++) { for (int it = 0; it < Ntau; it++) { PHY[ik][it].allreduce(comm); @@ -217,14 +225,14 @@ void SF::load(std::ifstream& F) { Serialize::load(F, SIGN); Serialize::load(F, ACC); const int nk = ACC.size(); - if(nk != NK){ + if (nk != NK) { std::cerr << "ERROR: NK is mismatched" << std::endl; std::cerr << " sfinpfile maybe changed." << std::endl; exit(1); } - if(NK > 0){ + if (NK > 0) { const int ntau = ACC[0].size(); - if(ntau != Ntau){ + if (ntau != Ntau) { std::cerr << "ERROR: Ntau is mismatched" << std::endl; std::cerr << " sfinpfile maybe changed." << std::endl; exit(1); diff --git a/src/dla/util.hpp b/src/dla/util.hpp index 6db978e9..41b0306f 100644 --- a/src/dla/util.hpp +++ b/src/dla/util.hpp @@ -25,11 +25,11 @@ namespace util { template int min_index(const std::vector& xs) { const int n = xs.size(); - int i = 0; - T xmin = xs[0]; + int i = 0; + T xmin = xs[0]; for (int j = 1; j < n; ++j) { if (xs[j] < xmin) { - i = j; + i = j; xmin = xs[j]; } } @@ -38,23 +38,22 @@ int min_index(const std::vector& xs) { template int max_index(const std::vector& xs) { const int n = xs.size(); - int i = 0; - T xmax = xs[0]; + int i = 0; + T xmax = xs[0]; for (int j = 1; j < n; ++j) { if (xs[j] > xmax) { - i = j; + i = j; xmax = xs[j]; } } return i; } - -void ERROR(const char* msg){ +void ERROR(const char* msg) { std::cerr << "ERROR: " << msg << std::endl; std::exit(1); } } // namespace util -#endif // UTIL_HPP +#endif // UTIL_HPP diff --git a/src/dla/wavevector.hpp b/src/dla/wavevector.hpp index 367de1e9..472202c8 100644 --- a/src/dla/wavevector.hpp +++ b/src/dla/wavevector.hpp @@ -17,12 +17,13 @@ #ifndef WAVEVECTOR_HPP #define WAVEVECTOR_HPP -#include #include #include #include -#include "debug.hpp" +#include + #include "accumulator.hpp" +#include "debug.hpp" #include "parameter.hpp" #include "xml.h" @@ -37,8 +38,8 @@ struct WaveVector { WaveVector(Parameter const& param); }; -WaveVector::WaveVector(Parameter const& param) : defined(false), NSITES(0), NK(0) -{ +WaveVector::WaveVector(Parameter const& param) + : defined(false), NSITES(0), NK(0) { AutoDebugDump("WaveVector::WaveVector"); if (param.WVFILE.length() > 0) { defined = true; @@ -58,8 +59,8 @@ WaveVector::WaveVector(Parameter const& param) : defined(false), NSITES(0), NK(0 if (B.getName() == "RK") { double COSrk_ = B.getDouble(0); double SINrk_ = B.getDouble(1); - int site = B.getInteger(2); - int wave = B.getInteger(3); + int site = B.getInteger(2); + int wave = B.getInteger(3); COSrk[site][wave] = COSrk_; SINrk[site][wave] = SINrk_; } @@ -67,5 +68,4 @@ WaveVector::WaveVector(Parameter const& param) : defined(false), NSITES(0), NK(0 } }; - #endif // WaveVector_H diff --git a/src/dla/xml.h b/src/dla/xml.h index 65ac45ec..94619341 100644 --- a/src/dla/xml.h +++ b/src/dla/xml.h @@ -32,8 +32,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . - - // Known bugs: // (1) Tags must be separated from other words by one or more spaces or // line breaks. Otherwise they are not recognized. @@ -52,7 +50,7 @@ class Block; inline bool isCommentOpening(const std::string& key) { std::string sopen = ""; continue; } if (isOpening(w)) { - //cout << " ... beginning of a subelement [" << w << "]" << endl; + // cout << " ... beginning of a subelement [" << w << "]" << endl; depth++; const string name = getOpeningName(w); - //cout << "opening name : " << name << endl; + // cout << "opening name : " << name << endl; SkipTo = ""; NB++; continue; @@ -224,19 +223,23 @@ bool Block::syntax_error() { if (isClosing(w)) { printf("Block::read> Error.\n"); printf(" An unexpected closing tag %s\n", w.c_str()); - printf(" is detected in reading an element of name [%s].\n", getName().c_str()); + printf(" is detected in reading an element of name [%s].\n", + getName().c_str()); return true; } - //cout << " ... a value" << endl; + // cout << " ... a value" << endl; NV++; } if (depth != 0) { printf("Block::read> Error.\n"); string expected = SkipTo; - if (expected == "") { expected = Close; } + if (expected == "") { + expected = Close; + } printf(" A missing closing tag %s\n", expected.c_str()); - printf(" is detected in reading an element of name [%s].\n", getName().c_str()); + printf(" is detected in reading an element of name [%s].\n", + getName().c_str()); return true; } @@ -251,16 +254,16 @@ void Block::read() { if (NV > 0) Value.init("Value", 1, NV); if (NB > 0) SubBlock.init("SubBlock", 1, NB); - bool open = false; + bool open = false; string SkipTo = ""; - int ib = 0; - int iv = 0; - int i = 0; + int ib = 0; + int iv = 0; + int i = 0; while (true) { string& w = Word[i++]; // cout << "### " << w << endl; if (w == Open) { - //printf("Opened. %s\n", w.c_str()); + // printf("Opened. %s\n", w.c_str()); open = true; continue; } @@ -339,7 +342,8 @@ inline Block& Block::getElement(const std::string& name) { } } -inline Block& Block::getElement(const std::string& name, const std::string& idkey, const int id) { +inline Block& Block::getElement(const std::string& name, + const std::string& idkey, const int id) { int ib; for (ib = 0; ib < NB; ib++) { if (name == SubBlock[ib].getName()) { diff --git a/src/pmwa/PMWA.cpp b/src/pmwa/PMWA.cpp index 26a86bc2..96babfc1 100644 --- a/src/pmwa/PMWA.cpp +++ b/src/pmwa/PMWA.cpp @@ -14,16 +14,14 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include - -#include "../common/version.h" +#include +#include #include -#include - #include "../common/read_keyvalues.h" #include "../common/tostring.h" +#include "../common/version.h" int main(int argc, char **argv) { Dla Sim(argc, argv); @@ -76,17 +74,17 @@ double Dla::PMWA() { AutoPlog(""); Lattice LT(latfile); - if(!std::isinf(BETA)){ + if (!std::isinf(BETA)) { LT.set_beta(BETA); } PR.FlgAnneal = false; PR.FlgRestart = (MC.runtype == Restart); - if(PR.FlgRestart) { + if (PR.FlgRestart) { if (!std::isinf(oldBETA)) { LT.set_oldbeta(oldBETA); PR.FlgAnneal = true; PR.FlgRestart = false; - } else{ + } else { PR.FlgAnneal = false; } } @@ -101,16 +99,17 @@ double Dla::PMWA() { Probability P(&N, &sp, &PR); P.LookUpTable(&N, &sp); - Configuration CS(&MC, &N, sp.nmax, <, &P, &PR, IMAX, WMAX, Eventfile_old, &MR, (bool)cb, outfile); + Configuration CS(&MC, &N, sp.nmax, <, &P, &PR, IMAX, WMAX, Eventfile_old, + &MR, (bool)cb, outfile); Quantities QNT(&N, &MC, &sp, <, &PR, sfinpfile); - + //########################################################################## ////////////////// Determination of Ncyc //////////////////////// if (MC.nc <= 1) { MPI_Barrier(MPI_COMM_WORLD); pstart = MPI_Wtime(); - CS.DeterminationNworm(MC.Ntest, &MR, &QNT); // NCyc + CS.DeterminationNworm(MC.Ntest, &MR, &QNT); // NCyc MPI_Barrier(MPI_COMM_WORLD); pend = MPI_Wtime(); @@ -132,7 +131,7 @@ double Dla::PMWA() { return 1; } - if(PR.my_rank==0){ + if (PR.my_rank == 0) { cout << "start thermalization" << endl; } ////////////////// Thermalization //////////////////////// @@ -191,7 +190,8 @@ void Dla::NameOutfiles() { Eventfile = std::string("evout_"); Eventfile += outfile; - Eventfile += std::string("_rank") + tostring(PR.my_rank) + std::string(".dat"); + Eventfile += + std::string("_rank") + tostring(PR.my_rank) + std::string(".dat"); if (MC.runtype != Normal) { Eventfile_old = Eventfile; } @@ -200,7 +200,7 @@ void Dla::NameOutfiles() { void Dla::ReadParameterfile(int m_pnum, int m_myrank, int NP, char **PLIST) { using boost::lexical_cast; - PR.p_num = m_pnum; + PR.p_num = m_pnum; PR.my_rank = m_myrank; if (NP < 2) { @@ -216,14 +216,14 @@ void Dla::ReadParameterfile(int m_pnum, int m_myrank, int NP, char **PLIST) { deprecated_parameter(dict, "ntherm", "nmcse"); deprecated_parameter(dict, "ndecor", "nmcsd"); - MC.runtype = lexical_cast(dict["runtype"]); - MC.nc = lexical_cast(dict["nc"]); - MC.Nbin = lexical_cast(dict["nset"]); - MC.Nsample = lexical_cast(dict["nmcs"]); + MC.runtype = lexical_cast(dict["runtype"]); + MC.nc = lexical_cast(dict["nc"]); + MC.Nbin = lexical_cast(dict["nset"]); + MC.Nsample = lexical_cast(dict["nmcs"]); MC.Nthermal = lexical_cast(dict["ntherm"]); - MC.Nstep = lexical_cast(dict["ndecor"]); - MC.Ntest = lexical_cast(dict["npre"]); - MC.seed = lexical_cast(dict["seed"]); + MC.Nstep = lexical_cast(dict["ndecor"]); + MC.Ntest = lexical_cast(dict["npre"]); + MC.seed = lexical_cast(dict["seed"]); BETA = lexical_cast(dict["beta"]); oldBETA = lexical_cast(dict["oldbeta"]); @@ -232,22 +232,22 @@ void Dla::ReadParameterfile(int m_pnum, int m_myrank, int NP, char **PLIST) { deprecated_parameter(dict, "u", "ub"); deprecated_parameter(dict, "v", "vbb"); - sp.tb = lexical_cast(dict["t"]); + sp.tb = lexical_cast(dict["t"]); sp.Ubb = lexical_cast(dict["u"]); sp.Vb1 = lexical_cast(dict["v"]); - sp.mu = lexical_cast(dict["mu"]); + sp.mu = lexical_cast(dict["mu"]); sp.Htr = lexical_cast(dict["g"]); sp.nmax = lexical_cast(dict["nmax"]); - cb = lexical_cast(dict["cb"]); + cb = lexical_cast(dict["cb"]); IMAX = lexical_cast(dict["nvermax"]); WMAX = lexical_cast(dict["nwormax"]); - algfile = dict["algfile"]; - latfile = dict["latfile"]; + algfile = dict["algfile"]; + latfile = dict["latfile"]; sfinpfile = dict["sfinpfile"]; - outfile = dict["outfile"]; + outfile = dict["outfile"]; sfoutfile = dict["sfoutfile"]; N.d = (N.y == 1) ? 1 : ((N.z == 1) ? 2 : 3); @@ -260,14 +260,14 @@ void Dla::ReadParameterfile(int m_pnum, int m_myrank, int NP, char **PLIST) { } void Dla::init_paramdict(std::map &dict) { - dict["cb"] = "0"; - dict["nset"] = "10"; - dict["nmcs"] = "1000"; - dict["npre"] = "1000"; + dict["cb"] = "0"; + dict["nset"] = "10"; + dict["nmcs"] = "1000"; + dict["npre"] = "1000"; dict["ntherm"] = "1000"; dict["ndecor"] = "1000"; - dict["seed"] = "13"; - dict["nc"] = "0"; + dict["seed"] = "13"; + dict["nc"] = "0"; dict["nvermax"] = "100000000"; dict["nwormax"] = "1000"; @@ -275,26 +275,27 @@ void Dla::init_paramdict(std::map &dict) { dict["beta"] = "Inf"; dict["oldbeta"] = "Inf"; - dict["g"] = "0.2"; - dict["t"] = "1.0"; - dict["u"] = "0.0"; - dict["v"] = "3.0"; - dict["mu"] = "1.0"; + dict["g"] = "0.2"; + dict["t"] = "1.0"; + dict["u"] = "0.0"; + dict["v"] = "3.0"; + dict["mu"] = "1.0"; dict["nmax"] = "1"; - dict["algfile"] = "algorithm.xml"; - dict["latfile"] = "lattice.xml"; + dict["algfile"] = "algorithm.xml"; + dict["latfile"] = "lattice.xml"; dict["sfinpfile"] = "sf.xml"; - dict["outfile"] = "res.dat"; + dict["outfile"] = "res.dat"; dict["sfoutfile"] = "sf.out"; dict["cfoutfile"] = "cf.out"; } void Dla::set_Parallel() { - PR.B = N.B / (double)PR.Ntdiv; // beta for a domain. + PR.B = N.B / (double)PR.Ntdiv; // beta for a domain. PR.oldB = N.oldB / (double)PR.Ntdiv; // for annealing. - PR.Nsdiv = PR.Nxdiv * PR.Nydiv * PR.Nzdiv; // the number of spatial decompositions. + PR.Nsdiv = + PR.Nxdiv * PR.Nydiv * PR.Nzdiv; // the number of spatial decompositions. PR.x = N.x / PR.Nxdiv; PR.y = N.y / PR.Nydiv; @@ -302,54 +303,98 @@ void Dla::set_Parallel() { PR.V = PR.x * PR.y * PR.z; - PR.NtNs = PR.Ntdiv * PR.Nsdiv; //the number of decompositions. - PR.Npara = PR.p_num / PR.NtNs; //the number of seeds for trivial parallelization. + PR.NtNs = PR.Ntdiv * PR.Nsdiv; // the number of decompositions. + PR.Npara = + PR.p_num / PR.NtNs; // the number of seeds for trivial parallelization. - PR.nt = PR.my_rank % PR.Ntdiv; // the temporal domain number for the processor. - PR.ns = (int)(PR.my_rank / PR.Ntdiv) % PR.Nsdiv; // the spatial domain number for the processor. + PR.nt = + PR.my_rank % PR.Ntdiv; // the temporal domain number for the processor. + PR.ns = (int)(PR.my_rank / PR.Ntdiv) % + PR.Nsdiv; // the spatial domain number for the processor. - PR.nx = PR.ns % PR.Nxdiv; // the x-directional domain number for the processor. - PR.ny = (PR.ns / PR.Nxdiv) % PR.Nydiv; // the y-directional domain number for the processor. - PR.nz = PR.ns / (PR.Nxdiv * PR.Nydiv); // the z-directional domain number for the processor. + PR.nx = + PR.ns % PR.Nxdiv; // the x-directional domain number for the processor. + PR.ny = (PR.ns / PR.Nxdiv) % + PR.Nydiv; // the y-directional domain number for the processor. + PR.nz = + PR.ns / (PR.Nxdiv * + PR.Nydiv); // the z-directional domain number for the processor. - PR.nst = PR.my_rank % PR.NtNs; // the domain number for the processor. - PR.np = PR.my_rank / (PR.NtNs); // the seed number of the trivial parallelization for the processor. + PR.nst = PR.my_rank % PR.NtNs; // the domain number for the processor. + PR.np = PR.my_rank / (PR.NtNs); // the seed number of the trivial + // parallelization for the processor. if (PR.Rpara > 0) { - PR.nr = PR.np % PR.Rpara; // a random potential number (one of trivial parallelization) - PR.nq = - PR.np - / PR.Rpara; // a seed number of the trivial parallelization for the random potential (one of trivial parallelization) + PR.nr = + PR.np % + PR.Rpara; // a random potential number (one of trivial parallelization) + PR.nq = PR.np / + PR.Rpara; // a seed number of the trivial parallelization for the + // random potential (one of trivial parallelization) } else { PR.nr = 0; PR.nq = PR.np; } - //the coordinate is (nt,nx,ny,nz,np) - - PR.nst0 = PR.np * PR.NtNs; // nst=0 process number for the processor. - PR.nt0 = PR.ns * PR.Ntdiv + PR.np * PR.NtNs; //nt=0 process number for the processor. - PR.ns0 = PR.nt + PR.np * PR.NtNs; //ns=0 process number for the processor. - PR.nx0 = PR.nt + (PR.ny * PR.Nxdiv + PR.nz * PR.Nxdiv * PR.Nydiv) * PR.Ntdiv - + PR.np * PR.NtNs; //nx=0 process number for the processor. - - PR.upper = (PR.nt + 1) % PR.Ntdiv + PR.ns * PR.Ntdiv - + PR.np * PR.Ntdiv * PR.Nsdiv; //the upper process number for the temporal direction. - PR.lower = (PR.nt - 1 + PR.Ntdiv) % PR.Ntdiv + PR.ns * PR.Ntdiv - + PR.np * PR.Ntdiv * PR.Nsdiv; //the lower process number the temporal direction. - - PR.right[0] = PR.nt + ((PR.nx + 1) % PR.Nxdiv + PR.ny * PR.Nxdiv + PR.nz * PR.Nxdiv * PR.Nydiv) * PR.Ntdiv - + PR.np * PR.Ntdiv * PR.Nsdiv; //the right side process number for the x direction. - PR.left[0] = PR.nt + ((PR.nx - 1 + PR.Nxdiv) % PR.Nxdiv + PR.ny * PR.Nxdiv + PR.nz * PR.Nxdiv * PR.Nydiv) * PR.Ntdiv - + PR.np * PR.Ntdiv * PR.Nsdiv; //the left side process number for the x direction. - - PR.right[1] = PR.nt + (PR.nx + ((PR.ny + 1) % PR.Nydiv) * PR.Nxdiv + PR.nz * PR.Nxdiv * PR.Nydiv) * PR.Ntdiv - + PR.np * PR.Ntdiv * PR.Nsdiv; //the right side process number for the y direction. - PR.left[1] = PR.nt + (PR.nx + ((PR.ny - 1 + PR.Nydiv) % PR.Nydiv) * PR.Nxdiv + PR.nz * PR.Nxdiv * PR.Nydiv) * PR.Ntdiv - + PR.np * PR.Ntdiv * PR.Nsdiv; //the left side process number for the y direction. - - PR.right[2] = PR.nt + (PR.nx + PR.ny * PR.Nxdiv + ((PR.nz + 1) % PR.Nzdiv) * PR.Nxdiv * PR.Nydiv) * PR.Ntdiv - + PR.np * PR.Ntdiv * PR.Nsdiv; //the right side process number for the z direction. - PR.left[2] = PR.nt + (PR.nx + PR.ny * PR.Nxdiv + ((PR.nz - 1 + PR.Nzdiv) % PR.Nzdiv) * PR.Nxdiv * PR.Nydiv) * PR.Ntdiv - + PR.np * PR.Ntdiv * PR.Nsdiv; //the left side process number for the z direction. + // the coordinate is (nt,nx,ny,nz,np) + + PR.nst0 = PR.np * PR.NtNs; // nst=0 process number for the processor. + PR.nt0 = PR.ns * PR.Ntdiv + + PR.np * PR.NtNs; // nt=0 process number for the processor. + PR.ns0 = PR.nt + PR.np * PR.NtNs; // ns=0 process number for the processor. + PR.nx0 = PR.nt + (PR.ny * PR.Nxdiv + PR.nz * PR.Nxdiv * PR.Nydiv) * PR.Ntdiv + + PR.np * PR.NtNs; // nx=0 process number for the processor. + + PR.upper = + (PR.nt + 1) % PR.Ntdiv + PR.ns * PR.Ntdiv + + PR.np * PR.Ntdiv * + PR.Nsdiv; // the upper process number for the temporal direction. + PR.lower = (PR.nt - 1 + PR.Ntdiv) % PR.Ntdiv + PR.ns * PR.Ntdiv + + PR.np * PR.Ntdiv * + PR.Nsdiv; // the lower process number the temporal direction. + + PR.right[0] = + PR.nt + + ((PR.nx + 1) % PR.Nxdiv + PR.ny * PR.Nxdiv + + PR.nz * PR.Nxdiv * PR.Nydiv) * + PR.Ntdiv + + PR.np * PR.Ntdiv * + PR.Nsdiv; // the right side process number for the x direction. + PR.left[0] = + PR.nt + + ((PR.nx - 1 + PR.Nxdiv) % PR.Nxdiv + PR.ny * PR.Nxdiv + + PR.nz * PR.Nxdiv * PR.Nydiv) * + PR.Ntdiv + + PR.np * PR.Ntdiv * + PR.Nsdiv; // the left side process number for the x direction. + + PR.right[1] = + PR.nt + + (PR.nx + ((PR.ny + 1) % PR.Nydiv) * PR.Nxdiv + + PR.nz * PR.Nxdiv * PR.Nydiv) * + PR.Ntdiv + + PR.np * PR.Ntdiv * + PR.Nsdiv; // the right side process number for the y direction. + PR.left[1] = + PR.nt + + (PR.nx + ((PR.ny - 1 + PR.Nydiv) % PR.Nydiv) * PR.Nxdiv + + PR.nz * PR.Nxdiv * PR.Nydiv) * + PR.Ntdiv + + PR.np * PR.Ntdiv * + PR.Nsdiv; // the left side process number for the y direction. + + PR.right[2] = + PR.nt + + (PR.nx + PR.ny * PR.Nxdiv + + ((PR.nz + 1) % PR.Nzdiv) * PR.Nxdiv * PR.Nydiv) * + PR.Ntdiv + + PR.np * PR.Ntdiv * + PR.Nsdiv; // the right side process number for the z direction. + PR.left[2] = + PR.nt + + (PR.nx + PR.ny * PR.Nxdiv + + ((PR.nz - 1 + PR.Nzdiv) % PR.Nzdiv) * PR.Nxdiv * PR.Nydiv) * + PR.Ntdiv + + PR.np * PR.Ntdiv * + PR.Nsdiv; // the left side process number for the z direction. } diff --git a/src/pmwa/configuration.cpp b/src/pmwa/configuration.cpp index 9274b9fe..5d100fd1 100644 --- a/src/pmwa/configuration.cpp +++ b/src/pmwa/configuration.cpp @@ -1,24 +1,25 @@ -#include - -#include - #include #include +#include +#include + #include "../common/timer.hpp" //#define Bcheck //#include "graphspace.cpp" -Configuration::Configuration(MC_p *m_MC, Size *m_N, int m_nmax, Lattice *m_LT, Probability *m_P, Parallel *PR, - long long m_IMAX, long long m_WMAX, std::string const& m_Eventfile, My_rdm *MR, bool cb, - std::string const& m_outfile) - : GraphSpace(m_N, m_nmax, m_LT, m_P, PR, m_IMAX, m_WMAX, m_Eventfile, MR, cb, m_outfile) { - N = m_N; - LT = m_LT; - BV = PR->B * PR->V; +Configuration::Configuration(MC_p *m_MC, Size *m_N, int m_nmax, Lattice *m_LT, + Probability *m_P, Parallel *PR, long long m_IMAX, + long long m_WMAX, std::string const &m_Eventfile, + My_rdm *MR, bool cb, std::string const &m_outfile) + : GraphSpace(m_N, m_nmax, m_LT, m_P, PR, m_IMAX, m_WMAX, m_Eventfile, MR, + cb, m_outfile) { + N = m_N; + LT = m_LT; + BV = PR->B * PR->V; p_num = PR->p_num; - MC = m_MC; + MC = m_MC; ALGFILE = "algorithm.xml"; LATFILE = "lattice.xml"; @@ -33,7 +34,8 @@ void Configuration::DeterminationNworm(int MCS, My_rdm *MR, Quantities *QNT) { } /* - * Determine NCycle so that total distance of all the worms during NCycle updates is about V*beta + * Determine NCycle so that total distance of all the worms during NCycle + * updates is about V*beta */ void Configuration::updateAnner(int MCS, My_rdm *MR, Quantities *QNT) { AutoPlog(""); @@ -54,8 +56,8 @@ void Configuration::updateAnner(int MCS, My_rdm *MR, Quantities *QNT) { For_Nworm = true; MCS /= step; - if(PR->my_rank==0){ - if(PR->FlgAnneal==true) cout << "start anneal" << endl; + if (PR->my_rank == 0) { + if (PR->FlgAnneal == true) cout << "start anneal" << endl; } for (int i = 0; i < step1; i++) { @@ -68,7 +70,7 @@ void Configuration::updateAnner(int MCS, My_rdm *MR, Quantities *QNT) { if (Wlen != 0.0) { ave_Wlen = Wlen / (double)(Ncyc * MCS); - Ncyc = (long)(BV / ave_Wlen); + Ncyc = (long)(BV / ave_Wlen); if (Ncyc == 0) Ncyc = 1; } else Ncyc = 0; @@ -76,7 +78,7 @@ void Configuration::updateAnner(int MCS, My_rdm *MR, Quantities *QNT) { MPI_Allgather(&Ncyc, 1, MPI_LONG, pcyc, 1, MPI_LONG, comm_nst0); // cout<<"rank"<my_rank<<"::Wnum="<NtNs; tag++) { if (pcyc[tag] > 0) { count++; @@ -95,7 +97,9 @@ void Configuration::updateAnner(int MCS, My_rdm *MR, Quantities *QNT) { if (Ncyc > 100000) Ncyc = 100000; - // cout<< i <<"::rank"<my_rank<<":: Wlen="<my_rank<<":: Wlen="<my_rank<<":: Wlen="<my_rank<<":: Wlen="<my_rank == 0){ + if (PR->my_rank == 0) { std::cout << "start main calculation" << std::endl; } QNT->Init(); Timer tm; for (int bin = 0; bin < MC->Nbin; bin++) { - sweep(MC->Nstep, MR, QNT); QNT->Init(); for (int i = 0; i < MC->Nsample; i++) { For_Nworm = true; - Wlen = 0.0; + Wlen = 0.0; if (Diagonal_Update(MR, QNT)) Worm_Update(MR); QNT->Measure(Nv, Nk, ev, WORM, world, worldB, Wlen, W[0], i); } - // calculate observables as functions of expectation value of other observables, - // e.g., compressibility + // calculate observables as functions of expectation value of other + // observables, e.g., compressibility QNT->Measure(); QNT->BINsum(bin); - + const double elapsed = tm.elapsed(); - const double ETR = elapsed * (MC->Nbin - bin-1) / (bin+1); - if (PR->my_rank == 0){ - std::cout << bin+1 << " / " << MC->Nbin << " done. [Elapsed: " << elapsed << " sec. ETR: " << ETR << " sec.]" << std::endl; + const double ETR = elapsed * (MC->Nbin - bin - 1) / (bin + 1); + if (PR->my_rank == 0) { + std::cout << bin + 1 << " / " << MC->Nbin + << " done. [Elapsed: " << elapsed << " sec. ETR: " << ETR + << " sec.]" << std::endl; } } diff --git a/src/pmwa/graphspace.cpp b/src/pmwa/graphspace.cpp index a2a9a315..3338c376 100644 --- a/src/pmwa/graphspace.cpp +++ b/src/pmwa/graphspace.cpp @@ -1,25 +1,29 @@ #include "Graph_functions.h" -bool ascending(const GraphSpace::Vertex &_p1, const GraphSpace::Vertex &_p2) { return _p1.t < _p2.t; } +bool ascending(const GraphSpace::Vertex &_p1, const GraphSpace::Vertex &_p2) { + return _p1.t < _p2.t; +} -GraphSpace::GraphSpace(Size *N, int m_nmax, Lattice *m_LT, Probability *m_P, Parallel *m_PR, long long m_IMAX, - long long m_WMAX, std::string const& m_Eventfile_old, My_rdm *MR, int cb, std::string const& m_outfile) { +GraphSpace::GraphSpace(Size *N, int m_nmax, Lattice *m_LT, Probability *m_P, + Parallel *m_PR, long long m_IMAX, long long m_WMAX, + std::string const &m_Eventfile_old, My_rdm *MR, int cb, + std::string const &m_outfile) { IMAX = m_IMAX; WMAX = m_WMAX; NMIN = G_NMIN; outfile = m_outfile; PR = m_PR; - V = PR->V; - B = PR->B; - D = N->d; + V = PR->V; + B = PR->B; + D = N->d; BetaOrg = N->B; BetaOldOrg = N->oldB; boxsize = IMAX / V; - nmax = m_nmax; - LT = m_LT; - P = m_P; + nmax = m_nmax; + LT = m_LT; + P = m_P; Bh = B / 2.0; @@ -117,7 +121,8 @@ GraphSpace::~GraphSpace() { delcall(t); } -void GraphSpace::initialev(std::string const& Eventfile_old, My_rdm *MR, int cb, double oldB) { +void GraphSpace::initialev(std::string const &Eventfile_old, My_rdm *MR, int cb, + double oldB) { ev.resize(IMAX); ev.clear(); @@ -127,20 +132,20 @@ void GraphSpace::initialev(std::string const& Eventfile_old, My_rdm *MR, int cb, std::string rndfile("RND"); rndfile += Eventfile_old; - if(PR->FlgAnneal || PR->FlgRestart) { + if (PR->FlgAnneal || PR->FlgRestart) { MR->ingen(rndfile); } for (int i = 0; i < V; i++) { world[i].type = worldB[i].type = -5; world[i].i = worldB[i].i = i; - world[i].t = 0.0; - worldB[i].t = B; - world[i].next[1] = &(worldB[i]); - world[i].next[0] = &(worldB[i]); - worldB[i].next[1] = &(world[i]); - worldB[i].next[0] = &(world[i]); - w[i] = &(world[i]); + world[i].t = 0.0; + worldB[i].t = B; + world[i].next[1] = &(worldB[i]); + world[i].next[0] = &(worldB[i]); + worldB[i].next[1] = &(world[i]); + worldB[i].next[0] = &(world[i]); + w[i] = &(world[i]); } ifstream fin(Eventfile_old.c_str()); @@ -148,48 +153,52 @@ void GraphSpace::initialev(std::string const& Eventfile_old, My_rdm *MR, int cb, Vertex *reuse_L, *reuse_R; int xl, xr, dummy; - if(PR->FlgAnneal || PR->FlgRestart) { - + if (PR->FlgAnneal || PR->FlgRestart) { if (fin) { - cout << "rank " << my_rank << ": checkpoint file" << Eventfile_old << " found, resume this calculation." << endl; + cout << "rank " << my_rank << ": checkpoint file" << Eventfile_old + << " found, resume this calculation." << endl; double tmp_B_old; fin >> tmp_B_old; if (PR->FlgAnneal) { - if (fabs(tmp_B_old-BetaOldOrg) < pow(10.0, -12)) { - cout << "Annealing rate=" << B / oldB << endl; //B: beta + if (fabs(tmp_B_old - BetaOldOrg) < pow(10.0, -12)) { + cout << "Annealing rate=" << B / oldB << endl; // B: beta + } else { + if (PR->my_rank == 0) { + cerr << "oldB = " << BetaOldOrg + << " is not same the beta =" << tmp_B_old + << " written in the input file" << endl; } - else{ - if(PR->my_rank==0) { - cerr << "oldB = "<FlgRestart){ - if (fabs(tmp_B_old - BetaOrg) < pow(10.0, -12)) { - cout << "Restart calculation starts." << endl; - } - else{ - if(PR->my_rank==0) { - cerr << "B = "<< BetaOrg <<" is not same the beta ="<FlgRestart) { + if (fabs(tmp_B_old - BetaOrg) < pow(10.0, -12)) { + cout << "Restart calculation starts." << endl; + } else { + if (PR->my_rank == 0) { + cerr << "B = " << BetaOrg + << " is not same the beta =" << tmp_B_old + << " written in the input file" << endl; } + fin.close(); + MPI_Finalize(); + exit(1); + } } + } - fin >> Ncyc; - for (int i = 0; i < V; i++) - fin >> world[i].p >> worldB[i].p; + fin >> Ncyc; + for (int i = 0; i < V; i++) fin >> world[i].p >> worldB[i].p; while (!fin.eof()) { - fin >> dummy >> new_event_L.t >> new_event_L.type >> new_event_L.p >> xl; - if (new_event_L.type == 2) fin >> dummy >> new_event_R.t >> new_event_R.type >> new_event_R.p >> xr; + fin >> dummy >> new_event_L.t >> new_event_L.type >> new_event_L.p >> + xl; + if (new_event_L.type == 2) + fin >> dummy >> new_event_R.t >> new_event_R.type >> new_event_R.p >> + xr; if (PR->FlgAnneal) { new_event_L.t *= B / oldB; @@ -214,24 +223,24 @@ void GraphSpace::initialev(std::string const& Eventfile_old, My_rdm *MR, int cb, } } } else { - if(PR->my_rank==0) { - cerr << "rank " << my_rank << ":no evfile found, start a new calculation" << endl; + if (PR->my_rank == 0) { + cerr << "rank " << my_rank + << ":no evfile found, start a new calculation" << endl; } MPI_Finalize(); exit(1); } - } - else{ + } else { Ncyc = 30; if (cb == 1) for (int i = 0; i < V; i++) - world[i].p = worldB[i].p = ((i % PR->x + (int) (i / PR->x)) % 2 == 0) ? 1 : 0; + world[i].p = worldB[i].p = + ((i % PR->x + (int)(i / PR->x)) % 2 == 0) ? 1 : 0; else if (cb == 2) for (int i = 0; i < V; i++) world[i].p = worldB[i].p = (nmax + 1) * MR->rdm(); else - for (int i = 0; i < V; i++) - world[i].p = worldB[i].p = 0; + for (int i = 0; i < V; i++) world[i].p = worldB[i].p = 0; } fin.close(); @@ -239,10 +248,10 @@ void GraphSpace::initialev(std::string const& Eventfile_old, My_rdm *MR, int cb, newcalls(W, 2); rtb_i = P->tb; - rt_i = P->rtmax; + rt_i = P->rtmax; rtb_tot = LT->TB * rtb_i; - rt_tot = LT->TB * rt_i; + rt_tot = LT->TB * rt_i; rtot = rt_tot; @@ -256,26 +265,26 @@ void GraphSpace::initialev(std::string const& Eventfile_old, My_rdm *MR, int cb, for (int a = 0; a < 4; a++) { for (int b = 0; b <= a; b++) { if (a == b) { - Switch[a][b] = 0; //bounce - After[0][a] = b; //bounce - } else if (a + b == 3) { //hop and turn + Switch[a][b] = 0; // bounce + After[0][a] = b; // bounce + } else if (a + b == 3) { // hop and turn Switch[a][b] = 3; Switch[b][a] = 3; - After[3][b] = a; - After[3][a] = b; - } else if (a - b == 2) { //hop + After[3][b] = a; + After[3][a] = b; + } else if (a - b == 2) { // hop Switch[a][b] = 2; Switch[b][a] = 2; - After[2][b] = a; - After[2][a] = b; - } else { //pass + After[2][b] = a; + After[2][a] = b; + } else { // pass Switch[a][b] = 1; Switch[b][a] = 1; - After[1][b] = a; - After[1][a] = b; + After[1][b] = a; + After[1][a] = b; } } } @@ -290,7 +299,7 @@ void GraphSpace::initialev(std::string const& Eventfile_old, My_rdm *MR, int cb, } // output of the configuration. -void GraphSpace::Output(std::string const& fname, My_rdm *MR) { +void GraphSpace::Output(std::string const &fname, My_rdm *MR) { std::ofstream file(fname.c_str()); int EVmax = ev.size(); @@ -312,7 +321,8 @@ void GraphSpace::Output(std::string const& fname, My_rdm *MR) { if (type == 2 || type == 4 || type == 5 || type % 2 == -1) { file << endl; - file << i << " " << ev.at(i).t << " " << ev.at(i).type << " " << ev.at(i).p << " " << ev.at(i).i; + file << i << " " << ev.at(i).t << " " << ev.at(i).type << " " + << ev.at(i).p << " " << ev.at(i).i; } i++; @@ -330,7 +340,7 @@ void GraphSpace::Output(std::string const& fname, My_rdm *MR) { bool GraphSpace::Diagonal_Update(My_rdm *MR, Quantities *QNT) { WORM.clear(); - W[0] = 0; //initialization of the numberof worms + W[0] = 0; // initialization of the numberof worms Remove_Vertex(); @@ -369,7 +379,7 @@ void GraphSpace::Assign_OnsiteVertex(My_rdm *MR) { targ_time = 0.0; while (1) { - R = MR->rdm(); + R = MR->rdm(); double rhou = P->rumax[i]; if (rhou != 0.0) dt = -log(1.0 - R) / P->rumax[i]; @@ -410,8 +420,7 @@ void GraphSpace::Assign_OnsiteVertex(My_rdm *MR) { void GraphSpace::Remove_Vertex() { Vnum = 0; - for (int i = 0; i < V; i++) - INmax[i] = 1; + for (int i = 0; i < V; i++) INmax[i] = 1; Nv = 0; Nk = 0; @@ -457,13 +466,15 @@ void GraphSpace::Assign_TwoSiteVertex(My_rdm *MR) { double Blim = B - NMIN; /////////////////////////////////////////////////////////////////////////////////////////////// - //// For MPI information!! /////////////////////////////////////////////////////////////////////////////////////////////// + //// For MPI information!! + ////////////////////////////////////////////////////////////////////////////////////////////////// for (int d = 0; d < LT->Pd; d++) { kmax = 0; for (int i = 0; i < LT->Fx[d]; i++) { k = 0; - for (Vertex *wl = &(world[LT->frame_rsite[d][i]]); wl != &(worldB[LT->frame_rsite[d][i]]); wl = wl->next[1]) { + for (Vertex *wl = &(world[LT->frame_rsite[d][i]]); + wl != &(worldB[LT->frame_rsite[d][i]]); wl = wl->next[1]) { BoxSpace_t_th0[d][f(d, i, k)] = wl->t; BoxSpace_p_th0[d][f(d, i, k)] = wl->p; k++; @@ -477,32 +488,34 @@ void GraphSpace::Assign_TwoSiteVertex(My_rdm *MR) { } NewVertex_th0[d] = kmax * LT->Fx[d]; - MPI_Sendrecv(&(NewVertex_th0[d]), 1, MPI_INT, PR->left[d], 0, &(NewVertex_th1[d]), 1, MPI_INT, PR->right[d], 0, + MPI_Sendrecv(&(NewVertex_th0[d]), 1, MPI_INT, PR->left[d], 0, + &(NewVertex_th1[d]), 1, MPI_INT, PR->right[d], 0, MPI_COMM_WORLD, &status); } for (int d = 0; d < LT->Pd; d++) { - MPI_Sendrecv(&(BoxSpace_t_th0[d][0]), NewVertex_th0[d], MPI_DOUBLE, PR->left[d], 0, &(BoxSpace_t_th1[d][0]), - NewVertex_th1[d], MPI_DOUBLE, PR->right[d], 0, MPI_COMM_WORLD, &status); - MPI_Sendrecv(&(BoxSpace_p_th0[d][0]), NewVertex_th0[d], MPI_SHORT, PR->left[d], 0, &(BoxSpace_p_th1[d][0]), - NewVertex_th1[d], MPI_SHORT, PR->right[d], 0, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(BoxSpace_t_th0[d][0]), NewVertex_th0[d], MPI_DOUBLE, + PR->left[d], 0, &(BoxSpace_t_th1[d][0]), NewVertex_th1[d], + MPI_DOUBLE, PR->right[d], 0, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(BoxSpace_p_th0[d][0]), NewVertex_th0[d], MPI_SHORT, + PR->left[d], 0, &(BoxSpace_p_th1[d][0]), NewVertex_th1[d], + MPI_SHORT, PR->right[d], 0, MPI_COMM_WORLD, &status); } /////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// k = 0; - long Ih = IMAX / 2; + long Ih = IMAX / 2; targ_time = 0.0; for (int d = 0; d < D; d++) - for (int i = 0; i < ES; i++) - wf[d][i] = newt[d][i] = 0; + for (int i = 0; i < ES; i++) wf[d][i] = newt[d][i] = 0; int ics = 0; while (1) { - R = MR->rdm(); + R = MR->rdm(); dt = -log(1.0 - R) / rtot; if (dt < NMIN) dt = NMIN; targ_time += dt; @@ -516,9 +529,9 @@ void GraphSpace::Assign_TwoSiteVertex(My_rdm *MR) { R = MR->rdm(); if (Pv1 > R) { site = (int)(V * MR->rdm()); - d = (int)(LT->Pd * MR->rdm()); //(LT->bnum*MR->rdm()); - xl = site; - xr = LT->bd[site][d]; + d = (int)(LT->Pd * MR->rdm()); //(LT->bnum*MR->rdm()); + xl = site; + xr = LT->bd[site][d]; } else { if (D != 2) { cout << "error in DG" << endl; @@ -554,7 +567,7 @@ void GraphSpace::Assign_TwoSiteVertex(My_rdm *MR) { Nv++; } - } else { // innerbond + } else { // innerbond while (w[xr]->next[1] != &(worldB[xr])) { if (targ_time < w[xr]->next[1]->t) break; @@ -578,31 +591,31 @@ void GraphSpace::Assign_TwoSiteVertex(My_rdm *MR) { } /////////////////////////////////////////////////////////////////////////////////////////////// - //// For MPI information!! /////////////////////////////////////////////////////////////////////////////////////////////// + //// For MPI information!! + ////////////////////////////////////////////////////////////////////////////////////////////////// int ntmax; for (int d = 0; d < LT->Pd; d++) { - MPI_Sendrecv(newt[d], LT->Fx[d], MPI_INT, PR->right[d], 0, newt_th1[d], LT->Fx[d], MPI_INT, PR->left[d], 0, - MPI_COMM_WORLD, &status); + MPI_Sendrecv(newt[d], LT->Fx[d], MPI_INT, PR->right[d], 0, newt_th1[d], + LT->Fx[d], MPI_INT, PR->left[d], 0, MPI_COMM_WORLD, &status); ntmax = 0; - for (int i = 0; i < LT->Fx[d]; i++) - ntmax = max(ntmax, newt[d][i]); + for (int i = 0; i < LT->Fx[d]; i++) ntmax = max(ntmax, newt[d][i]); NewVertex_th0[d] = ntmax * LT->Fx[d]; ntmax = 0; - for (int i = 0; i < LT->Fx[d]; i++) - ntmax = max(ntmax, newt_th1[d][i]); + for (int i = 0; i < LT->Fx[d]; i++) ntmax = max(ntmax, newt_th1[d][i]); NewVertex_th1[d] = ntmax * LT->Fx[d]; - MPI_Sendrecv(&(BoxSpace_t_th0[d][0]), NewVertex_th0[d], MPI_DOUBLE, PR->right[d], 0, &(BoxSpace_t_th1[d][0]), - NewVertex_th1[d], MPI_DOUBLE, PR->left[d], 0, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(BoxSpace_t_th0[d][0]), NewVertex_th0[d], MPI_DOUBLE, + PR->right[d], 0, &(BoxSpace_t_th1[d][0]), NewVertex_th1[d], + MPI_DOUBLE, PR->left[d], 0, MPI_COMM_WORLD, &status); MPI_Barrier(MPI_COMM_WORLD); for (int i = 0; i < LT->Fx[d]; i++) { - xr = LT->frame_rsite[d][i]; + xr = LT->frame_rsite[d][i]; w[xr] = &(world[xr]); - k = 0; + k = 0; while (k < newt_th1[d][i]) { if (BoxSpace_t_th1[d][f(d, i, k)] < w[xr]->next[1]->t) { @@ -628,15 +641,15 @@ void GraphSpace::release(Vertex *wx) { VertexPool.push(wx); } -void GraphSpace::insert(Vertex *vl, Vertex *vr, short new_type, double new_time, int xl, int xr, int pl, int pr, - int d) { - //Left +void GraphSpace::insert(Vertex *vl, Vertex *vr, short new_type, double new_time, + int xl, int xr, int pl, int pr, int d) { + // Left if (VertexPool.empty()) insert_NewEvent(vl, new_type, new_time, xl, pl, d); else Renew_Vertex(vl, new_type, new_time, xl, pl, d); - //Right + // Right if (VertexPool.empty()) insert_NewEvent(vr, new_type, new_time, xr, pr, d); else @@ -646,36 +659,39 @@ void GraphSpace::insert(Vertex *vl, Vertex *vr, short new_type, double new_time, vr->next[1]->nleg = vl->next[1]; } -void GraphSpace::insert(Vertex *v, short new_type, double new_time, int x, int p, int d) { +void GraphSpace::insert(Vertex *v, short new_type, double new_time, int x, + int p, int d) { if (VertexPool.empty()) insert_NewEvent(v, new_type, new_time, x, p, d); else Renew_Vertex(v, new_type, new_time, x, p, d); } -void GraphSpace::insert_NewEvent(Vertex *v, int new_type, double new_time, int xx, int px, int d) { +void GraphSpace::insert_NewEvent(Vertex *v, int new_type, double new_time, + int xx, int px, int d) { Vertex new_event; new_event.type = new_type; - new_event.t = new_time; - new_event.i = xx + d * V; - new_event.p = px; + new_event.t = new_time; + new_event.i = xx + d * V; + new_event.p = px; ev.push_back(new_event); relink(v, &(ev.back()), v->next[1]); } -void GraphSpace::Renew_Vertex(Vertex *v, int new_type, double new_time, int xx, int px, int d) { +void GraphSpace::Renew_Vertex(Vertex *v, int new_type, double new_time, int xx, + int px, int d) { Vertex *reuse; reuse = VertexPool.top(); VertexPool.pop(); reuse->type = new_type; - reuse->t = new_time; - reuse->i = xx + d * V; - reuse->p = px; + reuse->t = new_time; + reuse->i = xx + d * V; + reuse->p = px; relink(v, reuse, v->next[1]); } @@ -689,8 +705,8 @@ void GraphSpace::relink(Vertex *v1, Vertex *v2, Vertex *v3) { void GraphSpace::connect_after(Vertex **wl, Vertex *el, int x) { wl[x]->next[1]->next[0] = el; - wl[x]->next[1] = el; - wl[x] = el; + wl[x]->next[1] = el; + wl[x] = el; } void GraphSpace::connect_before(Vertex *wl, Vertex *new_event) { @@ -700,13 +716,12 @@ void GraphSpace::connect_before(Vertex *wl, Vertex *new_event) { // check parity and remove worm void GraphSpace::worm_release(My_rdm *MR) { - int parity; Vertex *dw; for (int site = 0; site < V; site++) { parity = 0; - dw = &(world[site]); + dw = &(world[site]); if (INmax[site] == 1) { // No vertex exists (only worm) @@ -753,22 +768,23 @@ void GraphSpace::Assign_Worm(My_rdm *MR) { bool n0; for (int site = 0; site < V; site++) { - for (Vertex *wl = world[site].next[1]; wl != &(world[site]); wl = wl->next[1]) { // until worldB + for (Vertex *wl = world[site].next[1]; wl != &(world[site]); + wl = wl->next[1]) { // until worldB - j = 0; - dw = wl->next[0]; + j = 0; + dw = wl->next[0]; dtn[0] = dw->t; - n0 = dw->p; + n0 = dw->p; parity_check(MR, (wl->dir) % 2, dtn, j, wl->t, dw->t); - for (int l = 0; l < j; l++) { //insert j worms + for (int l = 0; l < j; l++) { // insert j worms insert(dw, 4 + n0, dtn[l], site, !n0, 0); WORM.push_back(wl->next[0]); wl->next[0]->dir = (int)(2 * MR->rdm()); - dw = wl->next[0]; - n0 = !n0; + dw = wl->next[0]; + n0 = !n0; } if (dw->type == 6) { @@ -779,12 +795,13 @@ void GraphSpace::Assign_Worm(My_rdm *MR) { } EVmax = ev.size(); - W[0] = WORM.size(); + W[0] = WORM.size(); } -void GraphSpace::parity_check(My_rdm *MR, int py, double *x, int &j, double topt, double bottomt) { - //j: # of worms in a segment - //py: parity +void GraphSpace::parity_check(My_rdm *MR, int py, double *x, int &j, + double topt, double bottomt) { + // j: # of worms in a segment + // py: parity double Il = topt - bottomt; double dt, dtmin = NMIN; double Ia = Il * P->rh_even; @@ -794,7 +811,8 @@ void GraphSpace::parity_check(My_rdm *MR, int py, double *x, int &j, double topt if (j != 0) { if (Il <= (double)(j + 1) * NMIN) { if (PR->my_rank == 0) - cout << "Il is too small: Il=" << Il << ", topt=" << topt << ", bottomt=" << bottomt << endl; + cout << "Il is too small: Il=" << Il << ", topt=" << topt + << ", bottomt=" << bottomt << endl; j = py % 2; if (Il <= (double)(j + 1) * NMIN) { if (PR->my_rank == 0) cout << "///Il has error" << endl; @@ -804,7 +822,7 @@ void GraphSpace::parity_check(My_rdm *MR, int py, double *x, int &j, double topt for (int i = 0; i < j; i++) { dt = Il * MR->rdm(); if (dt <= dtmin) { - dt = dtmin; + dt = dtmin; dtmin = dtmin + NMIN; } x[i] = bottomt + dt; @@ -821,12 +839,12 @@ int GraphSpace::NumberOfVertex(My_rdm *MR, double m, int py) { double R = MR->rdm(); double POW, EXP; - POW = (n) ? m : 1.0; + POW = (n) ? m : 1.0; int FAC = 1; - EXP = (this->*fmath[py])(m); + EXP = (this->*fmath[py])(m); while (1) { - FAC *= fn; //factorial( n ); + FAC *= fn; // factorial( n ); pos = POW / (double)FAC; Pn += pos; @@ -857,18 +875,19 @@ void GraphSpace::SpatialDomainBoundary(My_rdm *MR) { for (int i = 0; i < LT->Fx[d]; i++) { right = LT->frame_rsite[d][i]; - k = 0; - for (Vertex *wl = world[right].next[1]; wl != &(world[right]); wl = wl->next[1]) { //until worldB + k = 0; + for (Vertex *wl = world[right].next[1]; wl != &(world[right]); + wl = wl->next[1]) { // until worldB if (((wl->i) / V == d && wl->type <= -3 && wl->type >= -4) || next) { BoxSpace_t_th0[d][f(d, i, k)] = wl->t - wl->next[0]->t; - BoxSpace_py_th0[f(d, i, k)] = (short)wl->dir; + BoxSpace_py_th0[f(d, i, k)] = (short)wl->dir; if ((wl->i) / V != d || wl->type > -3 || wl->type < -4) { BoxSpace_type_th0[f(d, i, k)] = 7; - next = false; + next = false; } else { BoxSpace_type_th0[f(d, i, k)] = wl->type; - next = true; + next = true; } BoxSpace_p_th0[d][f(d, i, k)] = wl->p; k++; @@ -880,29 +899,37 @@ void GraphSpace::SpatialDomainBoundary(My_rdm *MR) { NewVertex_th0[d] = inmax * LT->Fx[d]; - MPI_Sendrecv(&(NewVertex_th0[d]), 1, MPI_INT, PR->left[d], 0, &(NewVertex_th1[d]), 1, MPI_INT, PR->right[d], 0, + MPI_Sendrecv(&(NewVertex_th0[d]), 1, MPI_INT, PR->left[d], 0, + &(NewVertex_th1[d]), 1, MPI_INT, PR->right[d], 0, MPI_COMM_WORLD, &status); - MPI_Sendrecv(&(BoxSpace_py_th0[0]), NewVertex_th0[d], MPI_SHORT, PR->left[d], 3, &(BoxSpace_py_th1[0]), - NewVertex_th1[d], MPI_SHORT, PR->right[d], 3, MPI_COMM_WORLD, &status); - MPI_Sendrecv(&(BoxSpace_p_th0[d][0]), NewVertex_th0[d], MPI_SHORT, PR->left[d], 1, &(BoxSpace_p_th1[d][0]), - NewVertex_th1[d], MPI_SHORT, PR->right[d], 1, MPI_COMM_WORLD, &status); - MPI_Sendrecv(&(BoxSpace_type_th0[0]), NewVertex_th0[d], MPI_SHORT, PR->left[d], 4, &(BoxSpace_type_th1[0]), - NewVertex_th1[d], MPI_SHORT, PR->right[d], 4, MPI_COMM_WORLD, &status); - MPI_Sendrecv(&(BoxSpace_t_th0[d][0]), NewVertex_th0[d], MPI_DOUBLE, PR->left[d], 2, &(BoxSpace_t_th1[d][0]), - NewVertex_th1[d], MPI_DOUBLE, PR->right[d], 2, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(BoxSpace_py_th0[0]), NewVertex_th0[d], MPI_SHORT, + PR->left[d], 3, &(BoxSpace_py_th1[0]), NewVertex_th1[d], + MPI_SHORT, PR->right[d], 3, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(BoxSpace_p_th0[d][0]), NewVertex_th0[d], MPI_SHORT, + PR->left[d], 1, &(BoxSpace_p_th1[d][0]), NewVertex_th1[d], + MPI_SHORT, PR->right[d], 1, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(BoxSpace_type_th0[0]), NewVertex_th0[d], MPI_SHORT, + PR->left[d], 4, &(BoxSpace_type_th1[0]), NewVertex_th1[d], + MPI_SHORT, PR->right[d], 4, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(BoxSpace_t_th0[d][0]), NewVertex_th0[d], MPI_DOUBLE, + PR->left[d], 2, &(BoxSpace_t_th1[d][0]), NewVertex_th1[d], + MPI_DOUBLE, PR->right[d], 2, MPI_COMM_WORLD, &status); for (int i = 0; i < LT->Fx[d]; i++) { rnum = 0; left = LT->frame_lsite[d][i]; - for (Vertex *wl = world[left].next[1]; wl != &(worldB[left]); wl = wl->next[1]) { - if ((wl->i) / V == d && (wl->type == -1 || wl->type == -2)) { // judge by the left + for (Vertex *wl = world[left].next[1]; wl != &(worldB[left]); + wl = wl->next[1]) { + if ((wl->i) / V == d && + (wl->type == -1 || wl->type == -2)) { // judge by the left while (BoxSpace_type_th1[f(d, i, rnum)] == 7) { rnum++; } - b = (wl->type == -2) ? BoxSpace_p_th1[d][f(d, i, rnum)] + 2 * wl->p : wl->p + 4; + b = (wl->type == -2) ? BoxSpace_p_th1[d][f(d, i, rnum)] + 2 * wl->p + : wl->p + 4; I1 = wl->t - wl->next[0]->t; I2 = wl->next[1]->t - wl->t; @@ -920,10 +947,12 @@ void GraphSpace::SpatialDomainBoundary(My_rdm *MR) { // int xl=LT->lx[left]; - PP[0] = (this->*Form[b][0])(I1, I2, I3, I4, py1, py2, py3, py4) * P->FracW[b][0][0]; + PP[0] = (this->*Form[b][0])(I1, I2, I3, I4, py1, py2, py3, py4) * + P->FracW[b][0][0]; for (a = 1; a < 6; a++) { - PP[a] = (this->*Form[b][a])(I1, I2, I3, I4, py1, py2, py3, py4) * P->FracW[b][a][0]; + PP[a] = (this->*Form[b][a])(I1, I2, I3, I4, py1, py2, py3, py4) * + P->FracW[b][a][0]; PP[a] += PP[a - 1]; } @@ -941,26 +970,30 @@ void GraphSpace::SpatialDomainBoundary(My_rdm *MR) { } } - MPI_Sendrecv(&(BoxSpace_p_th1[d][0]), NewVertex_th1[d], MPI_SHORT, PR->right[d], 0, &(BoxSpace_p_th0[d][0]), - NewVertex_th0[d], MPI_SHORT, PR->left[d], 0, MPI_COMM_WORLD, &status); - MPI_Sendrecv(&(BoxSpace_py_th1[0]), NewVertex_th1[d], MPI_SHORT, PR->right[d], 0, &(BoxSpace_py_th0[0]), - NewVertex_th0[d], MPI_SHORT, PR->left[d], 0, MPI_COMM_WORLD, &status); - MPI_Sendrecv(&(BoxSpace_type_th1[0]), NewVertex_th1[d], MPI_SHORT, PR->right[d], 0, &(BoxSpace_type_th0[0]), - NewVertex_th0[d], MPI_SHORT, PR->left[d], 0, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(BoxSpace_p_th1[d][0]), NewVertex_th1[d], MPI_SHORT, + PR->right[d], 0, &(BoxSpace_p_th0[d][0]), NewVertex_th0[d], + MPI_SHORT, PR->left[d], 0, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(BoxSpace_py_th1[0]), NewVertex_th1[d], MPI_SHORT, + PR->right[d], 0, &(BoxSpace_py_th0[0]), NewVertex_th0[d], + MPI_SHORT, PR->left[d], 0, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(BoxSpace_type_th1[0]), NewVertex_th1[d], MPI_SHORT, + PR->right[d], 0, &(BoxSpace_type_th0[0]), NewVertex_th0[d], + MPI_SHORT, PR->left[d], 0, MPI_COMM_WORLD, &status); next = false; for (int i = 0; i < LT->Fx[d]; i++) { right = LT->frame_rsite[d][i]; - k = 0; - for (Vertex *wl = world[right].next[1]; wl != &(world[right]); wl = wl->next[1]) { // until worldB + k = 0; + for (Vertex *wl = world[right].next[1]; wl != &(world[right]); + wl = wl->next[1]) { // until worldB if (((wl->i) / V == d && wl->type <= -3 && wl->type >= -4) || next) { wl->dir = BoxSpace_py_th0[f(d, i, k)]; if (BoxSpace_type_th0[f(d, i, k)] != 7) { wl->type = BoxSpace_type_th0[f(d, i, k)]; - wl->p = BoxSpace_p_th0[d][f(d, i, k)]; - next = true; + wl->p = BoxSpace_p_th0[d][f(d, i, k)]; + next = true; } else next = false; k++; @@ -971,30 +1004,33 @@ void GraphSpace::SpatialDomainBoundary(My_rdm *MR) { } void GraphSpace::TemporalDomainBoundary(My_rdm *MR, Quantities *QNT) { - //Here, P0 (P1) means the upper (lower) side interval than the temporal domain boundary. + // Here, P0 (P1) means the upper (lower) side interval than the temporal + // domain boundary. double R, P_i; bool py0, py1; double Om0, Om1; - double I0; //the length of the interval P0 - double I1; //the length of the interval P1 + double I0; // the length of the interval P0 + double I1; // the length of the interval P1 double exp0, exp1; - //MPI communication here. ( send information to the upper domain and receive from the lower domain. ) + // MPI communication here. ( send information to the upper domain and receive + // from the lower domain. ) OldBox(); //###### "the domain boundary (world)" is updated in P0 ###### for (int site = 0; site < V; site++) { - py0 = world[site].next[1]->dir; //the parity of P0 + py0 = world[site].next[1]->dir; // the parity of P0 py1 = (p0_box[site] + world[site].p) % 2; // the parity of P1. - I0 = world[site].next[1]->t; - I1 = i0_box[site]; + I0 = world[site].next[1]->t; + I1 = i0_box[site]; exp0 = exp(I0 * P->rh_even); exp1 = exp(I1 * P->rh_even); - //######################## calculation of , #################################### + //######################## calculation of , + //#################################### CondensateFraction(site, QNT, py0, py1, exp0, exp1); //############################################################ @@ -1003,15 +1039,15 @@ void GraphSpace::TemporalDomainBoundary(My_rdm *MR, Quantities *QNT) { Om0 = (this->*fexp[!py0])(exp0) / (this->*fexp[py0])(exp0); Om1 = (this->*fexp[!py1])(exp1) / (this->*fexp[py1])(exp1); - R = MR->rdm(); + R = MR->rdm(); P_i = Om0 * Om1; - if (P_i > R) { //update the temporal domain boundary. + if (P_i > R) { // update the temporal domain boundary. world[site].next[1]->dir = !(py0); - p0_box[site] = !(py1); - py0 = world[site].p; - world[site].p = !py0; + p0_box[site] = !(py1); + py0 = world[site].p; + world[site].p = !py0; } } @@ -1027,24 +1063,24 @@ void GraphSpace::OldBox() { MPI_Status status; - MPI_Sendrecv(&(p1_box[0]), V, MPI_SHORT, PR->upper, 0, &(p0_box[0]), V, MPI_SHORT, PR->lower, 0, MPI_COMM_WORLD, - &status); - MPI_Sendrecv(&(i1_box[0]), V, MPI_DOUBLE, PR->upper, 0, &(i0_box[0]), V, MPI_DOUBLE, PR->lower, 0, MPI_COMM_WORLD, - &status); + MPI_Sendrecv(&(p1_box[0]), V, MPI_SHORT, PR->upper, 0, &(p0_box[0]), V, + MPI_SHORT, PR->lower, 0, MPI_COMM_WORLD, &status); + MPI_Sendrecv(&(i1_box[0]), V, MPI_DOUBLE, PR->upper, 0, &(i0_box[0]), V, + MPI_DOUBLE, PR->lower, 0, MPI_COMM_WORLD, &status); } void GraphSpace::NewBox() { MPI_Status status; - MPI_Sendrecv(&(p0_box[0]), V, MPI_SHORT, PR->lower, 0, &(p1_box[0]), V, MPI_SHORT, PR->upper, 0, MPI_COMM_WORLD, - &status); + MPI_Sendrecv(&(p0_box[0]), V, MPI_SHORT, PR->lower, 0, &(p1_box[0]), V, + MPI_SHORT, PR->upper, 0, MPI_COMM_WORLD, &status); - for (int site = 0; site < V; site++) - worldB[site].dir = p1_box[site]; + for (int site = 0; site < V; site++) worldB[site].dir = p1_box[site]; } -void GraphSpace::CondensateFraction(int site, Quantities *QNT, bool py0, bool py1, double exp0, double exp1) { - //0:upper, 1:lower +void GraphSpace::CondensateFraction(int site, Quantities *QNT, bool py0, + bool py1, double exp0, double exp1) { + // 0:upper, 1:lower bool cf; double Ra, Rc, Rca, Rac, norm; @@ -1054,8 +1090,8 @@ void GraphSpace::CondensateFraction(int site, Quantities *QNT, bool py0, bool py cf = (PY + p0_box[site]) % 2; - Ra = (this->*fexp[!(p0_box[site])])(exp1) * (this->*fexp[cf])(exp0); - Rc = (this->*fexp[p0_box[site]])(exp1) * (this->*fexp[!cf])(exp0); + Ra = (this->*fexp[!(p0_box[site])])(exp1) * (this->*fexp[cf])(exp0); + Rc = (this->*fexp[p0_box[site]])(exp1) * (this->*fexp[!cf])(exp0); Rca = (this->*fexp[!(p0_box[site])])(exp1) * (this->*fexp[!cf])(exp0); Rac = (this->*fexp[p0_box[site]])(exp1) * (this->*fexp[cf])(exp0); diff --git a/src/pmwa/inc/Configuration.h b/src/pmwa/inc/Configuration.h index e062559d..e6bc8cc8 100644 --- a/src/pmwa/inc/Configuration.h +++ b/src/pmwa/inc/Configuration.h @@ -1,24 +1,23 @@ #ifndef CONFIGURATION_H #define CONFIGURATION_H -#include - #include #include +#include +#include #include +#include +#include + +#include #include -#include #include - +#include +#include #include #include -#include -#include -#include -#include "mpi.h" -#include -#include +#include "mpi.h" #define G_NMIN 1.0e-8 #define NSAMPLE 100000 @@ -29,13 +28,12 @@ using namespace XML; #include - class Quantities; class Probability; class GraphSpace { -public: + public: double NMIN; double msh(double); @@ -54,17 +52,20 @@ class GraphSpace { // worm, an onsite vertex, moves with reconnection of bidirectional list class Vertex { - public: - double t; //imaginary time - short p; //the number of bosons - int i; //bond index = site + d*V + public: + double t; // imaginary time + short p; // the number of bosons + int i; // bond index = site + d*V short type; - // -5: temporal edge, -2(left),-4(right),:inter-domain vertex, -1(l),-3(r),:inter-domain kink, - // 0:on-site, 1: 2-site vertex, 2:kink, 3:2site-vertex(second nearest), 4:active "annihilation"-worm, 5:active "creation"-worm, 6:nonactive worm or other, 7:marker - bool dir; //for worm, moving direction. for vertex, parity. - - Vertex *next[2]; //doubly-linked list - Vertex *nleg; //the opposite side of the 2-site vertex. + // -5: temporal edge, -2(left),-4(right),:inter-domain vertex, + // -1(l),-3(r),:inter-domain kink, + // 0:on-site, 1: 2-site vertex, 2:kink, 3:2site-vertex(second nearest), + // 4:active "annihilation"-worm, 5:active "creation"-worm, 6:nonactive + // worm or other, 7:marker + bool dir; // for worm, moving direction. for vertex, parity. + + Vertex *next[2]; // doubly-linked list + Vertex *nleg; // the opposite side of the 2-site vertex. }; Parallel *PR; @@ -83,7 +84,7 @@ class GraphSpace { short sgn[2]; double rtb_i, rt_i, rtb_tot, rt_tot, rt_frame, rtot; - double Pv1, PBv1; + double Pv1, PBv1; double Wlen; long Ncyc; int Nv, Nk, Nu; @@ -111,22 +112,23 @@ class GraphSpace { std::string LATFILE; std::string ALGFILE; -public: - GraphSpace(Size *N, int m_nmax, Lattice *m_LT, Probability *m_P, Parallel *PR, long long m_IMAX, long long m_WMAX, - std::string const& m_Eventfile, My_rdm *MR, int cb, std::string const& m_outfile); + public: + GraphSpace(Size *N, int m_nmax, Lattice *m_LT, Probability *m_P, Parallel *PR, + long long m_IMAX, long long m_WMAX, std::string const &m_Eventfile, + My_rdm *MR, int cb, std::string const &m_outfile); ~GraphSpace(); void Output(std::string const &fname, My_rdm *MR); -protected: + protected: void Worm_Update(My_rdm *MR); bool Diagonal_Update(My_rdm *MR, Quantities *QNT); void DLA_Update(My_rdm *MR); -private: + private: double *dtn; Vertex **w; @@ -155,7 +157,7 @@ class GraphSpace { double *ver_time; int *INmax; // the number of segments at site i - double *I, *t, tA; + double *I, *t, tA; // t[1]| |t[2] // |----| // t[0]| |t[3] @@ -164,7 +166,7 @@ class GraphSpace { // world: (x coordinate , y coordinate) // Box: (coordinate, vertex) - //worm + // worm bool Next_event(My_rdm *MR); void transition(My_rdm *MR); @@ -197,10 +199,12 @@ class GraphSpace { void turn(bool oh, bool dir, int b, int a, double dla); - void (GraphSpace::*Transition[4])(bool oh, bool dir, int b, int a, double dla); + void (GraphSpace::*Transition[4])(bool oh, bool dir, int b, int a, + double dla); - //vertex - void initialev(std::string const& m_Eventfile, My_rdm *MR, int cb, double oldB); + // vertex + void initialev(std::string const &m_Eventfile, My_rdm *MR, int cb, + double oldB); void Remove_Vertex(); @@ -216,11 +220,13 @@ class GraphSpace { void connect_after(Vertex **wl, Vertex *el, int x); - void parity_check(My_rdm *MR, int py, double *x, int &j, double topt, double bottomt); + void parity_check(My_rdm *MR, int py, double *x, int &j, double topt, + double bottomt); int NumberOfVertex(My_rdm *MR, double m, int py); - void CondensateFraction(int site, Quantities *QNT, bool py0, bool py1, double exp0, double exp1); + void CondensateFraction(int site, Quantities *QNT, bool py0, bool py1, + double exp0, double exp1); void OldBox(); @@ -228,19 +234,21 @@ class GraphSpace { void release(Vertex *wx); - void insert(Vertex *vl, Vertex *vr, short type, double targ_time, int xl, int xr, int pl, int pr, int d); + void insert(Vertex *vl, Vertex *vr, short type, double targ_time, int xl, + int xr, int pl, int pr, int d); void insert(Vertex *v, short type, double targ_time, int xl, int pl, int d); - void insert_NewEvent(Vertex *v, int new_type, double new_time, int xx, int px, int d); + void insert_NewEvent(Vertex *v, int new_type, double new_time, int xx, int px, + int d); - void Renew_Vertex(Vertex *v, int new_type, double new_time, int xx, int px, int d); + void Renew_Vertex(Vertex *v, int new_type, double new_time, int xx, int px, + int d); void relink(Vertex *v1, Vertex *v2, Vertex *v3); void initial_functions(); - void (GraphSpace::*Parity_Update[6][6])(Vertex *wl, int d, int i, int rnum); void All(Vertex *wl, int d, int i, int rnum); @@ -271,23 +279,32 @@ class GraphSpace { void t10(Vertex *wl, int d, int i, int rnum); - double (GraphSpace::*Form[6][6])(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4); + double (GraphSpace::*Form[6][6])(double I1, double I2, double I3, double I4, + bool py1, bool py2, bool py3, bool py4); - double P_All(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4); + double P_All(double I1, double I2, double I3, double I4, bool py1, bool py2, + bool py3, bool py4); - double P_Right(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4); + double P_Right(double I1, double I2, double I3, double I4, bool py1, bool py2, + bool py3, bool py4); - double P_Left(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4); + double P_Left(double I1, double I2, double I3, double I4, bool py1, bool py2, + bool py3, bool py4); - double P_LuRu(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4); + double P_LuRu(double I1, double I2, double I3, double I4, bool py1, bool py2, + bool py3, bool py4); - double P_LdRd(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4); + double P_LdRd(double I1, double I2, double I3, double I4, bool py1, bool py2, + bool py3, bool py4); - double P_LdRu(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4); + double P_LdRu(double I1, double I2, double I3, double I4, bool py1, bool py2, + bool py3, bool py4); - double P_LuRd(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4); + double P_LuRd(double I1, double I2, double I3, double I4, bool py1, bool py2, + bool py3, bool py4); - double P_Stay(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4); + double P_Stay(double I1, double I2, double I3, double I4, bool py1, bool py2, + bool py3, bool py4); void SpatialDomainBoundary(My_rdm *MR); @@ -308,11 +325,13 @@ class Configuration : public GraphSpace { int p_num; MC_p *MC; -public: + public: void dump(ofstream &F); - Configuration(MC_p *m_MC, Size *N, int m_nmax, Lattice *m_LT, Probability *m_P, Parallel *PR, long long m_IMAX, - long long m_WMAX, std::string const& m_Eventfile, My_rdm *MR, bool cb, std::string const& m_outfile); + Configuration(MC_p *m_MC, Size *N, int m_nmax, Lattice *m_LT, + Probability *m_P, Parallel *PR, long long m_IMAX, + long long m_WMAX, std::string const &m_Eventfile, My_rdm *MR, + bool cb, std::string const &m_outfile); ~Configuration(); diff --git a/src/pmwa/inc/Graph_functions.h b/src/pmwa/inc/Graph_functions.h index 99f3aafb..4f58d954 100644 --- a/src/pmwa/inc/Graph_functions.h +++ b/src/pmwa/inc/Graph_functions.h @@ -2,18 +2,18 @@ #include "Probability.h" void GraphSpace::initial_functions() { - fexp[0] = &GraphSpace::mch; - fexp[1] = &GraphSpace::msh; - fmath[0] = &GraphSpace::mcosh; - fmath[1] = &GraphSpace::msinh; + fexp[0] = &GraphSpace::mch; + fexp[1] = &GraphSpace::msh; + fmath[0] = &GraphSpace::mcosh; + fmath[1] = &GraphSpace::msinh; Transition[0] = &GraphSpace::bounce; Transition[1] = &GraphSpace::pass; Transition[2] = &GraphSpace::hop; Transition[3] = &GraphSpace::turn; - for (int i = 0; i < 6; i++) - Form[i][i] = &GraphSpace::P_Stay; - Form[0][3] = Form[3][0] = Form[1][2] = Form[2][1] = Form[4][5] = Form[5][4] = &GraphSpace::P_All; + for (int i = 0; i < 6; i++) Form[i][i] = &GraphSpace::P_Stay; + Form[0][3] = Form[3][0] = Form[1][2] = Form[2][1] = Form[4][5] = Form[5][4] = + &GraphSpace::P_All; Form[0][1] = Form[1][0] = &GraphSpace::P_Right; Form[2][3] = Form[3][2] = &GraphSpace::P_Right; @@ -33,8 +33,9 @@ void GraphSpace::initial_functions() { Form[0][4] = Form[4][0] = &GraphSpace::P_LdRu; Form[3][5] = Form[5][3] = &GraphSpace::P_LdRu; - Parity_Update[0][3] = Parity_Update[3][0] = Parity_Update[1][2] = Parity_Update[2][1] = Parity_Update[4][5] = - Parity_Update[5][4] = &GraphSpace::All; + Parity_Update[0][3] = Parity_Update[3][0] = Parity_Update[1][2] = + Parity_Update[2][1] = Parity_Update[4][5] = Parity_Update[5][4] = + &GraphSpace::All; Parity_Update[0][1] = Parity_Update[1][0] = &GraphSpace::Right; Parity_Update[2][3] = Parity_Update[3][2] = &GraphSpace::Right; @@ -72,15 +73,17 @@ double GraphSpace::mcosh(double D) { return cosh(D); } //####################################################################################################### -double GraphSpace::P_Stay(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4) { +double GraphSpace::P_Stay(double I1, double I2, double I3, double I4, bool py1, + bool py2, bool py3, bool py4) { return 1.0; } -double GraphSpace::P_All(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4) { - double fth1 = I1; //tanh(I1*P->rh_even); - double fth2 = I2; //tanh(I2*P->rh_even); - double fth3 = I3; //tanh(I3*P->rh_even); - double fth4 = I4; //tanh(I4*P->rh_even); +double GraphSpace::P_All(double I1, double I2, double I3, double I4, bool py1, + bool py2, bool py3, bool py4) { + double fth1 = I1; // tanh(I1*P->rh_even); + double fth2 = I2; // tanh(I2*P->rh_even); + double fth3 = I3; // tanh(I3*P->rh_even); + double fth4 = I4; // tanh(I4*P->rh_even); if (py1) fth1 = 1.0 / fth1; if (py2) fth2 = 1.0 / fth2; @@ -90,9 +93,10 @@ double GraphSpace::P_All(double I1, double I2, double I3, double I4, bool py1, b return fth1 * fth2 * fth3 * fth4; } -double GraphSpace::P_Right(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4) { - double fth3 = I3; //tanh(I3*P->rh_even); - double fth4 = I4; //tanh(I4*P->rh_even); +double GraphSpace::P_Right(double I1, double I2, double I3, double I4, bool py1, + bool py2, bool py3, bool py4) { + double fth3 = I3; // tanh(I3*P->rh_even); + double fth4 = I4; // tanh(I4*P->rh_even); if (py3) fth3 = 1.0 / fth3; if (py4) fth4 = 1.0 / fth4; @@ -100,9 +104,10 @@ double GraphSpace::P_Right(double I1, double I2, double I3, double I4, bool py1, return fth3 * fth4; } -double GraphSpace::P_Left(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4) { - double fth1 = I1; //tanh(I1*P->rh_even); - double fth2 = I2; //tanh(I2*P->rh_even); +double GraphSpace::P_Left(double I1, double I2, double I3, double I4, bool py1, + bool py2, bool py3, bool py4) { + double fth1 = I1; // tanh(I1*P->rh_even); + double fth2 = I2; // tanh(I2*P->rh_even); if (py1) fth1 = 1.0 / fth1; if (py2) fth2 = 1.0 / fth2; @@ -110,9 +115,10 @@ double GraphSpace::P_Left(double I1, double I2, double I3, double I4, bool py1, return fth1 * fth2; } -double GraphSpace::P_LuRd(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4) { - double fth2 = I2; //tanh(I2*P->rh_even); - double fth4 = I4; //tanh(I4*P->rh_even); +double GraphSpace::P_LuRd(double I1, double I2, double I3, double I4, bool py1, + bool py2, bool py3, bool py4) { + double fth2 = I2; // tanh(I2*P->rh_even); + double fth4 = I4; // tanh(I4*P->rh_even); if (py2) fth2 = 1.0 / fth2; if (py4) fth4 = 1.0 / fth4; @@ -120,9 +126,10 @@ double GraphSpace::P_LuRd(double I1, double I2, double I3, double I4, bool py1, return fth2 * fth4; } -double GraphSpace::P_LdRu(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4) { - double fth1 = I1; //tanh(I1*P->rh_even); - double fth3 = I3; //tanh(I3*P->rh_even); +double GraphSpace::P_LdRu(double I1, double I2, double I3, double I4, bool py1, + bool py2, bool py3, bool py4) { + double fth1 = I1; // tanh(I1*P->rh_even); + double fth3 = I3; // tanh(I3*P->rh_even); if (py1) fth1 = 1.0 / fth1; if (py3) fth3 = 1.0 / fth3; @@ -130,9 +137,10 @@ double GraphSpace::P_LdRu(double I1, double I2, double I3, double I4, bool py1, return fth1 * fth3; } -double GraphSpace::P_LuRu(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4) { - double fth2 = I2; //tanh(I2*P->rh_even); - double fth3 = I3; //tanh(I3*P->rh_even); +double GraphSpace::P_LuRu(double I1, double I2, double I3, double I4, bool py1, + bool py2, bool py3, bool py4) { + double fth2 = I2; // tanh(I2*P->rh_even); + double fth3 = I3; // tanh(I3*P->rh_even); if (py2) fth2 = 1.0 / fth2; if (py3) fth3 = 1.0 / fth3; @@ -140,9 +148,10 @@ double GraphSpace::P_LuRu(double I1, double I2, double I3, double I4, bool py1, return fth2 * fth3; } -double GraphSpace::P_LdRd(double I1, double I2, double I3, double I4, bool py1, bool py2, bool py3, bool py4) { - double fth1 = I1; //tanh(I1*P->rh_even); - double fth4 = I4; //tanh(I4*P->rh_even); +double GraphSpace::P_LdRd(double I1, double I2, double I3, double I4, bool py1, + bool py2, bool py3, bool py4) { + double fth1 = I1; // tanh(I1*P->rh_even); + double fth4 = I4; // tanh(I4*P->rh_even); if (py1) fth1 = 1.0 / fth1; if (py4) fth4 = 1.0 / fth4; @@ -153,81 +162,85 @@ double GraphSpace::P_LdRd(double I1, double I2, double I3, double I4, bool py1, //####################################################################################################### void GraphSpace::All(Vertex *wl, int d, int i, int rnum) { - wl->dir = !wl->dir; - wl->next[1]->dir = !wl->next[1]->dir; - BoxSpace_py_th1[f(d, i, rnum + 1)] = !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); - BoxSpace_py_th1[f(d, i, rnum)] = !((bool)BoxSpace_py_th1[f(d, i, rnum)]); + wl->dir = !wl->dir; + wl->next[1]->dir = !wl->next[1]->dir; + BoxSpace_py_th1[f(d, i, rnum + 1)] = + !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); + BoxSpace_py_th1[f(d, i, rnum)] = !((bool)BoxSpace_py_th1[f(d, i, rnum)]); } void GraphSpace::Right(Vertex *wl, int d, int i, int rnum) { - BoxSpace_py_th1[f(d, i, rnum + 1)] = !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); - BoxSpace_py_th1[f(d, i, rnum)] = !((bool)BoxSpace_py_th1[f(d, i, rnum)]); + BoxSpace_py_th1[f(d, i, rnum + 1)] = + !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); + BoxSpace_py_th1[f(d, i, rnum)] = !((bool)BoxSpace_py_th1[f(d, i, rnum)]); } void GraphSpace::Left(Vertex *wl, int d, int i, int rnum) { - wl->dir = !wl->dir; + wl->dir = !wl->dir; wl->next[1]->dir = !wl->next[1]->dir; } void GraphSpace::LdRu(Vertex *wl, int d, int i, int rnum) { - wl->dir = !wl->dir; - BoxSpace_py_th1[f(d, i, rnum + 1)] = !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); + wl->dir = !wl->dir; + BoxSpace_py_th1[f(d, i, rnum + 1)] = + !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); } void GraphSpace::LuRd(Vertex *wl, int d, int i, int rnum) { - wl->next[1]->dir = !wl->next[1]->dir; + wl->next[1]->dir = !wl->next[1]->dir; BoxSpace_py_th1[f(d, i, rnum)] = !((bool)BoxSpace_py_th1[f(d, i, rnum)]); } void GraphSpace::LuRu(Vertex *wl, int d, int i, int rnum) { - wl->next[1]->dir = !wl->next[1]->dir; - BoxSpace_py_th1[f(d, i, rnum + 1)] = !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); + wl->next[1]->dir = !wl->next[1]->dir; + BoxSpace_py_th1[f(d, i, rnum + 1)] = + !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); } void GraphSpace::LdRd(Vertex *wl, int d, int i, int rnum) { - wl->dir = !wl->dir; + wl->dir = !wl->dir; BoxSpace_py_th1[f(d, i, rnum)] = !((bool)BoxSpace_py_th1[f(d, i, rnum)]); } //####################################################################################################### void GraphSpace::a00(Vertex *wl, int d, int i, int rnum) { - wl->type = -2; + wl->type = -2; BoxSpace_type_th1[f(d, i, rnum)] = -4; - wl->p = 0; + wl->p = 0; BoxSpace_p_th1[d][f(d, i, rnum)] = 0; } void GraphSpace::a01(Vertex *wl, int d, int i, int rnum) { - wl->type = -2; + wl->type = -2; BoxSpace_type_th1[f(d, i, rnum)] = -4; - wl->p = 0; + wl->p = 0; BoxSpace_p_th1[d][f(d, i, rnum)] = 1; } void GraphSpace::a10(Vertex *wl, int d, int i, int rnum) { - wl->type = -2; + wl->type = -2; BoxSpace_type_th1[f(d, i, rnum)] = -4; - wl->p = 1; + wl->p = 1; BoxSpace_p_th1[d][f(d, i, rnum)] = 0; } void GraphSpace::a11(Vertex *wl, int d, int i, int rnum) { - wl->type = -2; + wl->type = -2; BoxSpace_type_th1[f(d, i, rnum)] = -4; - wl->p = 1; + wl->p = 1; BoxSpace_p_th1[d][f(d, i, rnum)] = 1; } void GraphSpace::t01(Vertex *wl, int d, int i, int rnum) { - wl->type = -1; + wl->type = -1; BoxSpace_type_th1[f(d, i, rnum)] = -3; - wl->p = 0; + wl->p = 0; BoxSpace_p_th1[d][f(d, i, rnum)] = 1; } void GraphSpace::t10(Vertex *wl, int d, int i, int rnum) { - wl->type = -1; + wl->type = -1; BoxSpace_type_th1[f(d, i, rnum)] = -3; - wl->p = 1; + wl->p = 1; BoxSpace_p_th1[d][f(d, i, rnum)] = 0; } diff --git a/src/pmwa/inc/PMWA.h b/src/pmwa/inc/PMWA.h index 59319ab5..261d136c 100644 --- a/src/pmwa/inc/PMWA.h +++ b/src/pmwa/inc/PMWA.h @@ -1,54 +1,51 @@ #ifndef PMWA_H #define PMWA_H -#include -#include - #include #include +#include +#include + namespace pmwa_para { - enum sim { - RUN_TYPE, - N_SET, - N_MCSE, - N_MCSD, - N_MCS, - N_TEST, - N_SEED, - N_VERMAX, - N_WORMAX, - N_PARA_SIM - }; - enum file { - ALG_FILE = N_PARA_SIM, - LAT_FILE, - SF_INPFILE, - OUT_FILE, - SF_OUT_FILE, - N_PARA_FILE - }; - enum model { - G = N_PARA_FILE, - UBB, - VB1, - TB, - MU, - CB, - BETA, - OLD_BETA, - N_PARA_MODEL - }; - enum other { - N_MAX = N_PARA_MODEL, - NUMPARA - }; +enum sim { + RUN_TYPE, + N_SET, + N_MCSE, + N_MCSD, + N_MCS, + N_TEST, + N_SEED, + N_VERMAX, + N_WORMAX, + N_PARA_SIM +}; +enum file { + ALG_FILE = N_PARA_SIM, + LAT_FILE, + SF_INPFILE, + OUT_FILE, + SF_OUT_FILE, + N_PARA_FILE +}; +enum model { + G = N_PARA_FILE, + UBB, + VB1, + TB, + MU, + CB, + BETA, + OLD_BETA, + N_PARA_MODEL }; +enum other { N_MAX = N_PARA_MODEL, NUMPARA }; +}; // namespace pmwa_para ////////////////////////////////////////////////////////////////////////////////////////// class Dla { -private: + private: Size N; System sp; MC_p MC; @@ -82,31 +79,37 @@ class Dla { void NameOutfiles(); - enum{ Normal, Restart}; //for runtype + enum { Normal, Restart }; // for runtype -public: + public: double PMWA(); Dla(int NP, char **PLIST); ~Dla(); -private: + private: inline void show_MPIP() { - cout << "MPI check ---> rank= " << PR.my_rank << ", V= " << PR.V << " B= " << PR.B << ", Nx= " << PR.x - << ", Ny= " << PR.y << ", Nz= " << PR.z << ",, nt= " << PR.nt << ", nx= " << PR.nx << ", ny= " << PR.ny - << ", nz= " << PR.nz << ", up= " << PR.upper << ", lower= " << PR.lower << ", right(x)= " << PR.right[0] - << ", left(x)= " << PR.left[0] << ", right(y)= " << PR.right[1] << ", left(y)= " << PR.left[1] << endl; + cout << "MPI check ---> rank= " << PR.my_rank << ", V= " << PR.V + << " B= " << PR.B << ", Nx= " << PR.x << ", Ny= " << PR.y + << ", Nz= " << PR.z << ",, nt= " << PR.nt << ", nx= " << PR.nx + << ", ny= " << PR.ny << ", nz= " << PR.nz << ", up= " << PR.upper + << ", lower= " << PR.lower << ", right(x)= " << PR.right[0] + << ", left(x)= " << PR.left[0] << ", right(y)= " << PR.right[1] + << ", left(y)= " << PR.left[1] << endl; }; inline void show_SP() { - std::cout << "step =" << MC.Nstep << " thermal=" << MC.Nthermal << " bin=" << MC.Nbin << " B=" << N.B - << ", Nx=" << N.x << ", Ny=" << N.y << " Nz=" << N.z << " IMAX=" << IMAX << " WMAX=" << WMAX - << " U=" << sp.Ubb << " V=" << sp.Vb1 << " Ntest =" << MC.Ntest << " Nsample=" << MC.Nsample - << " nc=" << MC.nc << " t=" << sp.tb << " mu=" << sp.mu << " seed =" << MC.seed - << " nmax=" << sp.nmax << " Nd=" << N.d << " Htr=" << sp.Htr - << " Ntvid=" << PR.Ntdiv << " Npara=" << PR.Npara << " Nsdiv=" << PR.Nsdiv << " outfile=" << outfile - << std::endl; + std::cout << "step =" << MC.Nstep << " thermal=" << MC.Nthermal + << " bin=" << MC.Nbin << " B=" << N.B << ", Nx=" << N.x + << ", Ny=" << N.y << " Nz=" << N.z << " IMAX=" << IMAX + << " WMAX=" << WMAX << " U=" << sp.Ubb << " V=" << sp.Vb1 + << " Ntest =" << MC.Ntest << " Nsample=" << MC.Nsample + << " nc=" << MC.nc << " t=" << sp.tb << " mu=" << sp.mu + << " seed =" << MC.seed << " nmax=" << sp.nmax << " Nd=" << N.d + << " Htr=" << sp.Htr << " Ntvid=" << PR.Ntdiv + << " Npara=" << PR.Npara << " Nsdiv=" << PR.Nsdiv + << " outfile=" << outfile << std::endl; }; inline void show_TIME() { diff --git a/src/pmwa/inc/Probability.h b/src/pmwa/inc/Probability.h index 118d0772..023d41cc 100644 --- a/src/pmwa/inc/Probability.h +++ b/src/pmwa/inc/Probability.h @@ -2,14 +2,14 @@ #define PROB_H #include -#include #include +#include class Probability { int nmax, XMAX; double Ubb, V1, z; -public: + public: double tb, local_Et, rtmax, dim, *rumax, *local_Eu; double rh_odd, rh_even; @@ -30,14 +30,14 @@ class Probability { //################################################### class Omega { - public: + public: double val; int num; bool off; int i; }; -private: + private: Parallel *PR; int Nx; diff --git a/src/pmwa/inc/Quantities.h b/src/pmwa/inc/Quantities.h index 40360c71..3e9c676f 100644 --- a/src/pmwa/inc/Quantities.h +++ b/src/pmwa/inc/Quantities.h @@ -8,7 +8,7 @@ using namespace XML; class Quantities { // public: -private: + private: #ifdef SF XML::Block X; #endif @@ -57,7 +57,24 @@ class Quantities { int Cknum; int NVMAX, NWMAX; - enum { nver1, nwor1, nkin1, wndx1, wndy1, wndz1, amzu1, smzs1, smzu1, bmz1, xmzs1, magx1, magp1, magm1, ang1, Nq1 }; + enum { + nver1, + nwor1, + nkin1, + wndx1, + wndy1, + wndz1, + amzu1, + smzs1, + smzu1, + bmz1, + xmzs1, + magx1, + magp1, + magm1, + ang1, + Nq1 + }; enum { nver, nwor, @@ -118,16 +135,22 @@ class Quantities { }*/ inline int f_gk2r(int k, int k_) { return k + k_ * Nkxmax + Lsum[ck4 - 1]; } - inline int f_gk2i(int k, int k_) { return k + k_ * Nkxmax + Lsum[ck4 - 1] + Nkkmax * Nkxmax; } + inline int f_gk2i(int k, int k_) { + return k + k_ * Nkxmax + Lsum[ck4 - 1] + Nkkmax * Nkxmax; + } inline int f_noise(int k, int k_) { return k + k_ * Nkxmax + Lsum[dkk - 1]; } - inline int f_ck(int k, int num, int a) { return 5 + k + num * Nkmax + a * Nkmax * Cknum; }; + inline int f_ck(int k, int num, int a) { + return 5 + k + num * Nkmax + a * Nkmax * Cknum; + }; inline int f_ck(int k, int num) { return 5 + k + num * Nkmax; }; // inline int theta(int i, int k){ return i+(k+Nkxmax)*V; }; - inline int theta(int i, int k, int a) { return i + (k + (2 * a + 1) * Nkmax) * V; } + inline int theta(int i, int k, int a) { + return i + (k + (2 * a + 1) * Nkmax) * V; + } int *Lmax, *Lsum; @@ -163,11 +186,14 @@ class Quantities { void show_L(); - void RNDsum(double *local, double *global, int Ndiv, int my_rank, int rmax2, int Npara, int); + void RNDsum(double *local, double *global, int Ndiv, int my_rank, int rmax2, + int Npara, int); - void TreeSum(int num, double *child, double Normalization, int cnum, int mnum, int Nsum); + void TreeSum(int num, double *child, double Normalization, int cnum, int mnum, + int Nsum); - void TreeSum(int num, double *child, double *mother, double Normalization, int cnum, int mnum, int Nsum); + void TreeSum(int num, double *child, double *mother, double Normalization, + int cnum, int mnum, int Nsum); int V, Nx, NUM; System *sp; @@ -193,7 +219,7 @@ class Quantities { double SFD_Norm; double cr0, an0; -public: + public: #ifdef SF int Ntau; int Ntau1; @@ -228,7 +254,8 @@ class Quantities { char parainfo[64]; - Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Parallel *m_PR, std::string const &sfinfile); + Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Parallel *m_PR, + std::string const &sfinfile); ~Quantities(); @@ -236,8 +263,9 @@ class Quantities { void Output(std::string const &fname, double g); - void Measure(int Nv, int Nk, vector &ev, vector WORM, - GraphSpace::Vertex *world, GraphSpace::Vertex *worldB, double length, int m_Wnum, int mcs); + void Measure(int Nv, int Nk, vector &ev, + vector WORM, GraphSpace::Vertex *world, + GraphSpace::Vertex *worldB, double length, int m_Wnum, int mcs); void Measure(); diff --git a/src/pmwa/inc/debug.hpp b/src/pmwa/inc/debug.hpp index a9c2df94..e133e1b3 100644 --- a/src/pmwa/inc/debug.hpp +++ b/src/pmwa/inc/debug.hpp @@ -1,21 +1,23 @@ #ifndef PMWA_DEBUG_H #define PMWA_DEBUG_H +#include + #include -#include +class AutoPlog_impl { + std::string message; + std::string funcname; + int line; -class AutoPlog_impl{ - std::string message; - std::string funcname; - int line; -public: - AutoPlog_impl(std::string const &msg, std::string const &f, int l):message(msg), funcname(f), line(l){ - LOGD << message << "> Start. (" << funcname << "@" << line << ")"; - } - ~AutoPlog_impl(){ - LOGD << message << "> End. (" << funcname << "@" << line << ")"; - } + public: + AutoPlog_impl(std::string const &msg, std::string const &f, int l) + : message(msg), funcname(f), line(l) { + LOGD << message << "> Start. (" << funcname << "@" << line << ")"; + } + ~AutoPlog_impl() { + LOGD << message << "> End. (" << funcname << "@" << line << ")"; + } }; // we should expand macro twice to expand __LINE__ properly. @@ -26,4 +28,4 @@ class AutoPlog_impl{ #define NameValue(name) #name << " = " << (name) -#endif // PMWA_DEBUG_H +#endif // PMWA_DEBUG_H diff --git a/src/pmwa/inc/lattice.hpp b/src/pmwa/inc/lattice.hpp index 8c6dff09..2c741ad1 100644 --- a/src/pmwa/inc/lattice.hpp +++ b/src/pmwa/inc/lattice.hpp @@ -5,81 +5,74 @@ #include #include -#include -#include -#include - #include #include +#include +#include +#include #include //###################################################################### class Lattice { - -private: - - // Site* site; // the list of the poiters to sites - // Interaction* interaction; // the list of the pointers to interactions - XML::Block X; - // Algorithm& ALG; - -public: - - int D; // dimension - int L[4]; - double BETA; // inverse temperature - double oldBETA; //for annealing - int NCELL; // total number of cells - int NSITE; // total number of sites - int NINT; // total number of interactions - int NSTYPE; // number of site types - int NITYPE; // number of interaction types - int NLdiv; - int NBdiv; - int NFIELD; - Size *N; - - ////domain/// - Parallel *PR; - int V, Nx, Ny, Nz; - double B; - ///////////// - - int **bd, bnum, lc, TB, *lx; - double **bond_vec; - - bool **frame; - int Pd; - int *Fx; - int **frame_lsite; - int **frame_lnum; - int **frame_rsite; - int **frame_rnum; - - int rmax; - - Lattice(const char *FNAME); - Lattice(std::string const& FNAME); - - ~Lattice(); - - void dump(); - - void show_param(std::ofstream &F); - - int countVertices(); - - void make_Size(Size *N); - void make_Parallel(Parallel *PR); - void set_beta(double beta); - void set_oldbeta(double oldbeta); - -private: - - void read(); - + private: + // Site* site; // the list of the poiters to sites + // Interaction* interaction; // the list of the pointers to interactions + XML::Block X; + // Algorithm& ALG; + + public: + int D; // dimension + int L[4]; + double BETA; // inverse temperature + double oldBETA; // for annealing + int NCELL; // total number of cells + int NSITE; // total number of sites + int NINT; // total number of interactions + int NSTYPE; // number of site types + int NITYPE; // number of interaction types + int NLdiv; + int NBdiv; + int NFIELD; + Size *N; + + ////domain/// + Parallel *PR; + int V, Nx, Ny, Nz; + double B; + ///////////// + + int **bd, bnum, lc, TB, *lx; + double **bond_vec; + + bool **frame; + int Pd; + int *Fx; + int **frame_lsite; + int **frame_lnum; + int **frame_rsite; + int **frame_rnum; + + int rmax; + + Lattice(const char *FNAME); + Lattice(std::string const &FNAME); + + ~Lattice(); + + void dump(); + + void show_param(std::ofstream &F); + + int countVertices(); + + void make_Size(Size *N); + void make_Parallel(Parallel *PR); + void set_beta(double beta); + void set_oldbeta(double oldbeta); + + private: + void read(); }; - #endif diff --git a/src/pmwa/inc/systemparameter.h b/src/pmwa/inc/systemparameter.h index 0ac0f5e3..6c68be12 100644 --- a/src/pmwa/inc/systemparameter.h +++ b/src/pmwa/inc/systemparameter.h @@ -8,19 +8,19 @@ #include struct Size { - int x; //the number of lattice for x. - int y; //the number of lattice for y. - int z; //the number of lattice for z. - int V; //the total number of lattice. - int d; //dimension. - double B; //the inverse of temperature. - double oldB; //for annealing. - Size():x(0),y(0),z(0),V(0),d(0),B(0.0),oldB(0.0){} + int x; // the number of lattice for x. + int y; // the number of lattice for y. + int z; // the number of lattice for z. + int V; // the total number of lattice. + int d; // dimension. + double B; // the inverse of temperature. + double oldB; // for annealing. + Size() : x(0), y(0), z(0), V(0), d(0), B(0.0), oldB(0.0) {} }; struct System { int nmax; // the maximum number of bosons on a same site. - double Ubb; //on-site interaction. + double Ubb; // on-site interaction. double Vb1; // nearest-neighbor interaction. double tb; // hopping double mu; // chemical potential. @@ -28,7 +28,16 @@ struct System { double Htr; // the strenght of the transverse field for introducing worm. double Eu; // arbitrary energy shift for Ubb. double Et; // arbitrary energy shift for t-Vb1. - System():nmax(0),Ubb(0.0),Vb1(0.0),tb(0.0),mu(0.0),w_num(0),Htr(0.0),Eu(0.0),Et(0.0){} + System() + : nmax(0), + Ubb(0.0), + Vb1(0.0), + tb(0.0), + mu(0.0), + w_num(0), + Htr(0.0), + Eu(0.0), + Et(0.0) {} }; struct MC_p { @@ -39,49 +48,58 @@ struct MC_p { int Nbin; int Ntest; int nc; - int runtype; //{0: normal, 1:restart, 2:annealing} - MC_p():seed(0),Nstep(0),Nthermal(0),Nsample(0),Nbin(0),Ntest(0),nc(0),runtype(0){} + int runtype; //{0: normal, 1:restart, 2:annealing} + MC_p() + : seed(0), + Nstep(0), + Nthermal(0), + Nsample(0), + Nbin(0), + Ntest(0), + nc(0), + runtype(0) {} }; struct Parallel { - int p_num; // the total number of processors. - int my_rank; // the rank of each proseccor. - int Ntdiv; // the number of the temporal decomposition. - int Nsdiv, Nxdiv, Nydiv, Nzdiv; // the number of the spatial decomposition. (total, x, y, z) - int NtNs; // the number of domain decomposition. - int Npara; // the number of trivial parallelization. - double B; // beta of "a domain". - double oldB; // for annealing. - bool FlgAnneal; // for annealing. - bool FlgRestart; // for restart. + int p_num; // the total number of processors. + int my_rank; // the rank of each proseccor. + int Ntdiv; // the number of the temporal decomposition. + int Nsdiv, Nxdiv, Nydiv, + Nzdiv; // the number of the spatial decomposition. (total, x, y, z) + int NtNs; // the number of domain decomposition. + int Npara; // the number of trivial parallelization. + double B; // beta of "a domain". + double oldB; // for annealing. + bool FlgAnneal; // for annealing. + bool FlgRestart; // for restart. int x, y, z, V; // the coordinate number. // process numbers - int np; // index for random number parallelization - int Rpara; // the number of replica (random system) - int nq; // index for random system (random number parallelization) - int nr; // index for random system (replica) + int np; // index for random number parallelization + int Rpara; // the number of replica (random system) + int nq; // index for random system (random number parallelization) + int nr; // index for random system (replica) /* // a random potential number (one of trivial parallelization) - PR.nr = PR.np % PR.Rpara; - // a seed number of the trivial parallelization for the random potential (one of trivial parallelization) - PR.nq = PR.np / PR.Rpara; + PR.nr = PR.np % PR.Rpara; + // a seed number of the trivial parallelization for the random potential (one + of trivial parallelization) PR.nq = PR.np / PR.Rpara; */ // domain information - int nst; // domain index - int nt; // along imaginary time - int ns; // along space - int nx; // x - int ny; // y - int nz; // z + int nst; // domain index + int nt; // along imaginary time + int ns; // along space + int nx; // x + int ny; // y + int nz; // z // process id for origin domain - int nst0; // sharing np - int nt0; // sharing np, ns - int ns0; // sharing np, nt + int nst0; // sharing np + int nt0; // sharing np, ns + int ns0; // sharing np, nt int nx0; // process id for neighbor domains @@ -89,18 +107,41 @@ struct Parallel { int lower; int right[3]; int left[3]; - Parallel():p_num(0),my_rank(0), - Ntdiv(0),Nsdiv(0),Nxdiv(0),Nydiv(0),Nzdiv(0), - NtNs(0),Npara(0), - B(0.0),oldB(0.0), - FlgAnneal(false),FlgRestart(false), - x(0),y(0),z(0),V(0), - np(0),Rpara(0),nq(0),nr(0), - nst(0),nt(0),ns(0),nx(0),ny(0),nz(0), - nst0(0),nt0(0),ns0(0),nx0(0), - upper(0),lower(0) - { - for(int i=0; i<3; ++i){ + Parallel() + : p_num(0), + my_rank(0), + Ntdiv(0), + Nsdiv(0), + Nxdiv(0), + Nydiv(0), + Nzdiv(0), + NtNs(0), + Npara(0), + B(0.0), + oldB(0.0), + FlgAnneal(false), + FlgRestart(false), + x(0), + y(0), + z(0), + V(0), + np(0), + Rpara(0), + nq(0), + nr(0), + nst(0), + nt(0), + ns(0), + nx(0), + ny(0), + nz(0), + nst0(0), + nt0(0), + ns0(0), + nx0(0), + upper(0), + lower(0) { + for (int i = 0; i < 3; ++i) { right[i] = left[i] = 0; } } diff --git a/src/pmwa/inc/xml.hpp b/src/pmwa/inc/xml.hpp index 742847c3..295c9e9a 100644 --- a/src/pmwa/inc/xml.hpp +++ b/src/pmwa/inc/xml.hpp @@ -1,17 +1,18 @@ #ifndef XML_H #define XML_H -#include -#include #include +#include +#include #include -#include + +#include #include +#include #include -#include #include -//io.h (here)################## +// io.h (here)################## #define BLEN 256 inline int line_split(char *line, std::string *w) { @@ -25,7 +26,7 @@ inline int line_split(char *line, std::string *w) { } class FileReader { -private: + private: std::string EOL; char NAME[BLEN]; char LINE[BLEN]; @@ -35,7 +36,7 @@ class FileReader { std::ifstream INS; std::streampos top; -public: + public: void open(const char *name) { strcpy(NAME, name); INS.open(NAME); @@ -61,7 +62,9 @@ class FileReader { bool read() { bool b = (bool)INS.getline(LINE, BLEN); - if (b) { IL++; } + if (b) { + IL++; + } return b; }; @@ -76,18 +79,18 @@ class FileReader { void getWordList(int &NW, std::string *&W); }; -//io.h (end)################ -//array.h (here)################## +// io.h (end)################ +// array.h (here)################## //--------------------------------- class IndexSystem { -private: + private: bool INI; std::string LBL; // label int D; int *L; int N; -public: + public: void init(const int d, const int *l, const std::string &LBL0 = ""); IndexSystem() { INI = false; }; @@ -102,7 +105,7 @@ class IndexSystem { //------------------------------ template class Array { -private: + private: std::string LBL; // label int D; C *val; @@ -110,7 +113,7 @@ class Array { void init(va_list &ap); -public: + public: Array() { LBL = ""; val = 0; @@ -132,14 +135,14 @@ C &Array::operator[](const int i) { //====================================================================== -//array.h (end)################## +// array.h (end)################## namespace XML { class Block; class Block { -private: + private: std::string EOL; std::string Name; // the name of the element std::string *Word; // the whole list of words to be processed @@ -150,14 +153,14 @@ class Block { int NV; // the number of values Array Value; -public: + public: void initialize(std::string *word, const std::string &name = ""); void initialize(const std::string &FNAME, const std::string &name = ""); Block() { - NB = 0; - NV = 0; + NB = 0; + NV = 0; EOL = "_E_O_L_"; }; diff --git a/src/pmwa/lattgene.cc b/src/pmwa/lattgene.cc index 8853eb04..25456397 100644 --- a/src/pmwa/lattgene.cc +++ b/src/pmwa/lattgene.cc @@ -4,20 +4,22 @@ ----------------------------------------------*/ -#include -#include #include -#include + #include +#include #include +#include +#include using namespace std; //-------------------------------------------------------------- -void ShowUsage(std::string const& exename) { +void ShowUsage(std::string const &exename) { cout << "usage:\n"; cout << " " << exename << " [-o filename] D L B NLdiv NBdiv NFILED\n"; - cout << " " << exename << " [-o filename] D L_1 ... L_D B NLdiv NBdiv NFILED\n"; + cout << " " << exename + << " [-o filename] D L_1 ... L_D B NLdiv NBdiv NFILED\n"; cout << "arguments:\n"; cout << " D ... dimension. \n"; cout << " L ... the liner size of the lattice. \n"; @@ -33,7 +35,8 @@ void ShowUsage(std::string const& exename) { } //------------------------------------------------------------- -void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, int NF, std::string const& filename) { +void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, + int NF, std::string const &filename) { ofstream fout(filename.c_str()); fout.precision(15); @@ -44,18 +47,18 @@ void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, in } double B = orgB / (double)NBD; - int N = 1; //number of sites per domain. + int N = 1; // number of sites per domain. for (int i = 0; i < D; i++) { N *= L[i]; } - int NumberOfCells = N; - int NumberOfInteractions = N * D; //z/2*N - int NumberOfLDecomposition = NLD; - int NumberOfBDecomposition = NBD; - int NumberOfSiteTypes = 1; //sub-lattice + int NumberOfCells = N; + int NumberOfInteractions = N * D; // z/2*N + int NumberOfLDecomposition = NLD; + int NumberOfBDecomposition = NBD; + int NumberOfSiteTypes = 1; // sub-lattice int NumberOfInteractionTypes = 1; - int NumberOfExternalField = NF; + int NumberOfExternalField = NF; fout << "" << endl << endl; fout << "" << endl; @@ -68,7 +71,8 @@ void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, in fout << orgL[i] << " "; } fout << "" << endl; - fout << " " << NLD << " " << endl; + fout << " " << NLD << " " + << endl; fout << " "; for (int i = 0; i < D; i++) { fout << L[i] << " "; @@ -77,15 +81,22 @@ void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, in fout << " " << orgB << " " << endl; fout << " " << orgOB << " " << endl; - fout << " " << NBD << " " << endl; + fout << " " << NBD << " " + << endl; fout << " " << B << " " << endl; - fout << " " << NumberOfCells << " " << endl; //L^d units - fout << " " << N << " " << endl; //NumberOfCells*NumberOfSiteTypes - fout << " " << NumberOfInteractions << " " << endl; - fout << " " << NumberOfSiteTypes << " " << endl; - fout << " " << NumberOfInteractionTypes << " " << endl; - fout << " " << NumberOfExternalField << " " << endl; + fout << " " << NumberOfCells << " " + << endl; // L^d units + fout << " " << N << " " + << endl; // NumberOfCells*NumberOfSiteTypes + fout << " " << NumberOfInteractions + << " " << endl; + fout << " " << NumberOfSiteTypes << " " + << endl; + fout << " " << NumberOfInteractionTypes + << " " << endl; + fout << " " << NumberOfExternalField + << " " << endl; fout << endl; fout << "" << endl << endl; @@ -94,9 +105,9 @@ void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, in int mtype = 0; for (int id = 0; id < N; id++) { - int p = id; + int p = id; int Nt = N; - mtype = 0; + mtype = 0; for (int q = D - 1; q >= 0; q--) { Nt /= L[q]; mtype += p / Nt; @@ -108,14 +119,16 @@ void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, in } fout << endl; - fout << "" << endl << endl; + fout << "" + << endl + << endl; - int NB = D * N; // number of bonds - int *x = new int[D]; + int NB = D * N; // number of bonds + int *x = new int[D]; int itype = 0; int nbody = 2; - int eid = 0, etype; - NB = 0; + int eid = 0, etype; + NB = 0; for (int i = 0; i < N; i++) { for (int p = 0; p < D; p++) { @@ -131,14 +144,15 @@ void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, in } else etype = -1; - x[p] = (x[p] + 1) % L[p]; + x[p] = (x[p] + 1) % L[p]; int j = 0; for (int q = D - 1; q >= 0; q--) { j *= L[q]; j += x[q]; } - fout << " " << NB << " " << itype << " " << nbody << " " << etype << " " << i << " " << j << " " << endl; + fout << " " << NB << " " << itype << " " << nbody << " " << etype + << " " << i << " " << j << " " << endl; NB++; } @@ -153,11 +167,11 @@ void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, in int main(int argc, char **argv) { std::string exename(argv[0]); std::string filename("lattice.xml"); - if(argc < 3){ + if (argc < 3) { ShowUsage(exename); exit(0); } - if(std::strcmp(argv[1], "-o")==0){ + if (std::strcmp(argv[1], "-o") == 0) { filename = argv[2]; argc -= 2; argv += 2; @@ -169,29 +183,29 @@ int main(int argc, char **argv) { } const int D = atoi(argv[1]); // int L[D] ; - int *L = new int[D]; + int *L = new int[D]; double B = 0.0; - int NLD = 1; - int NBD = 1; - int NF = 0; + int NLD = 1; + int NBD = 1; + int NF = 0; if (argc == NARG + 1) { int lx = atoi(argv[2]); for (int i = 0; i < D; i++) { L[i] = lx; } - B = (double)atof(argv[3]); + B = (double)atof(argv[3]); NLD = atoi(argv[4]); NBD = atoi(argv[5]); - NF = atoi(argv[6]); + NF = atoi(argv[6]); } else if (argc == D + NARG) { for (int i = 0; i < D; i++) { L[i] = atoi(argv[2 + i]); } - B = (double)atof(argv[D + NARG - 4]); + B = (double)atof(argv[D + NARG - 4]); NLD = atoi(argv[D + NARG - 3]); NBD = atoi(argv[D + NARG - 2]); - NF = atoi(argv[D + NARG - 1]); + NF = atoi(argv[D + NARG - 1]); } else { cout << "error: D != number of L[]." << endl; ShowUsage(exename); @@ -217,7 +231,9 @@ int main(int argc, char **argv) { cout << "NBdiv = " << NBD << endl; cout << "NFIELD = " << NF << endl; - if (EvenOrOdd) { cout << "Warnig: L should be an even number." << endl; } + if (EvenOrOdd) { + cout << "Warnig: L should be an even number." << endl; + } WriteXML(D, L, B, B, NLD, NBD, NF, filename); cout << "... done." << endl; diff --git a/src/pmwa/lattice.cpp b/src/pmwa/lattice.cpp index 20074d3d..d4a95a93 100644 --- a/src/pmwa/lattice.cpp +++ b/src/pmwa/lattice.cpp @@ -10,9 +10,8 @@ inline void FileReader::getWordList(int &NW, std::string *&W) { NW = 0; rewind(); - while (read()) - NW += split(); - W = new std::string[NW + 1]; + while (read()) NW += split(); + W = new std::string[NW + 1]; int iw = 0; rewind(); while (read()) { @@ -33,17 +32,16 @@ void IndexSystem::init(const int d, const int *l, const std::string &LBL0) { } INI = true; LBL = LBL0; - D = d; - L = new int[d]; - N = 1; + D = d; + L = new int[d]; + N = 1; for (int i = 0; i < d; i++) { N *= l[i]; L[i] = l[i]; } if (N == 0) { printf("IndexSystem::init> Error. N = 0.\n"); - for (int i = 0; i < d; i++) - printf(" L[%d] = %d\n", i, L[i]); + for (int i = 0; i < d; i++) printf(" L[%d] = %d\n", i, L[i]); exit(0); }; } @@ -60,7 +58,7 @@ template void Array::init(va_list &ap) { reset(); int *L = new int[D]; - int N = 1; + int N = 1; int l; int i = 0; for (i = 0; i < D; i++) { @@ -89,7 +87,7 @@ void Array::init(va_list &ap) { template void Array::init(const std::string &s, int d, ...) { LBL = s; - D = d; + D = d; va_list ap; va_start(ap, d); init(ap); @@ -125,14 +123,14 @@ Block &Block::operator[](const std::string &name) { } inline void Block::initialize(std::string *word, const std::string &name) { - //printf("Block::initialize> Pass 1\n"); + // printf("Block::initialize> Pass 1\n"); Name = name; Word = word; if (name == "") { - Open = ""; + Open = ""; Close = ""; } else { - Open = "<" + name + ">"; + Open = "<" + name + ">"; Close = ""; } read(); @@ -153,13 +151,12 @@ void Block::initialize(const std::string &FNAME, const std::string &name) { inline bool isCommentOpening(const std::string &key) { std::string sopen = ""; continue; } if (isOpening(w)) { - //cout << " ... beginning of a subelement [" << w << "]" << endl; + // cout << " ... beginning of a subelement [" << w << "]" << endl; depth++; const std::string name = getOpeningName(w); - //cout << "opening name : " << name << endl; + // cout << "opening name : " << name << endl; SkipTo = ""; NB++; continue; @@ -244,26 +238,29 @@ inline bool Block::syntax_error() { if (isClosing(w)) { printf("Block::read> Error.\n"); printf(" An unexpected closing tag %s\n", w.c_str()); - printf(" is detected in reading an element of name [%s].\n", getName().c_str()); + printf(" is detected in reading an element of name [%s].\n", + getName().c_str()); return true; } - //cout << " ... a value" << endl; + // cout << " ... a value" << endl; NV++; } if (depth != 0) { printf("Block::read> Error.\n"); std::string expected = SkipTo; - if (expected == "") { expected = Close; } + if (expected == "") { + expected = Close; + } printf(" A missing closing tag %s\n", expected.c_str()); - printf(" is detected in reading an element of name [%s].\n", getName().c_str()); + printf(" is detected in reading an element of name [%s].\n", + getName().c_str()); return true; } return false; } - void Block::read() { // printf("Block::read> Pass 1\n"); if (syntax_error()) exit(0); @@ -271,11 +268,11 @@ void Block::read() { if (NV > 0) Value.init("Value", 1, NV); if (NB > 0) SubBlock.init("SubBlock", 1, NB); // cout<<"Block.NV = "< Start.\n"); // koko @@ -321,14 +317,11 @@ Lattice::Lattice(const std::string &FNAME) { #endif } - void Lattice::read() { D = X["Dimension"].getInteger(); // cout<<"D="< 1) ? X["LinearDomainSize"].getInteger(1) : 1; Nz = (D == 3) ? X["LinearDomainSize"].getInteger(2) : 1; - //cout<<"Ldom="<= 0) { - k = Fx[l]; - frame[l][s0] = true; + k = Fx[l]; + frame[l][s0] = true; frame_lsite[l][k] = s0; frame_lnum[l][s0] = k; frame_rsite[l][k] = s1; @@ -423,13 +416,13 @@ void Lattice::read() { void Lattice::make_Size(Size *_Nsize) { N = _Nsize; - _Nsize->d = D; - _Nsize->x = L[0]; //14 - _Nsize->y = L[1]; //15 - _Nsize->z = L[2]; //16 - _Nsize->B = BETA; //17 - _Nsize->oldB = oldBETA; //18 - _Nsize->V = _Nsize->x * _Nsize->y * _Nsize->z; + _Nsize->d = D; + _Nsize->x = L[0]; // 14 + _Nsize->y = L[1]; // 15 + _Nsize->z = L[2]; // 16 + _Nsize->B = BETA; // 17 + _Nsize->oldB = oldBETA; // 18 + _Nsize->V = _Nsize->x * _Nsize->y * _Nsize->z; } void Lattice::make_Parallel(Parallel *_PR) { @@ -441,10 +434,11 @@ void Lattice::make_Parallel(Parallel *_PR) { PR->Ntdiv = NBdiv; PR->Rpara = NFIELD; - PR->B = BETA/NBdiv; // beta for a domain. + PR->B = BETA / NBdiv; // beta for a domain. PR->oldB = oldBETA / (double)NBdiv; // for annealing. - PR->Nsdiv = PR->Nxdiv * PR->Nydiv * PR->Nzdiv; // the number of spatial decompositions. + PR->Nsdiv = PR->Nxdiv * PR->Nydiv * + PR->Nzdiv; // the number of spatial decompositions. PR->x = Nx; PR->y = Ny; @@ -452,64 +446,105 @@ void Lattice::make_Parallel(Parallel *_PR) { PR->V = V; - PR->NtNs = PR->Ntdiv * PR->Nsdiv; //the number of decompositions (non-trivial parallelization). - PR->Npara = PR->p_num / PR->NtNs; //the number of trivial parallelization. + PR->NtNs = + PR->Ntdiv * + PR->Nsdiv; // the number of decompositions (non-trivial parallelization). + PR->Npara = PR->p_num / PR->NtNs; // the number of trivial parallelization. - PR->nt = PR->my_rank % PR->Ntdiv; // the temporal domain number for the processor. - PR->ns = (int)(PR->my_rank / PR->Ntdiv) % PR->Nsdiv; // the spatial domain number for the processor. + PR->nt = + PR->my_rank % PR->Ntdiv; // the temporal domain number for the processor. + PR->ns = (int)(PR->my_rank / PR->Ntdiv) % + PR->Nsdiv; // the spatial domain number for the processor. - PR->nx = PR->ns % PR->Nxdiv; // the x-directional domain number for the processor. - PR->ny = (PR->ns / PR->Nxdiv) % PR->Nydiv; // the y-directional domain number for the processor. - PR->nz = PR->ns / (PR->Nxdiv * PR->Nydiv); // the z-directional domain number for the processor. + PR->nx = + PR->ns % PR->Nxdiv; // the x-directional domain number for the processor. + PR->ny = (PR->ns / PR->Nxdiv) % + PR->Nydiv; // the y-directional domain number for the processor. + PR->nz = PR->ns / + (PR->Nxdiv * + PR->Nydiv); // the z-directional domain number for the processor. - PR->nst = PR->my_rank % PR->NtNs; // the domain number for the processor. - PR->np = PR->my_rank / (PR->NtNs); // the seed number of the trivial parallelization for the processor. + PR->nst = PR->my_rank % PR->NtNs; // the domain number for the processor. + PR->np = PR->my_rank / (PR->NtNs); // the seed number of the trivial + // parallelization for the processor. if (PR->Rpara > 0) { - PR->nr = PR->np % PR->Rpara; // a random potential number (one of trivial parallelization) - PR->nq = - PR->np - / PR->Rpara; // a seed number of the trivial parallelization for the random potential (one of trivial parallelization) + PR->nr = PR->np % PR->Rpara; // a random potential number (one of trivial + // parallelization) + PR->nq = PR->np / + PR->Rpara; // a seed number of the trivial parallelization for the + // random potential (one of trivial parallelization) } else { PR->nr = 0; PR->nq = PR->np; } - //the coordinate is (nt,nx,ny,nz,np) - - PR->nst0 = PR->np * PR->NtNs; // nst=0 process number for the processor. - PR->nt0 = PR->ns * PR->Ntdiv + PR->np * PR->NtNs; //nt=0 process number for the processor. - PR->ns0 = PR->nt + PR->np * PR->NtNs; //ns=0 process number for the processor. - PR->nx0 = PR->nt + (PR->ny * PR->Nxdiv + PR->nz * PR->Nxdiv * PR->Nydiv) * PR->Ntdiv - + PR->np * PR->NtNs; //nx=0 process number for the processor. - - PR->upper = (PR->nt + 1) % PR->Ntdiv + PR->ns * PR->Ntdiv - + PR->np * PR->Ntdiv * PR->Nsdiv; //the upper process number for the temporal direction. - PR->lower = (PR->nt - 1 + PR->Ntdiv) % PR->Ntdiv + PR->ns * PR->Ntdiv - + PR->np * PR->Ntdiv * PR->Nsdiv; //the lower process number the temporal direction. - - PR->right[0] = PR->nt + ((PR->nx + 1) % PR->Nxdiv + PR->ny * PR->Nxdiv + PR->nz * PR->Nxdiv * PR->Nydiv) * PR->Ntdiv - + PR->np * PR->Ntdiv * PR->Nsdiv; //the right side process number for the x direction. + // the coordinate is (nt,nx,ny,nz,np) + + PR->nst0 = PR->np * PR->NtNs; // nst=0 process number for the processor. + PR->nt0 = PR->ns * PR->Ntdiv + + PR->np * PR->NtNs; // nt=0 process number for the processor. + PR->ns0 = + PR->nt + PR->np * PR->NtNs; // ns=0 process number for the processor. + PR->nx0 = PR->nt + + (PR->ny * PR->Nxdiv + PR->nz * PR->Nxdiv * PR->Nydiv) * PR->Ntdiv + + PR->np * PR->NtNs; // nx=0 process number for the processor. + + PR->upper = + (PR->nt + 1) % PR->Ntdiv + PR->ns * PR->Ntdiv + + PR->np * PR->Ntdiv * + PR->Nsdiv; // the upper process number for the temporal direction. + PR->lower = + (PR->nt - 1 + PR->Ntdiv) % PR->Ntdiv + PR->ns * PR->Ntdiv + + PR->np * PR->Ntdiv * + PR->Nsdiv; // the lower process number the temporal direction. + + PR->right[0] = + PR->nt + + ((PR->nx + 1) % PR->Nxdiv + PR->ny * PR->Nxdiv + + PR->nz * PR->Nxdiv * PR->Nydiv) * + PR->Ntdiv + + PR->np * PR->Ntdiv * + PR->Nsdiv; // the right side process number for the x direction. PR->left[0] = - PR->nt + ((PR->nx - 1 + PR->Nxdiv) % PR->Nxdiv + PR->ny * PR->Nxdiv + PR->nz * PR->Nxdiv * PR->Nydiv) * PR->Ntdiv - + PR->np * PR->Ntdiv * PR->Nsdiv; //the left side process number for the x direction. - - PR->right[1] = PR->nt + (PR->nx + ((PR->ny + 1) % PR->Nydiv) * PR->Nxdiv + PR->nz * PR->Nxdiv * PR->Nydiv) * PR->Ntdiv - + PR->np * PR->Ntdiv * PR->Nsdiv; //the right side process number for the y direction. + PR->nt + + ((PR->nx - 1 + PR->Nxdiv) % PR->Nxdiv + PR->ny * PR->Nxdiv + + PR->nz * PR->Nxdiv * PR->Nydiv) * + PR->Ntdiv + + PR->np * PR->Ntdiv * + PR->Nsdiv; // the left side process number for the x direction. + + PR->right[1] = + PR->nt + + (PR->nx + ((PR->ny + 1) % PR->Nydiv) * PR->Nxdiv + + PR->nz * PR->Nxdiv * PR->Nydiv) * + PR->Ntdiv + + PR->np * PR->Ntdiv * + PR->Nsdiv; // the right side process number for the y direction. PR->left[1] = - PR->nt - + (PR->nx + ((PR->ny - 1 + PR->Nydiv) % PR->Nydiv) * PR->Nxdiv + PR->nz * PR->Nxdiv * PR->Nydiv) * PR->Ntdiv - + PR->np * PR->Ntdiv * PR->Nsdiv; //the left side process number for the y direction. - - PR->right[2] = PR->nt + (PR->nx + PR->ny * PR->Nxdiv + ((PR->nz + 1) % PR->Nzdiv) * PR->Nxdiv * PR->Nydiv) * PR->Ntdiv - + PR->np * PR->Ntdiv * PR->Nsdiv; //the right side process number for the z direction. + PR->nt + + (PR->nx + ((PR->ny - 1 + PR->Nydiv) % PR->Nydiv) * PR->Nxdiv + + PR->nz * PR->Nxdiv * PR->Nydiv) * + PR->Ntdiv + + PR->np * PR->Ntdiv * + PR->Nsdiv; // the left side process number for the y direction. + + PR->right[2] = + PR->nt + + (PR->nx + PR->ny * PR->Nxdiv + + ((PR->nz + 1) % PR->Nzdiv) * PR->Nxdiv * PR->Nydiv) * + PR->Ntdiv + + PR->np * PR->Ntdiv * + PR->Nsdiv; // the right side process number for the z direction. PR->left[2] = - PR->nt - + (PR->nx + PR->ny * PR->Nxdiv + ((PR->nz - 1 + PR->Nzdiv) % PR->Nzdiv) * PR->Nxdiv * PR->Nydiv) * PR->Ntdiv - + PR->np * PR->Ntdiv * PR->Nsdiv; //the left side process number for the z direction. + PR->nt + + (PR->nx + PR->ny * PR->Nxdiv + + ((PR->nz - 1 + PR->Nzdiv) % PR->Nzdiv) * PR->Nxdiv * PR->Nydiv) * + PR->Ntdiv + + PR->np * PR->Ntdiv * + PR->Nsdiv; // the left side process number for the z direction. } - Lattice::~Lattice() { delcall(bond_vec, lc); delcall(bd, V); @@ -562,15 +597,14 @@ void Lattice::show_param(std::ofstream &F) { F << "P BETA = " << BETA << endl; F << "P DOML = " << PR->x << " " << PR->y << " " << PR->z << endl; F << "P DOMBETA = " << PR->B << endl; - F << "P NDIVL = " << PR->Nxdiv << " " << PR->Nydiv << " " << PR->Nzdiv << endl; + F << "P NDIVL = " << PR->Nxdiv << " " << PR->Nydiv << " " << PR->Nzdiv + << endl; F << "P NDIVBETA= " << PR->Ntdiv << endl; } -void Lattice::set_beta(double beta){ +void Lattice::set_beta(double beta) { BETA = beta; B = BETA / NBdiv; } -void Lattice::set_oldbeta(double oldbeta){ - oldBETA = oldbeta; -} +void Lattice::set_oldbeta(double oldbeta) { oldBETA = oldbeta; } diff --git a/src/pmwa/lib/My_rdm.boost.cpp b/src/pmwa/lib/My_rdm.boost.cpp index 16f3764d..f5b1ac81 100644 --- a/src/pmwa/lib/My_rdm.boost.cpp +++ b/src/pmwa/lib/My_rdm.boost.cpp @@ -24,7 +24,8 @@ void My_rdm::ingen(char *fname) { fin.close(); } -My_rdmi::My_rdmi(long seed, long iMax) : gen_i(seed), dst_i(0, iMax - 1), rdm_i(gen_i, dst_i) {} +My_rdmi::My_rdmi(long seed, long iMax) + : gen_i(seed), dst_i(0, iMax - 1), rdm_i(gen_i, dst_i) {} My_rdmi::~My_rdmi() {} @@ -48,7 +49,8 @@ void My_rdmi::ingen(char *fname) { fin.close(); } -My_rdms::My_rdms(long seed, short iMax) : gen_s(seed), dst_s(0, iMax - 1), rdm_s(gen_s, dst_s) {} +My_rdms::My_rdms(long seed, short iMax) + : gen_s(seed), dst_s(0, iMax - 1), rdm_s(gen_s, dst_s) {} My_rdms::~My_rdms() {} diff --git a/src/pmwa/lib/My_rdm.boost.h b/src/pmwa/lib/My_rdm.boost.h index a8f81ed3..8ebb0969 100644 --- a/src/pmwa/lib/My_rdm.boost.h +++ b/src/pmwa/lib/My_rdm.boost.h @@ -5,14 +5,14 @@ #include #include using namespace std; -//using namespace boost; +// using namespace boost; class My_rdm { boost::mt19937 gen_d; boost::uniform_real<> dst_d; // [0,1) boost::variate_generator > rdm_d; -public: + public: void outgen(char *fname); void ingen(char *fname); @@ -27,7 +27,7 @@ class My_rdms { boost::uniform_smallint<> dst_s; // [0,iMax] boost::variate_generator > rdm_s; -public: + public: void outgen(char *fname); void ingen(char *fname); @@ -42,7 +42,7 @@ class My_rdmi { boost::uniform_int<> dst_i; // [0,iMax] boost::variate_generator > rdm_i; -public: + public: void outgen(char *fname); void ingen(char *fname); diff --git a/src/pmwa/lib/My_rdm.gsl.cpp b/src/pmwa/lib/My_rdm.gsl.cpp index 22aec694..763fdf65 100644 --- a/src/pmwa/lib/My_rdm.gsl.cpp +++ b/src/pmwa/lib/My_rdm.gsl.cpp @@ -6,14 +6,18 @@ My_rdm::My_rdm(long seed) { else gsl_rng_default_seed = (unsigned long)seed; - type_gsl_rng = gsl_rng_default; + type_gsl_rng = gsl_rng_default; generator_gsl_rng = gsl_rng_alloc(type_gsl_rng); } My_rdm::~My_rdm() { gsl_rng_free(generator_gsl_rng); } -long double My_rdm::gsl_rng_rdm_ld() { return (long double)gsl_rng_uniform(generator_gsl_rng); } -double My_rdm::gsl_rng_rdm_d() { return (double)gsl_rng_uniform(generator_gsl_rng); } +long double My_rdm::gsl_rng_rdm_ld() { + return (long double)gsl_rng_uniform(generator_gsl_rng); +} +double My_rdm::gsl_rng_rdm_d() { + return (double)gsl_rng_uniform(generator_gsl_rng); +} double My_rdm::rdm() { return gsl_rng_rdm_d(); } long double My_rdm::rdml() { return gsl_rng_rdm_ld(); } diff --git a/src/pmwa/lib/My_rdm.gsl.h b/src/pmwa/lib/My_rdm.gsl.h index fb17a3b6..375a3e08 100644 --- a/src/pmwa/lib/My_rdm.gsl.h +++ b/src/pmwa/lib/My_rdm.gsl.h @@ -1,9 +1,10 @@ #ifndef MY_RDM_H #define MY_RDM_H -#include #include +#include #include + #include #include using namespace std; @@ -12,7 +13,7 @@ class My_rdm { gsl_rng *generator_gsl_rng; const gsl_rng_type *type_gsl_rng; -public: + public: My_rdm(long seed); ~My_rdm(); @@ -25,7 +26,7 @@ class My_rdm { int r01(); int r012(); -private: + private: long double gsl_rng_rdm_ld(); double gsl_rng_rdm_d(); }; diff --git a/src/pmwa/lib/My_rdm.hrd.cpp b/src/pmwa/lib/My_rdm.hrd.cpp index e20b4907..d8f9293d 100644 --- a/src/pmwa/lib/My_rdm.hrd.cpp +++ b/src/pmwa/lib/My_rdm.hrd.cpp @@ -7,14 +7,14 @@ My_rdm::~My_rdm() {} void My_rdm::outgen(std::string const& fname) { ofstream fout(fname.c_str(), ios::out | ios::binary); - fout.write((char *)this, sizeof(My_rdm)); + fout.write((char*)this, sizeof(My_rdm)); } void My_rdm::ingen(std::string const& fname) { ifstream fin(fname.c_str(), ios::in | ios::binary); if (fin) - fin.read((char *)this, sizeof(My_rdm)); + fin.read((char*)this, sizeof(My_rdm)); else { cout << "no file!" << endl; }; diff --git a/src/pmwa/lib/My_rdm.hrd.h b/src/pmwa/lib/My_rdm.hrd.h index 417e0d00..d2c09d99 100644 --- a/src/pmwa/lib/My_rdm.hrd.h +++ b/src/pmwa/lib/My_rdm.hrd.h @@ -2,6 +2,7 @@ #define MY_RDM_H #include + #include #include using namespace std; @@ -9,7 +10,7 @@ using namespace std; class My_rdm { Random RND; -public: + public: void outgen(std::string const& fname); void ingen(std::string const& fname); diff --git a/src/pmwa/lib/random.cpp b/src/pmwa/lib/random.cpp index 23cf698f..374344f7 100644 --- a/src/pmwa/lib/random.cpp +++ b/src/pmwa/lib/random.cpp @@ -24,10 +24,8 @@ double Random::Uniform(void) { if (navr == 0) { Rint i; - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; iptr = 0; navr = IPP; } @@ -38,10 +36,8 @@ double Random::Uniform(void) { Rint Random::Int(Rint ilimit) { if (navr == 0) { Rint i; - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; iptr = 0; navr = IPP; } @@ -53,10 +49,8 @@ Rint Random::Int(Rint ilimit) { Rint Random::Int(void) { if (navr == 0) { Rint i; - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; iptr = 0; navr = IPP; } @@ -66,12 +60,11 @@ Rint Random::Int(void) { // Random Permutation void Random::Perm(Rint N, int *Index) { - for (Rint i = 0; i < N; i++) - Index[i] = i; + for (Rint i = 0; i < N; i++) Index[i] = i; for (Rint i = 0; i < N - 1; i++) { - Rint x = Index[i]; - Rint ix = i + Int(N - i); - Index[i] = Index[ix]; + Rint x = Index[i]; + Rint ix = i + Int(N - i); + Index[i] = Index[ix]; Index[ix] = x; } /* @@ -82,8 +75,8 @@ void Random::Perm(Rint N, int *Index) { while(ind < N) { n = (Rint) (Int()*rx); if (Index[n] == -1) { - Index[n] = ind; - ind++; + Index[n] = ind; + ind++; } } */ @@ -91,9 +84,9 @@ void Random::Perm(Rint N, int *Index) { void Random::Scramble(Rint N, int *Index) { for (Rint i = 0; (i + 1) < N; i++) { - Rint x = Index[i]; - Rint ix = i + Int(N - i); - Index[i] = Index[ix]; + Rint x = Index[i]; + Rint ix = i + Int(N - i); + Index[i] = Index[ix]; Index[ix] = x; } } @@ -116,10 +109,9 @@ void Random::initialize(Rint irand0, Rint nrbit0) { nrbit = nrbit0; imask = 1; - for (i = 0; i < nrbit - 1; i++) - imask = (imask << 1) + 1; + for (i = 0; i < nrbit - 1; i++) imask = (imask << 1) + 1; runit = 1e0 / (imask + 1e0); - ix = irand0; + ix = irand0; for (i = 0; i < IPP; i++) { ix = (ix * 1812433253 + 1) & 0xffffffff; if (ix & 0x80000000) @@ -139,7 +131,7 @@ void Random::initialize(Rint irand0, Rint nrbit0) { ib[j] = mj; } for (j = 0; j < IPP; j++) { - ih = ((j * 16) % IPP); + ih = ((j * 16) % IPP); iri[j] = imask & ib[ih]; for (i = 0; i < 16; i++) { ii = (ih + i) % IPP; @@ -161,11 +153,9 @@ void Random::setSeed(Rint *seed, Rint nrbit0) { Rint i; nrbit = nrbit0; imask = 1; - for (i = 0; i < nrbit - 1; i++) - imask = (imask << 1) + 1; + for (i = 0; i < nrbit - 1; i++) imask = (imask << 1) + 1; runit = 1e0 / (imask + 1e0); - for (i = 0; i < IPP; i++) - iri[i] = imask & seed[i]; + for (i = 0; i < IPP; i++) iri[i] = imask & seed[i]; navr = IPP; iptr = 0; return; @@ -191,21 +181,17 @@ void Random::Uniform(Rint nr, Rint *ir) { Rint i, nrec, n1, iptd; nrec = nr; - n1 = (navr > nrec ? nrec : navr); - for (i = 0; i < n1; i++) - ir[i] = iri[iptr + i]; + n1 = (navr > nrec ? nrec : navr); + for (i = 0; i < n1; i++) ir[i] = iri[iptr + i]; iptd = n1; iptr += n1; navr -= n1; nrec -= n1; while (nrec > 0) { - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; n1 = (IPP > nrec ? nrec : IPP); - for (i = 0; i < n1; i++) - ir[iptd + i] = iri[i]; + for (i = 0; i < n1; i++) ir[iptd + i] = iri[i]; iptd += n1; iptr = n1; navr = IPP - n1; @@ -229,21 +215,17 @@ void Random::Uniform(Rint nr, double *rx) { Rint i, nrec, n1, iptd; nrec = nr; - n1 = (navr > nrec ? nrec : navr); - for (i = 0; i < n1; i++) - rx[i] = runit * iri[iptr + i]; + n1 = (navr > nrec ? nrec : navr); + for (i = 0; i < n1; i++) rx[i] = runit * iri[iptr + i]; iptd = n1; iptr += n1; navr -= n1; nrec -= n1; while (nrec > 0) { - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; n1 = (IPP > nrec ? nrec : IPP); - for (i = 0; i < n1; i++) - rx[iptd + i] = runit * iri[i]; + for (i = 0; i < n1; i++) rx[iptd + i] = runit * iri[i]; iptd += n1; iptr = n1; navr = IPP - n1; @@ -269,22 +251,18 @@ void Random::Int(Rint nr, Rint *ir, Rint ilimit) { double runitx; runitx = runit * ilimit; - nrec = nr; - n1 = (navr > nrec ? nrec : navr); - for (i = 0; i < n1; i++) - ir[i] = (Rint)(runitx * iri[iptr + i]); + nrec = nr; + n1 = (navr > nrec ? nrec : navr); + for (i = 0; i < n1; i++) ir[i] = (Rint)(runitx * iri[iptr + i]); iptd = n1; iptr += n1; navr -= n1; nrec -= n1; while (nrec > 0) { - for (i = 0; i < IQQ; i++) - iri[i] ^= iri[i + IPQ]; - for (i = IQQ; i < IPP; i++) - iri[i] ^= iri[i - IQQ]; + for (i = 0; i < IQQ; i++) iri[i] ^= iri[i + IPQ]; + for (i = IQQ; i < IPP; i++) iri[i] ^= iri[i - IQQ]; n1 = (IPP > nrec ? nrec : IPP); - for (i = 0; i < n1; i++) - ir[iptd + i] = (Rint)(runitx * iri[i]); + for (i = 0; i < n1; i++) ir[iptd + i] = (Rint)(runitx * iri[i]); iptd += n1; iptr = n1; navr = IPP - n1; diff --git a/src/pmwa/lib/random.h b/src/pmwa/lib/random.h index d33f3e28..41479b2c 100644 --- a/src/pmwa/lib/random.h +++ b/src/pmwa/lib/random.h @@ -31,37 +31,37 @@ typedef unsigned int Rint; // using M series method // X(t) := X(t-32) xor X(t-521) class Random { -private: + private: Rint nrbit, iptr, navr; Rint iri[IPP]; double runit; -private: + private: void initialize(Rint irand0, Rint nrbit0); //: Initialization - //!param: irand0 - seed for 521 initial random numbers - //!param: nrbit0 - precision (number of bit) + //! param: irand0 - seed for 521 initial random numbers + //! param: nrbit0 - precision (number of bit) -public: + public: Random(Rint *seed, Rint nrbit0); //: Constructor - //!param: seed - 521 initial random numbers - //!param: nrbit0 - precision (number of bit) + //! param: seed - 521 initial random numbers + //! param: nrbit0 - precision (number of bit) Random(Rint irand0 = 20000101, Rint nrbit0 = 32); //: Constructor - //!param: irand0 - seed for 521 initial random numbers - //!param: nrbit0 - precision (number of bit) + //! param: irand0 - seed for 521 initial random numbers + //! param: nrbit0 - precision (number of bit) void setSeed(Rint irand0, Rint nrbit0 = 32); //: Reset - //!param: irand0 - seed for 521 initial random numbers - //!param: nrbit0 - precision (number of bit) + //! param: irand0 - seed for 521 initial random numbers + //! param: nrbit0 - precision (number of bit) void setSeed(Rint *seed, Rint nrbit0); //: Reset - //!param: seed - 521 initial random numbers - //!param: nrbit0 - precision (number of bit) + //! param: seed - 521 initial random numbers + //! param: nrbit0 - precision (number of bit) Rint getSeed(Rint *seed); //: Return seed and nrbit0 @@ -75,19 +75,19 @@ class Random { void Uniform(Rint nr, Rint *ir); //: Uniform integers - //!param: nr - the number of random numbers to be generated - //!param: ir - pointer to store outputs + //! param: nr - the number of random numbers to be generated + //! param: ir - pointer to store outputs void Uniform(Rint nr, double *rx); //: Uniform reals - //!param: nr - the number of random numbers to be generated - //!param: rx - pointer to store outputs + //! param: nr - the number of random numbers to be generated + //! param: rx - pointer to store outputs void Int(Rint nr, Rint *ir, Rint ilimit); //: Uniform integers - //!param: nr - the number of random numbers to be generated - //!param: ir - pointer to store outputs - //!param: ilimit - maximum + //! param: nr - the number of random numbers to be generated + //! param: ir - pointer to store outputs + //! param: ilimit - maximum double Gauss() { double theta; diff --git a/src/pmwa/lib/stdma.cpp b/src/pmwa/lib/stdma.cpp index 860ae498..2ffc8cfd 100644 --- a/src/pmwa/lib/stdma.cpp +++ b/src/pmwa/lib/stdma.cpp @@ -1,8 +1,8 @@ -#include - #include #include +#include #include + #include #include using namespace std; diff --git a/src/pmwa/lib/stdma.h b/src/pmwa/lib/stdma.h index f3552ad2..ff16f4ac 100644 --- a/src/pmwa/lib/stdma.h +++ b/src/pmwa/lib/stdma.h @@ -2,8 +2,8 @@ #define STDMA_H //#include -#include #include // std::ostringstream +#include double factorial(int num); void count_time(long tms, double x); @@ -30,107 +30,90 @@ void newcalls(T*& Array, int max_val) { template void newcalls(T**& Array, int max_val1, int max_val2) { Array = new T*[max_val1]; - for (int x = 0; x < max_val1; x++) - Array[x] = new T[max_val2]; + for (int x = 0; x < max_val1; x++) Array[x] = new T[max_val2]; } template void newcall_zero(T*& Array, int max_val) { Array = new T[max_val]; - for (int x = 0; x < max_val; x++) - Array[x] = 0; + for (int x = 0; x < max_val; x++) Array[x] = 0; } template void newcall_zero(T**& Array, int max_val1, int max_val2) { Array = new T*[max_val1]; - for (int x = 0; x < max_val1; x++) - Array[x] = new T[max_val2]; + for (int x = 0; x < max_val1; x++) Array[x] = new T[max_val2]; for (int x = 0; x < max_val1; x++) - for (int y = 0; y < max_val2; y++) - Array[x][y] = 0; + for (int y = 0; y < max_val2; y++) Array[x][y] = 0; } template void newcall_zero(T***& Array, int max_val1, int max_val2, int max_val3) { Array = new T**[max_val1]; + for (int x = 0; x < max_val1; x++) Array[x] = new T*[max_val2]; for (int x = 0; x < max_val1; x++) - Array[x] = new T*[max_val2]; - for (int x = 0; x < max_val1; x++) - for (int y = 0; y < max_val2; y++) - Array[x][y] = new T[max_val3]; + for (int y = 0; y < max_val2; y++) Array[x][y] = new T[max_val3]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) - for (int z = 0; z < max_val3; z++) - Array[x][y][z] = 0; + for (int z = 0; z < max_val3; z++) Array[x][y][z] = 0; } template -void newcall_zero(T****& Array, int max_val1, int max_val2, int max_val3, int max_val4) { +void newcall_zero(T****& Array, int max_val1, int max_val2, int max_val3, + int max_val4) { Array = new T***[max_val1]; + for (int x = 0; x < max_val1; x++) Array[x] = new T**[max_val2]; for (int x = 0; x < max_val1; x++) - Array[x] = new T**[max_val2]; - for (int x = 0; x < max_val1; x++) - for (int y = 0; y < max_val2; y++) - Array[x][y] = new T*[max_val3]; + for (int y = 0; y < max_val2; y++) Array[x][y] = new T*[max_val3]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) - for (int z = 0; z < max_val3; z++) - Array[x][y][z] = new T[max_val4]; + for (int z = 0; z < max_val3; z++) Array[x][y][z] = new T[max_val4]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) for (int z = 0; z < max_val3; z++) - for (int a = 0; a < max_val4; a++) - Array[x][y][z][a] = 0; + for (int a = 0; a < max_val4; a++) Array[x][y][z][a] = 0; } template -void newcall_zero(T*****& Array, int max_val1, int max_val2, int max_val3, int max_val4, int max_val5) { +void newcall_zero(T*****& Array, int max_val1, int max_val2, int max_val3, + int max_val4, int max_val5) { Array = new T****[max_val1]; + for (int x = 0; x < max_val1; x++) Array[x] = new T***[max_val2]; for (int x = 0; x < max_val1; x++) - Array[x] = new T***[max_val2]; + for (int y = 0; y < max_val2; y++) Array[x][y] = new T**[max_val3]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) - Array[x][y] = new T**[max_val3]; + for (int z = 0; z < max_val3; z++) Array[x][y][z] = new T*[max_val4]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) for (int z = 0; z < max_val3; z++) - Array[x][y][z] = new T*[max_val4]; - for (int x = 0; x < max_val1; x++) - for (int y = 0; y < max_val2; y++) - for (int z = 0; z < max_val3; z++) - for (int a = 0; a < max_val4; a++) - Array[x][y][z][a] = new T[max_val5]; + for (int a = 0; a < max_val4; a++) Array[x][y][z][a] = new T[max_val5]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) for (int z = 0; z < max_val3; z++) for (int a = 0; a < max_val4; a++) - for (int b = 0; b < max_val5; b++) - Array[x][y][z][a][b] = 0; + for (int b = 0; b < max_val5; b++) Array[x][y][z][a][b] = 0; } template -void newcall_zero(T******& Array, int max_val1, int max_val2, int max_val3, int max_val4, int max_val5, int max_val6) { +void newcall_zero(T******& Array, int max_val1, int max_val2, int max_val3, + int max_val4, int max_val5, int max_val6) { Array = new T*****[max_val1]; + for (int x = 0; x < max_val1; x++) Array[x] = new T****[max_val2]; for (int x = 0; x < max_val1; x++) - Array[x] = new T****[max_val2]; - for (int x = 0; x < max_val1; x++) - for (int y = 0; y < max_val2; y++) - Array[x][y] = new T***[max_val3]; + for (int y = 0; y < max_val2; y++) Array[x][y] = new T***[max_val3]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) - for (int z = 0; z < max_val3; z++) - Array[x][y][z] = new T**[max_val4]; + for (int z = 0; z < max_val3; z++) Array[x][y][z] = new T**[max_val4]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) for (int z = 0; z < max_val3; z++) - for (int a = 0; a < max_val4; a++) - Array[x][y][z][a] = new T*[max_val5]; + for (int a = 0; a < max_val4; a++) Array[x][y][z][a] = new T*[max_val5]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) for (int z = 0; z < max_val3; z++) @@ -143,8 +126,7 @@ void newcall_zero(T******& Array, int max_val1, int max_val2, int max_val3, int for (int z = 0; z < max_val3; z++) for (int a = 0; a < max_val4; a++) for (int b = 0; b < max_val5; b++) - for (int c = 0; c < max_val6; c++) - Array[x][y][z][a][b][c] = 0; + for (int c = 0; c < max_val6; c++) Array[x][y][z][a][b][c] = 0; } template @@ -154,18 +136,15 @@ void delcall(T*& Array) { template void delcall(T**& Array, int max_val1) { - for (int x = 0; x < max_val1; x++) - delete[] Array[x]; + for (int x = 0; x < max_val1; x++) delete[] Array[x]; delete[] Array; } template void delcall(T***& Array, int max_val1, int max_val2) { for (int x = 0; x < max_val1; x++) - for (int y = 0; y < max_val2; y++) - delete[] Array[x][y]; - for (int x = 0; x < max_val1; x++) - delete[] Array[x]; + for (int y = 0; y < max_val2; y++) delete[] Array[x][y]; + for (int x = 0; x < max_val1; x++) delete[] Array[x]; delete[] Array; } @@ -173,57 +152,47 @@ template void delcall(T****& Array, int max_val1, int max_val2, int max_val3) { for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) - for (int z = 0; z < max_val3; z++) - delete[] Array[x][y][z]; - for (int x = 0; x < max_val1; x++) - for (int y = 0; y < max_val2; y++) - delete[] Array[x][y]; + for (int z = 0; z < max_val3; z++) delete[] Array[x][y][z]; for (int x = 0; x < max_val1; x++) - delete[] Array[x]; + for (int y = 0; y < max_val2; y++) delete[] Array[x][y]; + for (int x = 0; x < max_val1; x++) delete[] Array[x]; delete[] Array; } template -void delcall(T*****& Array, int max_val1, int max_val2, int max_val3, int max_val4) { +void delcall(T*****& Array, int max_val1, int max_val2, int max_val3, + int max_val4) { for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) for (int z = 0; z < max_val3; z++) - for (int a = 0; a < max_val4; a++) - delete[] Array[x][y][z][a]; + for (int a = 0; a < max_val4; a++) delete[] Array[x][y][z][a]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) - for (int z = 0; z < max_val3; z++) - delete[] Array[x][y][z]; + for (int z = 0; z < max_val3; z++) delete[] Array[x][y][z]; for (int x = 0; x < max_val1; x++) - for (int y = 0; y < max_val2; y++) - delete[] Array[x][y]; - for (int x = 0; x < max_val1; x++) - delete[] Array[x]; + for (int y = 0; y < max_val2; y++) delete[] Array[x][y]; + for (int x = 0; x < max_val1; x++) delete[] Array[x]; delete[] Array; } template -void delcall(T*****& Array, int max_val1, int max_val2, int max_val3, int max_val4, int max_val5) { - for (int x = 0; x < max_val1; x++) - for (int y = 0; y < max_val2; y++) - for (int z = 0; z < max_val3; z++) - for (int a = 0; a < max_val4; a++) - for (int b = 0; b < max_val5; b++) - delete[] Array[x][y][z][a][b]; +void delcall(T*****& Array, int max_val1, int max_val2, int max_val3, + int max_val4, int max_val5) { for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) for (int z = 0; z < max_val3; z++) for (int a = 0; a < max_val4; a++) - delete[] Array[x][y][z][a]; + for (int b = 0; b < max_val5; b++) delete[] Array[x][y][z][a][b]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) for (int z = 0; z < max_val3; z++) - delete[] Array[x][y][z]; + for (int a = 0; a < max_val4; a++) delete[] Array[x][y][z][a]; for (int x = 0; x < max_val1; x++) for (int y = 0; y < max_val2; y++) - delete[] Array[x][y]; + for (int z = 0; z < max_val3; z++) delete[] Array[x][y][z]; for (int x = 0; x < max_val1; x++) - delete[] Array[x]; + for (int y = 0; y < max_val2; y++) delete[] Array[x][y]; + for (int x = 0; x < max_val1; x++) delete[] Array[x]; delete[] Array; } diff --git a/src/pmwa/probability.B.cpp b/src/pmwa/probability.B.cpp index 62a4b4f4..9b66c2ef 100644 --- a/src/pmwa/probability.B.cpp +++ b/src/pmwa/probability.B.cpp @@ -1,5 +1,6 @@ #include #include + #include #include "Probability.h" @@ -23,7 +24,7 @@ void Probability::look(Size *N, System *sp) { double sql; int h; - local_Et = 0.0; //local energy shift + local_Et = 0.0; // local energy shift double rmin = 0.0, Ri; // search the minimum value of the vertex density. @@ -31,13 +32,15 @@ void Probability::look(Size *N, System *sp) { for (int j = 0; j <= nmax; j++) { for (int x = 0; x < XMAX; x++) { Ri = at_make(i, j, x); - if (Ri <= rmin) { rmin = Ri; } + if (Ri <= rmin) { + rmin = Ri; + } } } } local_Et = tb - rmin; - sp->Et = z / 2.0 * N->V * local_Et; + sp->Et = z / 2.0 * N->V * local_Et; //////// @@ -53,8 +56,7 @@ void Probability::look(Size *N, System *sp) { } sp->Eu = 0.0; - for (int x = 0; x < PR->V; x++) - sp->Eu += local_Eu[x]; + for (int x = 0; x < PR->V; x++) sp->Eu += local_Eu[x]; MPI_Status status; MPI_Comm comm_nst0; @@ -74,7 +76,7 @@ void Probability::look(Size *N, System *sp) { for (int tag = 0; tag < PR->NtNs; tag++) { sp->Eu += peu[tag]; } - sp->Eu /= (double)PR->Ntdiv; //double count for Ntdiv + sp->Eu /= (double)PR->Ntdiv; // double count for Ntdiv delcall(peu); MPI_Comm_free(&comm_nst0); @@ -82,17 +84,15 @@ void Probability::look(Size *N, System *sp) { cout << "rank=" << PR->my_rank << ":: global Eu = " << sp->Eu << endl; //////// - rh_odd = sp->Htr; + rh_odd = sp->Htr; rh_even = sp->Htr; //************ at ************** for (int i = 0; i <= nmax; i++) for (int j = 0; j <= nmax; j++) - for (int x = 0; x < XMAX; x++) - at[i][j][x] = at_make(i, j, x); + for (int x = 0; x < XMAX; x++) at[i][j][x] = at_make(i, j, x); for (int i = 0; i <= nmax; i++) - for (int x = 0; x < PR->V; x++) - ru[i][x] = au_make(i, x); + for (int x = 0; x < PR->V; x++) ru[i][x] = au_make(i, x); //************ romax ****************** rtmax = rmin; @@ -107,22 +107,24 @@ void Probability::look(Size *N, System *sp) { //******************* scattering prob against u ****************** for (int i = 0; i <= nmax; i++) - for (int x = 0; x < PR->V; x++) - ru[i][x] /= rumax[x]; + for (int x = 0; x < PR->V; x++) ru[i][x] /= rumax[x]; for (int x = 0; x < PR->V; x++) - for (int b = 0; b < 2; b++) //b=0 corresconds "oh=dir" : b =(oh==dir)? 0: 1; - for (int i = 0; i <= nmax; i++) { //state before scattering - int j = (b) ? i - 1 : i + 1; //state after scattering + for (int b = 0; b < 2; + b++) // b=0 corresconds "oh=dir" : b =(oh==dir)? 0: 1; + for (int i = 0; i <= nmax; i++) { // state before scattering + int j = (b) ? i - 1 : i + 1; // state after scattering if (j < 0 || j > nmax) u[b][i][x] = 0.0; else if (ru[i][x] <= ru[j][x]) u[b][i][x] = 1.0; else - u[b][i][x] = Tuab(i, j, x); //when i is larger(L), if L->S then P = S/L, if L->L then 1.0 - S/L. + u[b][i][x] = Tuab(i, j, x); // when i is larger(L), if L->S then P = + // S/L, if L->L then 1.0 - S/L. } - //****************** scattering prob against t ********************************* + //****************** scattering prob against t + //********************************* int flaver = 4; for (int x = 0; x < XMAX; x++) { @@ -139,21 +141,19 @@ void Probability::look(Size *N, System *sp) { if (h == i) type = 5; else { - type = 0; + type = 0; Om[0].val = at[i][j][x]; Om[1].val = at[i + oh][j][x]; Om[2].val = (j != h) ? tb : 0.0; Om[3].val = (j == h) ? tb : 0.0; } - for (int k = 0; k < 4; k++) - Om[k].num = k; + for (int k = 0; k < 4; k++) Om[k].num = k; qsort(Om, 4, sizeof(Omega), Pcomp); - for (int k = 0; k < 4; k++) - Tr[Om[k].num] = k; // sorted + for (int k = 0; k < 4; k++) Tr[Om[k].num] = k; // sorted if (type != 5) SolveWeightEquation(flaver); // - //if(type!=5) Color(flaver); + // if(type!=5) Color(flaver); for (int b = 0; b < 4; b++) // before update for (int a = 0; a < 4; a++) { // after update @@ -166,9 +166,11 @@ void Probability::look(Size *N, System *sp) { //***************************************************** #ifdef DEBUG if (x == 0) - std::cout << "h=" << h << " a=" << a << " b=" << b << " i=" << i << " j=" << j << " type=" << type - << " Om[0]=" << Om[0].val << " Om[1]=" << Om[1].val << " Om[2]=" << Om[2].val - << " Om[3]=" << Om[3].val << " sql=" << sql << " a_t=" << at[i][j][x] + std::cout << "h=" << h << " a=" << a << " b=" << b << " i=" << i + << " j=" << j << " type=" << type + << " Om[0]=" << Om[0].val << " Om[1]=" << Om[1].val + << " Om[2]=" << Om[2].val << " Om[3]=" << Om[3].val + << " sql=" << sql << " a_t=" << at[i][j][x] << " t =" << t[h][a][b][i][j][x] << std::endl; #endif } @@ -183,18 +185,16 @@ void Probability::Color(int cmax) { ex_Wall[i] = ex_Penki[i] = Om[i].val; } for (int i = 0; i < cmax; i++) - for (int p = 0; p < cmax; p++) - Wall[i][p] = 0.0; + for (int p = 0; p < cmax; p++) Wall[i][p] = 0.0; double total_Penki, paint; for (int penki = 0; penki < cmax - 1; penki++) { if (ex_Penki[penki] == 0.0) continue; total_Penki = 0.0; - for (int kabe = penki + 1; kabe < cmax; kabe++) - total_Penki += Om[kabe].val; + for (int kabe = penki + 1; kabe < cmax; kabe++) total_Penki += Om[kabe].val; for (int kabe = penki + 1; kabe < cmax; kabe++) { - paint = ex_Wall[penki] * (Om[kabe].val / total_Penki); + paint = ex_Wall[penki] * (Om[kabe].val / total_Penki); // paint `kabe` wall by `penki` penki. Wall[kabe][penki] = paint; // paint `penki` wall by `kabe` penki. @@ -217,8 +217,7 @@ void Probability::SolveWeightEquation(int cmax) { ex_Wall[cmax - 1 - i] = ex_Penki[cmax - 1 - i] = Om[i].val; } for (int i = 0; i < cmax; i++) - for (int p = 0; p < cmax; p++) - Wall[i][p] = 0.0; + for (int p = 0; p < cmax; p++) Wall[i][p] = 0.0; int p, q; double V_first; @@ -235,9 +234,9 @@ void Probability::SolveWeightEquation(int cmax) { for (p = 0; p < cmax; p++) if (ex_Wall[p] != V_first) break; N_first = p; - if (p == cmax) { //all are same + if (p == cmax) { // all are same V_second = 0.0; - V_third = 0.0; + V_third = 0.0; N_second = 0; } else { V_second = ex_Wall[p]; @@ -262,15 +261,15 @@ void Probability::SolveWeightEquation(int cmax) { double x = V_first - V_second; double y = (double)(N_second - 1) * (V_second - V_third); if (x < y) { - dw1 = (V_first - V_second) / (1.0 - 1.0 / (double)(N_second)); - dw2 = dw1 / (double)N_second; + dw1 = (V_first - V_second) / (1.0 - 1.0 / (double)(N_second)); + dw2 = dw1 / (double)N_second; V_second_new = V_second - dw2; - V_first_new = V_second_new; + V_first_new = V_second_new; } else { - dw2 = V_second - V_third; - dw1 = dw2 * (double)N_second; + dw2 = V_second - V_third; + dw1 = dw2 * (double)N_second; V_second_new = V_third; - V_first_new = V_first - dw1; + V_first_new = V_first - dw1; } ex_Wall[0] = V_first_new; for (int i = 1; i < 1 + N_second; i++) { @@ -316,13 +315,13 @@ double Probability::au_make(int p, int x) { } Probability::Probability(Size *N, System *sp, Parallel *m_PR) { - PR = m_PR; - Ubb = sp->Ubb; - V1 = sp->Vb1; + PR = m_PR; + Ubb = sp->Ubb; + V1 = sp->Vb1; nmax = sp->nmax; - tb = sp->tb; - z = 2.0 * N->d; + tb = sp->tb; + z = 2.0 * N->d; XMAX = 2; newcall_zero(ep, PR->V); @@ -349,7 +348,7 @@ Probability::Probability(Size *N, System *sp, Parallel *m_PR) { void Probability::LocalPotential(double mu) { mu1[0] = -mu; mu1[1] = -mu; - double A0 = 1.0; //staggerd lattice + double A0 = 1.0; // staggerd lattice for (int z = 0; z < PR->z; z++) for (int y = 0; y < PR->y; y++) @@ -361,15 +360,14 @@ void Probability::LocalPotential(double mu) { char fname[256]; sprintf(fname, "potential_S%02dT%02dR%03d", PR->ns, PR->nt, PR->nr); std::ofstream fout(fname); - for (int i = 0; i < PR->V; i++) - fout << i << " " << ep[i] << endl; + for (int i = 0; i < PR->V; i++) fout << i << " " << ep[i] << endl; fout.close(); #endif } void Probability::LookUpTable(Size *N, System *sp) { - dim = sp->mu / z; - Nx = N->x; + dim = sp->mu / z; + Nx = N->x; LocalPotential(sp->mu); look(N, sp); for (int x = 0; x < XMAX; x++) { @@ -380,8 +378,7 @@ void Probability::LookUpTable(Size *N, System *sp) { weight[4] = weight[5] = tb; for (int i = 0; i < 6; i++) - for (int j = 0; j < 6; j++) - FracW[j][i][x] = weight[i] / weight[j]; + for (int j = 0; j < 6; j++) FracW[j][i][x] = weight[i] / weight[j]; } } diff --git a/src/pmwa/probability.H.cpp b/src/pmwa/probability.H.cpp index d478dcf6..10d987af 100644 --- a/src/pmwa/probability.H.cpp +++ b/src/pmwa/probability.H.cpp @@ -1,11 +1,11 @@ +#include #include #include + #include -#include #include "mpi.h" - int Pcomp(const void *p, const void *q) { double x, y; x = ((Probability::Omega *)p)->val; @@ -24,7 +24,7 @@ void Probability::look(Size *N, System *sp) { double sql; int h; - local_Et = 0.0; //local energy shift + local_Et = 0.0; // local energy shift double rmin = 0.0, Ri; // search the minimum value of the vertex density. @@ -32,13 +32,15 @@ void Probability::look(Size *N, System *sp) { for (int j = 0; j <= nmax; j++) { for (int x = 0; x < XMAX; x++) { Ri = at_make(i, j, x); - if (Ri <= rmin) { rmin = Ri; } + if (Ri <= rmin) { + rmin = Ri; + } } } } local_Et = tb - rmin; - sp->Et = z / 2.0 * N->V * local_Et; + sp->Et = z / 2.0 * N->V * local_Et; //////// @@ -54,8 +56,7 @@ void Probability::look(Size *N, System *sp) { } sp->Eu = 0.0; - for (int x = 0; x < PR->V; x++) - sp->Eu += local_Eu[x]; + for (int x = 0; x < PR->V; x++) sp->Eu += local_Eu[x]; MPI_Status status; MPI_Comm comm_nst0; @@ -75,7 +76,7 @@ void Probability::look(Size *N, System *sp) { for (int tag = 0; tag < PR->NtNs; tag++) { sp->Eu += peu[tag]; } - sp->Eu /= (double)PR->Ntdiv; //double count for Ntdiv + sp->Eu /= (double)PR->Ntdiv; // double count for Ntdiv delcall(peu); MPI_Comm_free(&comm_nst0); @@ -83,17 +84,15 @@ void Probability::look(Size *N, System *sp) { cout << "rank=" << PR->my_rank << ":: global Eu = " << sp->Eu << endl; //////// - rh_odd = sp->Htr; + rh_odd = sp->Htr; rh_even = sp->Htr; //************ at ************** for (int i = 0; i <= nmax; i++) for (int j = 0; j <= nmax; j++) - for (int x = 0; x < XMAX; x++) - at[i][j][x] = at_make(i, j, x); + for (int x = 0; x < XMAX; x++) at[i][j][x] = at_make(i, j, x); for (int i = 0; i <= nmax; i++) - for (int x = 0; x < PR->V; x++) - ru[i][x] = au_make(i, x); + for (int x = 0; x < PR->V; x++) ru[i][x] = au_make(i, x); //*************romax****************** rtmax = rmin; for (int i = 0; i <= nmax; i++) @@ -106,24 +105,27 @@ void Probability::look(Size *N, System *sp) { if (rumax[x] < ru[i][x]) rumax[x] = ru[i][x]; //******************* scattering prob against u ****************** for (int i = 0; i <= nmax; i++) - for (int x = 0; x < PR->V; x++) - ru[i][x] /= rumax[x]; + for (int x = 0; x < PR->V; x++) ru[i][x] /= rumax[x]; for (int x = 0; x < PR->V; x++) - for (int b = 0; b < 2; b++) //b=0 corresconds "oh=dir" : b =(oh==dir)? 0: 1; - for (int i = 0; i <= nmax; i++) { //state before scattering - int j = (b) ? i - 1 : i + 1; //state after scattering + for (int b = 0; b < 2; + b++) // b=0 corresconds "oh=dir" : b =(oh==dir)? 0: 1; + for (int i = 0; i <= nmax; i++) { // state before scattering + int j = (b) ? i - 1 : i + 1; // state after scattering if (j < 0 || j > nmax) u[b][i][x] = 0.0; else if (ru[i][x] <= ru[j][x]) u[b][i][x] = 1.0; else - u[b][i][x] = Tuab(i, j, x); //when i is larger(L), if L->S then P = S/L, if L->L then 1.0 - S/L. + u[b][i][x] = Tuab(i, j, x); // when i is larger(L), if L->S then P = + // S/L, if L->L then 1.0 - S/L. - // if(PR->my_rank==0)cout <<"x="<Ubb; - V1 = sp->Vb1; + PR = m_PR; + Ubb = sp->Ubb; + V1 = sp->Vb1; nmax = sp->nmax; - tb = 0.5 * sp->tb; - z = 2.0 * N->d; + tb = 0.5 * sp->tb; + z = 2.0 * N->d; XMAX = 2; newcall_zero(ep, PR->V); @@ -357,10 +354,10 @@ Probability::Probability(Size *N, System *sp, Parallel *m_PR) { } void Probability::LocalPotential(double mu) { - mu1[0] = -mu ; - mu1[1] = -mu ; + mu1[0] = -mu; + mu1[1] = -mu; - double A0 = 1.0; //staggerd lattice + double A0 = 1.0; // staggerd lattice for (int z = 0; z < PR->z; z++) for (int y = 0; y < PR->y; y++) for (int x = 0; x < PR->x; x++) { @@ -371,15 +368,14 @@ void Probability::LocalPotential(double mu) { char fname[256]; sprintf(fname, "potential_S%02dT%02dR%03d", PR->ns, PR->nt, PR->nr); std::ofstream fout(fname); - for (int i = 0; i < PR->V; i++) - fout << i << " " << ep[i] << endl; + for (int i = 0; i < PR->V; i++) fout << i << " " << ep[i] << endl; fout.close(); #endif } void Probability::LookUpTable(Size *N, System *sp) { - dim = sp->mu / z; - Nx = N->x; + dim = sp->mu / z; + Nx = N->x; LocalPotential(sp->mu); look(N, sp); @@ -391,8 +387,7 @@ void Probability::LookUpTable(Size *N, System *sp) { weight[4] = weight[5] = tb; for (int i = 0; i < 6; i++) - for (int j = 0; j < 6; j++) - FracW[j][i][x] = weight[i] / weight[j]; + for (int j = 0; j < 6; j++) FracW[j][i][x] = weight[i] / weight[j]; } } diff --git a/src/pmwa/quantities.B.cpp b/src/pmwa/quantities.B.cpp index 7c9f5b3b..872a614a 100644 --- a/src/pmwa/quantities.B.cpp +++ b/src/pmwa/quantities.B.cpp @@ -4,17 +4,18 @@ //#define XSTEPALL //#include -Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Parallel *m_PR, std::string const &outfile) { - Npara = m_PR->Npara; +Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, + Parallel *m_PR, std::string const &outfile) { + Npara = m_PR->Npara; my_rank = m_PR->my_rank; MC = m_MC; - N = m_N; + N = m_N; LT = m_LT; PR = m_PR; sp = m_sp; - V = PR->V; + V = PR->V; Nx = PR->x; NL[0] = N->x; @@ -39,17 +40,17 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral #endif Nkxmax = N->x / Nkstep; - Nxmax = N->x / Nxstep; - Nkmax = Nkxmax * 2; //i.e. kx=ky=kz, kx!=ky=kz=0 + Nxmax = N->x / Nxstep; + Nkmax = Nkxmax * 2; // i.e. kx=ky=kz, kx!=ky=kz=0 Nkkmax = Nkxmax; - Nend = Nq - 3; //Mx's number + Nend = Nq - 3; // Mx's number newcall_zero(Lmax, Nc); newcall_zero(Lsum, Nc); Lsum[mz] = Lmax[mz] = V; - Lmax[cr2] = Nxmax; + Lmax[cr2] = Nxmax; // Lmax[sk]=Nkmax*2;//i.e. real and imaginary part Lmax[ck2] = Nkmax * 2; //#ifdef GF22Gk2 @@ -59,16 +60,14 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral //#endif Lmax[ck4] = Nkxmax * Nkkmax * 2; Lmax[dkk] = Nkxmax * Nkkmax; - Lmax[nw] = V; + Lmax[nw] = V; Lmax[nw2] = V; - Lmax[lw] = V; + Lmax[lw] = V; - Lsize = 0; //sin,cos,Nk,Sk + Lsize = 0; // sin,cos,Nk,Sk - for (int i = 1; i < Nc; i++) - Lsum[i] = Lsum[i - 1] + Lmax[i]; - for (int i = 0; i < Nc; i++) - Lsize += Lmax[i]; + for (int i = 1; i < Nc; i++) Lsum[i] = Lsum[i - 1] + Lmax[i]; + for (int i = 0; i < Nc; i++) Lsize += Lmax[i]; newcall_zero(file, Nc + Nq, 128); newcall_zero(Qname, Nc + Nq, 128); @@ -76,48 +75,48 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral int NVMAX, NWMAX; // sprintf(parainfo,"B%.1lf_Nx%d_Ny%d_Vbb%.1lf",N->B,N->x,N->y,sp->Vb1); - sprintf(Qname[wndx], "wndx"); //Winding Number for x-axis - sprintf(Qname[wndy], "wndy"); //Winding Number for y-axis - sprintf(Qname[wndz], "wndz"); //Winding Number for z-axis - sprintf(Qname[wnd2], "wnd2"); //square of Winding Number - sprintf(Qname[amzu], "amzu"); //Density or z-Magnetization - sprintf(Qname[bmzu], "bmzu"); //Density or z-Magnetization - sprintf(Qname[ene], "ene "); //Energy - sprintf(Qname[nver], "nver"); //Number of vertices - sprintf(Qname[spe], "spe "); //Specific heat - sprintf(Qname[nwor], "nwor"); //Number of worms - sprintf(Qname[xmx], "xmx "); //Susceptibility - sprintf(Qname[nkin], "nkin"); //Number of kinks - sprintf(Qname[comp], "comp"); //Compressibility - sprintf(Qname[lxmx], "lxmx"); //Compressibility - sprintf(Qname[magx], "bmxu"); //BEC order parameter or xmag - sprintf(Qname[magp], "bmpu"); //BEC order parameter or +mag - sprintf(Qname[magm], "bmmu"); //BEC order parameter or -mag - sprintf(Qname[smzu], "smzu"); //structure factor (uniform) - sprintf(Qname[smzs], "smzs"); //structure factor (staggerd) - sprintf(Qname[xmzu], "xmzu"); //structure factor (uniform) - sprintf(Qname[xmzs], "xmzs"); //structure factor (staggerd) + sprintf(Qname[wndx], "wndx"); // Winding Number for x-axis + sprintf(Qname[wndy], "wndy"); // Winding Number for y-axis + sprintf(Qname[wndz], "wndz"); // Winding Number for z-axis + sprintf(Qname[wnd2], "wnd2"); // square of Winding Number + sprintf(Qname[amzu], "amzu"); // Density or z-Magnetization + sprintf(Qname[bmzu], "bmzu"); // Density or z-Magnetization + sprintf(Qname[ene], "ene "); // Energy + sprintf(Qname[nver], "nver"); // Number of vertices + sprintf(Qname[spe], "spe "); // Specific heat + sprintf(Qname[nwor], "nwor"); // Number of worms + sprintf(Qname[xmx], "xmx "); // Susceptibility + sprintf(Qname[nkin], "nkin"); // Number of kinks + sprintf(Qname[comp], "comp"); // Compressibility + sprintf(Qname[lxmx], "lxmx"); // Compressibility + sprintf(Qname[magx], "bmxu"); // BEC order parameter or xmag + sprintf(Qname[magp], "bmpu"); // BEC order parameter or +mag + sprintf(Qname[magm], "bmmu"); // BEC order parameter or -mag + sprintf(Qname[smzu], "smzu"); // structure factor (uniform) + sprintf(Qname[smzs], "smzs"); // structure factor (staggerd) + sprintf(Qname[xmzu], "xmzu"); // structure factor (uniform) + sprintf(Qname[xmzs], "xmzs"); // structure factor (staggerd) // sprintf(Qname[d00] ,"d00"); //noise correlation at k=0 - sprintf(Qname[len], "len"); //correlation length + sprintf(Qname[len], "len"); // correlation length - sprintf(Qname[Nq + mz], "mz"); //Local density or local mz - sprintf(Qname[Nq + cr2], "cr2"); //2-points correlation (mx-mx) + sprintf(Qname[Nq + mz], "mz"); // Local density or local mz + sprintf(Qname[Nq + cr2], "cr2"); // 2-points correlation (mx-mx) // sprintf(Qname[Nq+sk] ,"sk"); //structure factor - sprintf(Qname[Nq + ck2], "ck2"); //k-space of cr2 + sprintf(Qname[Nq + ck2], "ck2"); // k-space of cr2 // sprintf(Qname[Nq+cr4],"cr4"); //4-points correlation - sprintf(Qname[Nq + ck4], "ck4"); //k-space of cr4 - sprintf(Qname[Nq + dkk], "dkk"); //Noise correlation - sprintf(Qname[Nq + nw], "nw"); //local number of worms - sprintf(Qname[Nq + nw2], "nw2"); //square of nw - sprintf(Qname[Nq + lw], "lw"); //square of nw + sprintf(Qname[Nq + ck4], "ck4"); // k-space of cr4 + sprintf(Qname[Nq + dkk], "dkk"); // Noise correlation + sprintf(Qname[Nq + nw], "nw"); // local number of worms + sprintf(Qname[Nq + nw2], "nw2"); // square of nw + sprintf(Qname[Nq + lw], "lw"); // square of nw int S = Nc + Nq; - // newcall_zero(values_S, Nq1); + // newcall_zero(values_S, Nq1); newcall_zero(values_S, Nq); newcall_zero(MCmean_S, Nq * 2); newcall_zero(BINmean_S, Nq * 2 * MC->Nbin); - //newcall_zero(RNDmean_S,Nq*2*PR->Npara); + // newcall_zero(RNDmean_S,Nq*2*PR->Npara); newcall_zero(values_L, Lsize); newcall_zero(MCmean_L, Lsize * 2); @@ -130,7 +129,7 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral // newcall_zero(COSnp,V); // newcall_zero(SINnp,V); - Cknum = 16; + Cknum = 16; Nk_set = 5 + 2 * Nkmax * Cknum; Sk_set = 2; @@ -143,14 +142,15 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral int y = (int)(i / Nx) % PR->y + PR->ny * PR->y; int z = (int)(i / (Nx * PR->y)) + PR->nz * PR->z; - for (int k = -Nkmax + 1; k < Nkmax; k++) { //max(kx+kk)=Nkkmax-1 + Nkxmax-1 + for (int k = -Nkmax + 1; k < Nkmax; k++) { // max(kx+kk)=Nkkmax-1 + + // Nkxmax-1 - double phase = 2.0 * PI * x * k / (double)Nkxmax; //kx!=0,ky=kz=0 + double phase = 2.0 * PI * x * k / (double)Nkxmax; // kx!=0,ky=kz=0 complex phase_c(0.0, phase); EXPrk[theta(i, k, 0)] = exp(phase_c); - phase = 2.0 * PI * (x + y + z) * k / (double)Nkxmax; //kx=ky - phase_c = complex(0.0, phase); + phase = 2.0 * PI * (x + y + z) * k / (double)Nkxmax; // kx=ky + phase_c = complex(0.0, phase); EXPrk[theta(i, k, 1)] = exp(phase_c); } @@ -158,8 +158,8 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral // if((x+y+z)%2==0) COSnp[i]=1.0; // else COSnp[i]=-1.0; - //COSnp[i]=cos(phasep); - //SINnp[i]=sin(phasep); + // COSnp[i]=cos(phasep); + // SINnp[i]=sin(phasep); } newcall_zero(an, V); @@ -184,7 +184,7 @@ Quantities::~Quantities() { delcall(values_L); delcall(MCmean_L); delcall(BINmean_L); - //delcall(RNDmean_L); + // delcall(RNDmean_L); delcall(m_val); @@ -203,34 +203,32 @@ Quantities::~Quantities() { } void Quantities::Init() { - for (int i = 0; i < Nq1; i++) - values_S[i] = 0; - for (int i = 0; i < Lsize; i++) - values_L[i] = 0; - for (int i = 0; i < Nq * 2; i++) - MCmean_S[i] = 0; - for (int i = 0; i < Lsize * 2; i++) - MCmean_L[i] = 0; + for (int i = 0; i < Nq1; i++) values_S[i] = 0; + for (int i = 0; i < Lsize; i++) values_L[i] = 0; + for (int i = 0; i < Nq * 2; i++) MCmean_S[i] = 0; + for (int i = 0; i < Lsize * 2; i++) MCmean_L[i] = 0; // for( int i=0; iNpara; i++ ) RNDmean_S[i]=0; // for( int i=0; iNpara; i++ ) RNDmean_L[i]=0; } -void Quantities::Measure(int Nv, int Nk, vector &ev, vector WORM, - GraphSpace::Vertex *world, GraphSpace::Vertex *worldB, double length, int m_Wnum, int mcs) { +void Quantities::Measure(int Nv, int Nk, vector &ev, + vector WORM, + GraphSpace::Vertex *world, GraphSpace::Vertex *worldB, + double length, int m_Wnum, int mcs) { NVMAX = max(NVMAX, m_Wnum + Nv); NWMAX = max(NWMAX, m_Wnum); - WindingNumber(ev, mcs); //no MPI - NumberOfVertices(m_Wnum + Nv, mcs); //no MPI - NumberOfWorms(ev, mcs); //noMPI - NumberOfKinks(Nk, mcs); //no MPI - CondensateFraction(mcs, world); //MPI in correlation function1,2 - Density(world, worldB); //no MPI + WindingNumber(ev, mcs); // no MPI + NumberOfVertices(m_Wnum + Nv, mcs); // no MPI + NumberOfWorms(ev, mcs); // noMPI + NumberOfKinks(Nk, mcs); // no MPI + CondensateFraction(mcs, world); // MPI in correlation function1,2 + Density(world, worldB); // no MPI CorrelationLength(length); SUM_OVER_T(); // for local nw and mz SUM_OVER_S(); // for amzu - SUM_OVER_ST(); //for values_S + SUM_OVER_ST(); // for values_S // cout<<"Sk"< " << endl; F << setprecision(16); for (int l = 0; l < Nx; l++) { - R = l; - k = f_ld(l) * 2; + R = l; + k = f_ld(l) * 2; Cname = "real_" + tostr(R); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //Local worm density + // Local worm density F.open(file[Nq + nw], std::ios::app); F << "# Local worm density." << endl; F << "# R x-SITE " << endl; F << setprecision(16); for (int l = 0; l < Nx; l++) { - R = l; - k = f_nw(l) * 2; + R = l; + k = f_nw(l) * 2; Cname = "real_" + tostr(R); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //worm length + // worm length F.open(file[Nq + lw], std::ios::app); F << "# worm length." << endl; F << "# R x-SITE " << endl; F << setprecision(16); for (int l = 0; l < V; l++) { - R = l; - k = f_lw(l) * 2; + R = l; + k = f_lw(l) * 2; Cname = "real_" + tostr(R); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //Local susceptibility + // Local susceptibility F.open(file[Nq + nw2], std::ios::app); F << "# Local susceptibility." << endl; F << "# R x-SITE " << endl; F << setprecision(16); for (int l = 0; l < Nx; l++) { - R = l; - k = f_nw2(l) * 2; + R = l; + k = f_nw2(l) * 2; Cname = "real_" + tostr(R); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //GF + // GF F.open(file[Nq + cr2], std::ios::app); F << "#2-point Correlation with sites." << endl; F << "# R x-distance " << endl; F << setprecision(16); for (int l = 0; l < Lmax[cr2]; l++) { - R = l * Nxstep; - k = f_gf(l) * 2; + R = l * Nxstep; + k = f_gf(l) * 2; Cname = "real_" + tostr(R); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //nk + // nk F.open(file[Nq + ck2], std::ios::app); F << "# 2-point Correlation with wave numbers." << endl; F << "# real/imag kx ky " << endl; F << setprecision(16); for (int l = 0; l < Lmax[ck2]; l++) { - R = l % Nkxmax; - Ry = ((int)(l / Nkxmax) % 2) * R; - ll = ((bool)(l / Nkmax)) ? "imag" : "real"; - k = f_nk(l) * 2; + R = l % Nkxmax; + Ry = ((int)(l / Nkxmax) % 2) * R; + ll = ((bool)(l / Nkmax)) ? "imag" : "real"; + k = f_nk(l) * 2; Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(Ry * Nkstep); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //4-point correlation + // 4-point correlation F.open(file[Nq + ck4], std::ios::app); F << "# 4-point Correlation with wave numbers." << endl; F << "# kx kx' " << endl; F << setprecision(16); for (int l = 0; l < Lmax[ck4]; l++) { - k = f_gk2(l) * 2; - R = l % Nkxmax; - R_ = (int)(l / Nkxmax) % Nkkmax; + k = f_gk2(l) * 2; + R = l % Nkxmax; + R_ = (int)(l / Nkxmax) % Nkkmax; bool kl = l / (Nkkmax * Nkxmax); - ll = (kl) ? "imag" : "real"; // real or imag - Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(R_ * Nkstep); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + ll = (kl) ? "imag" : "real"; // real or imag + Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(R_ * Nkstep); + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; if (R == Nkxmax - 1) F << endl; } F.close(); - //noise correlation + // noise correlation F.open(file[Nq + dkk], std::ios::app); F << "# Noise Correlation with wave numbers." << endl; F << "# kx kx' " << endl; F << setprecision(16); for (int l = 0; l < Lmax[dkk]; l++) { - k = f_noise(l) * 2; - R = l % Nkxmax; - R_ = (int)(l / Nkxmax); - ll = "real"; + k = f_noise(l) * 2; + R = l % Nkxmax; + R_ = (int)(l / Nkxmax); + ll = "real"; Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(R_ * Nkstep); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; if (R == Nkxmax - 1) F << endl; } @@ -457,10 +465,10 @@ void Quantities::show(ofstream &F, FILE *SFF) { } ////// -void Quantities::Output(std::string const & fname, double g) { - +void Quantities::Output(std::string const &fname, double g) { std::ofstream file(fname.c_str(), std::ios::app); - file << sp->Htr << " " << sp->mu << " " << sp->Vb1 << " " << sp->tb << " " << N->B << " " << g << std::endl; + file << sp->Htr << " " << sp->mu << " " << sp->Vb1 << " " << sp->tb << " " + << N->B << " " << g << std::endl; } //########################################################################################## @@ -474,7 +482,10 @@ void Quantities::WindingNumber(vector &ev, int mcs) { while (it != ev.end()) { int l = it->i / V; - if ((it->type == 2 && /*LT->bd[it->i%V][l*2] == it->nleg->i%V &&*/ it->i % V < it->nleg->i % V) || it->type == -1) { + if ((it->type == 2 && + /*LT->bd[it->i%V][l*2] == it->nleg->i%V &&*/ it->i % V < + it->nleg->i % V) || + it->type == -1) { int crr = (it->p < it->next[0]->p) ? 1 : -1; for (int d = 0; d < N->d; d++) if (LT->bond_vec[l][d] != 0.0) Wi[d] += crr; @@ -486,7 +497,6 @@ void Quantities::WindingNumber(vector &ev, int mcs) { for (int d = 0; d < N->d; d++) { values_S[wndx + d] = (double)Wi[d]; } //(double)NL[d]; } - } void Quantities::WindingNumber2() { @@ -496,16 +506,18 @@ void Quantities::WindingNumber2() { ww += MCmean_S[(wndx + d) * 2 + 1]; } - MCmean_S[wnd2 * 2] = ww; + MCmean_S[wnd2 * 2] = ww; MCmean_S[wnd2 * 2 + 1] = ww * ww; } -void Quantities::Density(GraphSpace::Vertex *world, GraphSpace::Vertex *worldB) { +void Quantities::Density(GraphSpace::Vertex *world, + GraphSpace::Vertex *worldB) { double atot = 0.0, btot = 0.0, stot = 0.0, xtot = 0.0; for (int i = 0; i < V; i++) { double n0 = 0.0; - for (GraphSpace::Vertex *wl = &(world[i]); wl != &(worldB[i]); wl = wl->next[1]) { + for (GraphSpace::Vertex *wl = &(world[i]); wl != &(worldB[i]); + wl = wl->next[1]) { n0 += (wl->next[1]->t - wl->t) * (wl->p); } @@ -530,12 +542,16 @@ void Quantities::Density(GraphSpace::Vertex *world, GraphSpace::Vertex *worldB) void Quantities::Compressibility() { MCmean_S[comp * 2] = - N->B * N->V * (MCmean_S[smzu * 2] / (MCmean_S[amzu * 2] * MCmean_S[amzu * 2] * (double)N->V) - 1.0); + N->B * N->V * + (MCmean_S[smzu * 2] / + (MCmean_S[amzu * 2] * MCmean_S[amzu * 2] * (double)N->V) - + 1.0); MCmean_S[comp * 2 + 1] = MCmean_S[comp * 2] * MCmean_S[comp * 2]; } void Quantities::Energy() { - MCmean_S[ene * 2] = (sp->Eu + sp->Et - MCmean_S[nver * 2] / N->B) / (double)N->V; + MCmean_S[ene * 2] = + (sp->Eu + sp->Et - MCmean_S[nver * 2] / N->B) / (double)N->V; MCmean_S[ene * 2 + 1] = MCmean_S[ene * 2] * MCmean_S[ene * 2]; } @@ -545,13 +561,14 @@ void Quantities::NumberOfVertices(int countv, int mcs) { void Quantities::SpecificHeat() { MCmean_S[spe * 2] = - (MCmean_S[nver * 2 + 1] - MCmean_S[nver * 2] * MCmean_S[nver * 2] - MCmean_S[nver * 2]) / (double)N->V; + (MCmean_S[nver * 2 + 1] - MCmean_S[nver * 2] * MCmean_S[nver * 2] - + MCmean_S[nver * 2]) / + (double)N->V; MCmean_S[spe * 2 + 1] = MCmean_S[spe * 2] * MCmean_S[spe * 2]; } void Quantities::NumberOfWorms(vector &ev, int mcs) { - for (int i = 0; i < V; i++) - values_L[f_nw(i)] = 0; + for (int i = 0; i < V; i++) values_L[f_nw(i)] = 0; int Nw = 0; vector::iterator it = ev.begin(); @@ -567,24 +584,24 @@ void Quantities::NumberOfWorms(vector &ev, int mcs) { values_S[nwor] = Nw; } -void Quantities::NumberOfKinks(int Nk, int mcs) { - values_S[nkin] = Nk; -} +void Quantities::NumberOfKinks(int Nk, int mcs) { values_S[nkin] = Nk; } void Quantities::Susceptibility() { double lx = 0.0; for (int i = 0; i < V; i++) { MCmean_L[f_nw2(i)] = - (MCmean_L[f_nw2(i)] - MCmean_L[f_nw(i)] * MCmean_L[f_nw(i)]) / (4.0 * N->B * sp->Htr * sp->Htr); + (MCmean_L[f_nw2(i)] - MCmean_L[f_nw(i)] * MCmean_L[f_nw(i)]) / + (4.0 * N->B * sp->Htr * sp->Htr); lx += MCmean_L[f_nw2(i)]; } - MCmean_S[lxmx * 2] = lx / (double)V; + MCmean_S[lxmx * 2] = lx / (double)V; MCmean_S[lxmx * 2 + 1] = MCmean_S[lxmx * 2] * MCmean_S[lxmx * 2]; MCmean_S[xmx * 2] = - (MCmean_S[nwor * 2 + 1] - MCmean_S[nwor * 2] * MCmean_S[nwor * 2]) / (4.0 * N->V * N->B * sp->Htr * sp->Htr); + (MCmean_S[nwor * 2 + 1] - MCmean_S[nwor * 2] * MCmean_S[nwor * 2]) / + (4.0 * N->V * N->B * sp->Htr * sp->Htr); MCmean_S[xmx * 2 + 1] = MCmean_S[xmx * 2] * MCmean_S[xmx * 2]; } @@ -605,7 +622,7 @@ void Quantities::CondensateFraction(int mcs, GraphSpace::Vertex *world) { values_S[magm] = ctot / PR->Ntdiv; #ifdef CFOUT CorrelationFunction1(); - //CorrelationFunction2(world); + // CorrelationFunction2(world); #endif } @@ -614,12 +631,12 @@ void Quantities::CorrelationLength(double length) { values_S[len] = length; } //////////////////////////////////// void Quantities::SUM_OVER_T() { - if (PR->nt == 0) { //Sum over t + if (PR->nt == 0) { // Sum over t for (int tag = 1; tag < PR->Ntdiv; tag++) { - MPI_Recv(m_val, V * 2, MPI_DOUBLE, tag + PR->nt0, 0, MPI_COMM_WORLD, &status); - for (int i = 0; i < V * 2; i++) - values_L[f_ld(i)] += m_val[i]; + MPI_Recv(m_val, V * 2, MPI_DOUBLE, tag + PR->nt0, 0, MPI_COMM_WORLD, + &status); + for (int i = 0; i < V * 2; i++) values_L[f_ld(i)] += m_val[i]; } for (int i = 0; i < V; i++) { @@ -627,19 +644,21 @@ void Quantities::SUM_OVER_T() { } } else { - MPI_Send(&(values_L[f_ld(0)]), V * 2, MPI_DOUBLE, PR->nt0, 0, MPI_COMM_WORLD); + MPI_Send(&(values_L[f_ld(0)]), V * 2, MPI_DOUBLE, PR->nt0, 0, + MPI_COMM_WORLD); } } ///////// void Quantities::SUM_OVER_S() { - if (PR->ns == 0) { //Sum over s at same tau + if (PR->ns == 0) { // Sum over s at same tau double Norm = PR->Ntdiv; for (int tag = 1; tag < PR->Nsdiv; tag++) { - MPI_Recv(m_val, 2, MPI_DOUBLE, tag * PR->Ntdiv + PR->ns0, 0, MPI_COMM_WORLD, &status); + MPI_Recv(m_val, 2, MPI_DOUBLE, tag * PR->Ntdiv + PR->ns0, 0, + MPI_COMM_WORLD, &status); values_S[amzu] += m_val[0]; values_S[smzs] += m_val[1]; @@ -661,10 +680,11 @@ void Quantities::SUM_OVER_S() { ///////// void Quantities::SUM_OVER_ST() { - if (PR->nst == 0) { //Sum over t and s + if (PR->nst == 0) { // Sum over t and s for (int tag = 1; tag < PR->NtNs; tag++) { - MPI_Recv(m_val, Nq1, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, &status); + MPI_Recv(m_val, Nq1, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, + &status); for (int i = 0; i < Nq1; i++) { values_S[i] += m_val[i]; } @@ -682,30 +702,29 @@ void Quantities::SUM_OVER_ST() { values_S[bmzu] /= (double)N->V; } -void Quantities::CorrelationFunction1() { //real space +void Quantities::CorrelationFunction1() { // real space //***MPI sum for G double ntot = 0.0; - int Lcr2 = Lmax[cr2]; - int ixmax = Lcr2 / PR->Nxdiv; + int Lcr2 = Lmax[cr2]; + int ixmax = Lcr2 / PR->Nxdiv; double Norm; - for (int i = 0; i < Lcr2; i++) - values_L[f_gf(i)] = 0.0; + for (int i = 0; i < Lcr2; i++) values_L[f_gf(i)] = 0.0; - if (PR->nx == 0) { //Sum over x at same tau + if (PR->nx == 0) { // Sum over x at same tau for (int i = 0; i < ixmax; i++) { - int ixx = i * Nxstep; - this->Q[i] = an[ixx]; - this->Q[i + Lcr2] = cr[ixx]; + int ixx = i * Nxstep; + this->Q[i] = an[ixx]; + this->Q[i + Lcr2] = cr[ixx]; this->Q[i + 2 * Lcr2] = ca[ixx]; } for (int tag = 1; tag < PR->Nxdiv; tag++) { - MPI_Recv(m_val, ixmax * 3, MPI_DOUBLE, tag * PR->Ntdiv + PR->nx0, 0, MPI_COMM_WORLD, &status); - for (int i = 0; i < ixmax; i++) - this->Q[i + tag * ixmax] = m_val[i]; + MPI_Recv(m_val, ixmax * 3, MPI_DOUBLE, tag * PR->Ntdiv + PR->nx0, 0, + MPI_COMM_WORLD, &status); + for (int i = 0; i < ixmax; i++) this->Q[i + tag * ixmax] = m_val[i]; for (int i = 0; i < ixmax; i++) this->Q[i + tag * ixmax + Lcr2] = m_val[i + ixmax]; for (int i = 0; i < ixmax; i++) @@ -718,63 +737,66 @@ void Quantities::CorrelationFunction1() { //real space if (ix == ixx) values_L[f_gf(0)] += this->Q[ix + 2 * Lcr2] * 2.0; else - values_L[f_gf(rx)] += this->Q[ix] * this->Q[ixx + Lcr2] + this->Q[ix + Lcr2] * this->Q[ixx]; + values_L[f_gf(rx)] += this->Q[ix] * this->Q[ixx + Lcr2] + + this->Q[ix + Lcr2] * this->Q[ixx]; } Norm = 2.0 * Lcr2 * PR->Ntdiv * PR->Nydiv * PR->Nzdiv; - for (int i = 0; i < Lcr2; i++) - values_L[f_gf(i)] /= Norm; + for (int i = 0; i < Lcr2; i++) values_L[f_gf(i)] /= Norm; } else { for (int i = 0; i < ixmax; i++) { - int ixx = i * Nxstep; - this->Q[i] = an[ixx]; - this->Q[i + ixmax] = cr[ixx]; + int ixx = i * Nxstep; + this->Q[i] = an[ixx]; + this->Q[i + ixmax] = cr[ixx]; this->Q[i + 2 * ixmax] = cr[ixx]; } MPI_Send(this->Q, ixmax * 3, MPI_DOUBLE, PR->nx0, 0, MPI_COMM_WORLD); } - if (PR->nst == 0) { //Sum over t at x=0 + if (PR->nst == 0) { // Sum over t at x=0 for (int tag = 1; tag < PR->NtNs; tag++) { if ((tag / PR->Ntdiv) % PR->Nxdiv != 0) continue; - MPI_Recv(m_val, Lcr2, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, &status); - for (int i = 0; i < Lcr2; i++) - values_L[f_gf(i)] += m_val[i]; + MPI_Recv(m_val, Lcr2, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, + &status); + for (int i = 0; i < Lcr2; i++) values_L[f_gf(i)] += m_val[i]; } } else if (PR->nx == 0) { - MPI_Send(&(values_L[f_gf(0)]), Lcr2, MPI_DOUBLE, PR->nst0, 0, MPI_COMM_WORLD); + MPI_Send(&(values_L[f_gf(0)]), Lcr2, MPI_DOUBLE, PR->nst0, 0, + MPI_COMM_WORLD); } } -void Quantities::CorrelationFunction2(GraphSpace::Vertex *world) { //momentum space +void Quantities::CorrelationFunction2( + GraphSpace::Vertex *world) { // momentum space MPI_Status status; complex Nk2; ////G2/// - for (int i = 0; i < Nk_set; i++) - Ck[i] = complex(0.0, 0.0); + for (int i = 0; i < Nk_set; i++) Ck[i] = complex(0.0, 0.0); - double rootV = sqrt((double)N->V); + double rootV = sqrt((double)N->V); double rootV2 = N->V; double rootV3 = rootV2 * rootV; double rootV4 = rootV2 * rootV2; for (int r = 0; r < V; r++) { double ancr = an[r] * cr[r]; - double n = world[r].p; - double ck0 = ancr - n; - double nn = 1.0 - n; + double n = world[r].p; + double ck0 = ancr - n; + double nn = 1.0 - n; Ck[0] += ck0 / rootV2; Ck[1] += ancr / rootV2; Ck[2] += (ancr * ancr - n) / rootV4; Ck[3] += n / rootV2; - Ck[4] += (5.0 * ancr * ancr - 6.0 * n * ancr - 2.0 * nn * ancr + 2.0 * ancr + n * n + n * nn) / rootV4; + Ck[4] += (5.0 * ancr * ancr - 6.0 * n * ancr - 2.0 * nn * ancr + + 2.0 * ancr + n * n + n * nn) / + rootV4; for (int a = 0; a < 2; a++) { for (int k = 0; k < Nkmax; k++) { @@ -791,32 +813,35 @@ void Quantities::CorrelationFunction2(GraphSpace::Vertex *world) { //momentum s Ck[f_ck(k, 10, a)] += ck0 * an[r] * EXPrk[theta(r, -k, a)] / rootV3; Ck[f_ck(k, 11, a)] += ck0 * cr[r] * EXPrk[theta(r, k, a)] / rootV3; - Ck[f_ck(k, 12, a)] += (ancr - nn) * an[r] * EXPrk[theta(r, -k, a)] / rootV3; - Ck[f_ck(k, 13, a)] += (ancr - nn) * cr[r] * EXPrk[theta(r, k, a)] / rootV3; + Ck[f_ck(k, 12, a)] += + (ancr - nn) * an[r] * EXPrk[theta(r, -k, a)] / rootV3; + Ck[f_ck(k, 13, a)] += + (ancr - nn) * cr[r] * EXPrk[theta(r, k, a)] / rootV3; Ck[f_ck(k, 14, a)] += ancr * an[r] * EXPrk[theta(r, -k, a)] / rootV3; Ck[f_ck(k, 15, a)] += ancr * cr[r] * EXPrk[theta(r, k, a)] / rootV3; } for (int k = 1; k < Nkmax; k++) { - Ck[f_ck(-k, 5, a)] += ancr * EXPrk[theta(r, -k, a)] / rootV2; //ck(4)<=ck(-k)<=ck(5) + Ck[f_ck(-k, 5, a)] += + ancr * EXPrk[theta(r, -k, a)] / rootV2; // ck(4)<=ck(-k)<=ck(5) Ck[f_ck(-k, 7, a)] += n * EXPrk[theta(r, -k, a)] / rootV2; Ck[f_ck(-k, 9, a)] += nn * EXPrk[theta(r, -k, a)] / rootV2; } } } - if (PR->ns == 0) { //Sum over site at same tau + if (PR->ns == 0) { // Sum over site at same tau for (int tag = 1; tag < PR->Nsdiv; tag++) { - MPI_Recv(Ck_m, Nk_set + Sk_set, MPI_DOUBLE_COMPLEX, tag * PR->Ntdiv + PR->ns0, 0, MPI_COMM_WORLD, &status); - for (int i = 0; i < Nk_set + Sk_set; i++) - Ck[i] += Ck_m[i]; + MPI_Recv(Ck_m, Nk_set + Sk_set, MPI_DOUBLE_COMPLEX, + tag * PR->Ntdiv + PR->ns0, 0, MPI_COMM_WORLD, &status); + for (int i = 0; i < Nk_set + Sk_set; i++) Ck[i] += Ck_m[i]; } ///////////////// Gk ////////////////////// for (int a = 0; a < 2; a++) { for (int k = 0; k < Nkxmax; k++) { - Nk2 = (Ck[f_ck(k, 0, a)] * Ck[f_ck(k, 1, a)] - Ck[0]) / (double)N->V; + Nk2 = (Ck[f_ck(k, 0, a)] * Ck[f_ck(k, 1, a)] - Ck[0]) / (double)N->V; values_L[f_nkr(k + a * Nkxmax)] = real(Nk2); values_L[f_nki(k + a * Nkxmax)] = imag(Nk2); } @@ -825,45 +850,61 @@ void Quantities::CorrelationFunction2(GraphSpace::Vertex *world) { //momentum s ///////////////// Sk ////////////////////// ////////////////////////////////////////// } else { - MPI_Send(Ck, Nk_set + Sk_set, MPI_DOUBLE_COMPLEX, PR->ns0, 0, MPI_COMM_WORLD); + MPI_Send(Ck, Nk_set + Sk_set, MPI_DOUBLE_COMPLEX, PR->ns0, 0, + MPI_COMM_WORLD); } // complex Gk2, Dkkk; if (PR->ns == 0) { - for (int kx = 0; kx < Nkxmax; kx++) { //(kx,ky,kz)=(0~Nkmax,0,0); (0~Nkmax,kx,kx) - - for (int kk = 0; kk < Nkkmax; kk++) { //(k'x,k'y,k'z)=(0,0,0);...(depends on CKK)...; (kx,ky,kz) - - Gk2 = Ck[f_ck(kx, 0)] * Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 0)] * Ck[f_ck(kk, 1)] - - - (Ck[0] * (Ck[f_ck(kk, 1)] * Ck[f_ck(kk, 0)] - Ck[1]) - Ck[f_ck(kk, 11)] * Ck[f_ck(kk, 0)] - - Ck[f_ck(kk, 10)] * Ck[f_ck(kk, 1)]) //i=j - - (Ck[f_ck(kk + kx, 3)] * (Ck[f_ck(kx, 0)] * Ck[f_ck(kk, 0)] - Ck[f_ck(kk + kx, 2)]) - - Ck[f_ck(kk, 15)] * Ck[f_ck(kk, 0)] - Ck[f_ck(kx, 15)] * Ck[f_ck(kx, 0)]) //i=l - - ((Ck[f_ck(kx - kk, 5)] - Ck[f_ck(kx - kk, 7)]) - * (Ck[f_ck(kx, 0)] * Ck[f_ck(kk, 1)] - Ck[f_ck(kk - kx, 5)]) - - Ck[f_ck(kk, 10)] * Ck[f_ck(kk, 1)] - Ck[f_ck(kx, 11)] * Ck[f_ck(kx, 0)]) //i=m - - (Ck[f_ck(kx + kk, 2)] * (Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 1)] - Ck[f_ck(kk + kx, 3)]) - - Ck[f_ck(kx, 14)] * Ck[f_ck(kx, 1)] - Ck[f_ck(kk, 14)] * Ck[f_ck(kk, 1)]) //j=m - - ((Ck[f_ck(kk - kx, 5)] - Ck[f_ck(kk - kx, 9)]) - * (Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 0)] - Ck[f_ck(kx - kk, 5)]) - - Ck[f_ck(kx, 12)] * Ck[f_ck(kx, 1)] - Ck[f_ck(kk, 13)] * Ck[f_ck(kk, 0)]) //j=l - - (Ck[0] * (Ck[f_ck(kx, 1)] * Ck[f_ck(kx, 0)] - Ck[1]) - Ck[f_ck(kx, 11)] * Ck[f_ck(kx, 0)] - - Ck[f_ck(kx, 10)] * Ck[f_ck(kx, 1)]) //l=m - - - (Ck[f_ck(kk, 15)] - Ck[f_ck(kk, 1)] / rootV2) * Ck[f_ck(kk, 0)] //i=j=l - - Ck[f_ck(kk, 14)] * Ck[f_ck(kk, 1)] //i=j=m - - Ck[f_ck(kx, 15)] * Ck[f_ck(kx, 0)] //i=m=l - - (Ck[f_ck(kx, 14)] - Ck[f_ck(kx, 0)] / rootV2) * Ck[f_ck(kx, 1)] //j=l=m - - - (Ck[1] * Ck[1] - Ck[3] * Ck[3]) //i=j,l=m - - (Ck[f_ck(kx - kk, 5)] * Ck[f_ck(kk - kx, 5)] - Ck[f_ck(kx - kk, 7)] * Ck[f_ck(kk - kx, 9)]) //i=m,j=l - - Ck[f_ck(kk + kx, 3)] * Ck[f_ck(kk + kx, 2)] //i=l,j=m - - Ck[2] //i=j=l=m - - Ck[4]; - - Dkkk = Gk2; //vol2; + for (int kx = 0; kx < Nkxmax; + kx++) { //(kx,ky,kz)=(0~Nkmax,0,0); (0~Nkmax,kx,kx) + + for (int kk = 0; kk < Nkkmax; + kk++) { //(k'x,k'y,k'z)=(0,0,0);...(depends on CKK)...; (kx,ky,kz) + + Gk2 = + Ck[f_ck(kx, 0)] * Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 0)] * + Ck[f_ck(kk, 1)] + + - (Ck[0] * (Ck[f_ck(kk, 1)] * Ck[f_ck(kk, 0)] - Ck[1]) - + Ck[f_ck(kk, 11)] * Ck[f_ck(kk, 0)] - + Ck[f_ck(kk, 10)] * Ck[f_ck(kk, 1)]) // i=j + - (Ck[f_ck(kk + kx, 3)] * + (Ck[f_ck(kx, 0)] * Ck[f_ck(kk, 0)] - Ck[f_ck(kk + kx, 2)]) - + Ck[f_ck(kk, 15)] * Ck[f_ck(kk, 0)] - + Ck[f_ck(kx, 15)] * Ck[f_ck(kx, 0)]) // i=l + - ((Ck[f_ck(kx - kk, 5)] - Ck[f_ck(kx - kk, 7)]) * + (Ck[f_ck(kx, 0)] * Ck[f_ck(kk, 1)] - Ck[f_ck(kk - kx, 5)]) - + Ck[f_ck(kk, 10)] * Ck[f_ck(kk, 1)] - + Ck[f_ck(kx, 11)] * Ck[f_ck(kx, 0)]) // i=m + - (Ck[f_ck(kx + kk, 2)] * + (Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 1)] - Ck[f_ck(kk + kx, 3)]) - + Ck[f_ck(kx, 14)] * Ck[f_ck(kx, 1)] - + Ck[f_ck(kk, 14)] * Ck[f_ck(kk, 1)]) // j=m + - ((Ck[f_ck(kk - kx, 5)] - Ck[f_ck(kk - kx, 9)]) * + (Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 0)] - Ck[f_ck(kx - kk, 5)]) - + Ck[f_ck(kx, 12)] * Ck[f_ck(kx, 1)] - + Ck[f_ck(kk, 13)] * Ck[f_ck(kk, 0)]) // j=l + - (Ck[0] * (Ck[f_ck(kx, 1)] * Ck[f_ck(kx, 0)] - Ck[1]) - + Ck[f_ck(kx, 11)] * Ck[f_ck(kx, 0)] - + Ck[f_ck(kx, 10)] * Ck[f_ck(kx, 1)]) // l=m + + - (Ck[f_ck(kk, 15)] - Ck[f_ck(kk, 1)] / rootV2) * + Ck[f_ck(kk, 0)] // i=j=l + - Ck[f_ck(kk, 14)] * Ck[f_ck(kk, 1)] // i=j=m + - Ck[f_ck(kx, 15)] * Ck[f_ck(kx, 0)] // i=m=l + - (Ck[f_ck(kx, 14)] - Ck[f_ck(kx, 0)] / rootV2) * + Ck[f_ck(kx, 1)] // j=l=m + + - (Ck[1] * Ck[1] - Ck[3] * Ck[3]) // i=j,l=m + - (Ck[f_ck(kx - kk, 5)] * Ck[f_ck(kk - kx, 5)] - + Ck[f_ck(kx - kk, 7)] * Ck[f_ck(kk - kx, 9)]) // i=m,j=l + - Ck[f_ck(kk + kx, 3)] * Ck[f_ck(kk + kx, 2)] // i=l,j=m + - Ck[2] // i=j=l=m + - Ck[4]; + + Dkkk = Gk2; // vol2; // for(int kky=0; kky<1; kky++){ //ky=kky= 0 or kx(kkx) values_L[f_gk2r(kx, kk)] = real(Dkkk); @@ -874,20 +915,19 @@ void Quantities::CorrelationFunction2(GraphSpace::Vertex *world) { //momentum s } //******* - int L3 = Lmax[ck2] + Lmax[ck4]; //for nk, gk2 + int L3 = Lmax[ck2] + Lmax[ck4]; // for nk, gk2 - if (PR->nst == 0) { //Sum over t=0 + if (PR->nst == 0) { // Sum over t=0 for (int tag = 1; tag < PR->Ntdiv; tag++) { - MPI_Recv(m_val, L3, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, &status); - for (int i = 0; i < L3; i++) - values_L[f_nk(i)] += m_val[i]; + MPI_Recv(m_val, L3, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, + &status); + for (int i = 0; i < L3; i++) values_L[f_nk(i)] += m_val[i]; } - for (int i = 0; i < L3; i++) - values_L[f_nk(i)] /= (double)PR->Ntdiv; + for (int i = 0; i < L3; i++) values_L[f_nk(i)] /= (double)PR->Ntdiv; - } else if (PR->ns == 0) { //Ntdiv prosessors for nk, gf2, gk2 + } else if (PR->ns == 0) { // Ntdiv prosessors for nk, gf2, gk2 MPI_Send(&(values_L[f_nk(0)]), L3, MPI_DOUBLE, PR->nst0, 0, MPI_COMM_WORLD); } } @@ -896,11 +936,12 @@ void Quantities::CorrelationFunction2(GraphSpace::Vertex *world) { //momentum s void Quantities::NoiseCorrelation() { for (int kx = 0; kx < Nkxmax; kx++) { for (int kk = 0; kk < Nkkmax; kk++) { - MCmean_L[f_noise(kx, kk)] = MCmean_L[f_gk2r(kx, kk)] - MCmean_L[f_nkr(kx)] * MCmean_L[f_nkr(kk)]; + MCmean_L[f_noise(kx, kk)] = + MCmean_L[f_gk2r(kx, kk)] - MCmean_L[f_nkr(kx)] * MCmean_L[f_nkr(kk)]; } } - MCmean_S[d00 * 2] = MCmean_L[f_noise(0, 0)]; + MCmean_S[d00 * 2] = MCmean_L[f_noise(0, 0)]; MCmean_S[d00 * 2 + 1] = MCmean_S[d00 * 2] * MCmean_S[d00 * 2]; } #endif @@ -919,7 +960,8 @@ void Quantities::MCsum_S() { void Quantities::MCsum_SF() { for (int isf = 0; isf < NKMAX; isf++) for (int it = 0; it < Ntau; it++) - MCmean_SF[2 * isf][it] += sfsamp[isf][it] / (double)N->V / (double)MC->Nsample; + MCmean_SF[2 * isf][it] += + sfsamp[isf][it] / (double)N->V / (double)MC->Nsample; } #endif diff --git a/src/pmwa/quantities.H.cpp b/src/pmwa/quantities.H.cpp index f99f47f3..a08f4e0c 100644 --- a/src/pmwa/quantities.H.cpp +++ b/src/pmwa/quantities.H.cpp @@ -5,23 +5,24 @@ //#define XSTEPALL //#include -Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Parallel *m_PR, std::string const & sfinfile) { +Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, + Parallel *m_PR, std::string const &sfinfile) { #ifdef REWEIGHT cout << "REWEIGHTING ON" << endl; #else cout << "REWEIGHTING OFF" << endl; #endif - Npara = m_PR->Npara; + Npara = m_PR->Npara; my_rank = m_PR->my_rank; MC = m_MC; - N = m_N; + N = m_N; LT = m_LT; PR = m_PR; sp = m_sp; - V = PR->V; + V = PR->V; Nx = PR->x; NL[0] = N->x; @@ -48,17 +49,17 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral #endif Nkxmax = N->x / Nkstep; - Nxmax = N->x / Nxstep; - Nkmax = Nkxmax * 2; //i.e. kx=ky=kz, kx!=ky=kz=0 + Nxmax = N->x / Nxstep; + Nkmax = Nkxmax * 2; // i.e. kx=ky=kz, kx!=ky=kz=0 Nkkmax = Nkxmax; - Nend = Nq - 3; //Mx's number + Nend = Nq - 3; // Mx's number newcall_zero(Lmax, Nc); newcall_zero(Lsum, Nc); Lsum[mz] = Lmax[mz] = V; - Lmax[cr2] = Nxmax; + Lmax[cr2] = Nxmax; // Lmax[sk]=Nkmax*2;//i.e. real and imaginary part Lmax[ck2] = Nkmax * 2; //#ifdef GF22Gk2 @@ -68,16 +69,14 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral //#endif Lmax[ck4] = Nkxmax * Nkkmax * 2; Lmax[dkk] = Nkxmax * Nkkmax; - Lmax[nw] = V; + Lmax[nw] = V; Lmax[nw2] = V; - Lmax[lw] = V; + Lmax[lw] = V; - Lsize = 0; //sin,cos,Nk,Sk + Lsize = 0; // sin,cos,Nk,Sk - for (int i = 1; i < Nc; i++) - Lsum[i] = Lsum[i - 1] + Lmax[i]; - for (int i = 0; i < Nc; i++) - Lsize += Lmax[i]; + for (int i = 1; i < Nc; i++) Lsum[i] = Lsum[i - 1] + Lmax[i]; + for (int i = 0; i < Nc; i++) Lsize += Lmax[i]; newcall_zero(file, Nc + Nq, 128); newcall_zero(Qname, Nc + Nq, 128); @@ -85,48 +84,48 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral // int NVMAX, NWMAX; // sprintf(parainfo,"B%.1lf_Nx%d_Ny%d_Vbb%.1lf",N->B,N->x,N->y,sp->Vb1); - sprintf(Qname[wndx], "wndx"); //Winding Number for x-axis - sprintf(Qname[wndy], "wndy"); //Winding Number for y-axis - sprintf(Qname[wndz], "wndz"); //Winding Number for z-axis - sprintf(Qname[wnd2], "wnd2"); //square of Winding Number - sprintf(Qname[amzu], "amzu"); //Density or z-Magnetization - sprintf(Qname[bmzu], "bmzu"); //Density or z-Magnetization - sprintf(Qname[ang], "ang "); //Phase - sprintf(Qname[ene], "ene "); //Energy - sprintf(Qname[nver], "nver"); //Number of vertices - sprintf(Qname[spe], "spe "); //Specific heat - sprintf(Qname[nwor], "nwor"); //Number of worms - sprintf(Qname[xmx], "xmx "); //Susceptibility - sprintf(Qname[nkin], "nkin"); //Number of kinks - sprintf(Qname[comp], "comp"); //Compressibility - sprintf(Qname[lxmx], "lxmx"); //Compressibility - sprintf(Qname[magx], "bmxu"); //BEC order parameter or xmag - sprintf(Qname[magp], "bmpu"); //BEC order parameter or +mag - sprintf(Qname[magm], "bmmu"); //BEC order parameter or -mag - sprintf(Qname[smzu], "smzu"); //structure factor (uniform) - sprintf(Qname[smzs], "smzs"); //structure factor (staggerd) - sprintf(Qname[xmzu], "xmzu"); //structure factor (uniform) - sprintf(Qname[xmzs], "xmzs"); //structure factor (staggerd) + sprintf(Qname[wndx], "wndx"); // Winding Number for x-axis + sprintf(Qname[wndy], "wndy"); // Winding Number for y-axis + sprintf(Qname[wndz], "wndz"); // Winding Number for z-axis + sprintf(Qname[wnd2], "wnd2"); // square of Winding Number + sprintf(Qname[amzu], "amzu"); // Density or z-Magnetization + sprintf(Qname[bmzu], "bmzu"); // Density or z-Magnetization + sprintf(Qname[ang], "ang "); // Phase + sprintf(Qname[ene], "ene "); // Energy + sprintf(Qname[nver], "nver"); // Number of vertices + sprintf(Qname[spe], "spe "); // Specific heat + sprintf(Qname[nwor], "nwor"); // Number of worms + sprintf(Qname[xmx], "xmx "); // Susceptibility + sprintf(Qname[nkin], "nkin"); // Number of kinks + sprintf(Qname[comp], "comp"); // Compressibility + sprintf(Qname[lxmx], "lxmx"); // Compressibility + sprintf(Qname[magx], "bmxu"); // BEC order parameter or xmag + sprintf(Qname[magp], "bmpu"); // BEC order parameter or +mag + sprintf(Qname[magm], "bmmu"); // BEC order parameter or -mag + sprintf(Qname[smzu], "smzu"); // structure factor (uniform) + sprintf(Qname[smzs], "smzs"); // structure factor (staggerd) + sprintf(Qname[xmzu], "xmzu"); // structure factor (uniform) + sprintf(Qname[xmzs], "xmzs"); // structure factor (staggerd) // sprintf(Qname[d00] ,"d00"); //noise correlation at k=0 - sprintf(Qname[len], "len"); //noise correlation at k=0 + sprintf(Qname[len], "len"); // noise correlation at k=0 - sprintf(Qname[Nq + mz], "mz"); //Local density or local mz - sprintf(Qname[Nq + cr2], "cr2"); //2-points correlation (mx-mx) + sprintf(Qname[Nq + mz], "mz"); // Local density or local mz + sprintf(Qname[Nq + cr2], "cr2"); // 2-points correlation (mx-mx) // sprintf(Qname[Nq+sk] ,"sk"); //structure factor - sprintf(Qname[Nq + ck2], "ck2"); //k-space of cr2 + sprintf(Qname[Nq + ck2], "ck2"); // k-space of cr2 // sprintf(Qname[Nq+cr4],"cr4"); //4-points correlation - sprintf(Qname[Nq + ck4], "ck4"); //k-space of cr4 - sprintf(Qname[Nq + dkk], "dkk"); //Noise correlation - sprintf(Qname[Nq + nw], "nw"); //local number of worms - sprintf(Qname[Nq + nw2], "nw2"); //square of nw - sprintf(Qname[Nq + lw], "lw"); //square of nw + sprintf(Qname[Nq + ck4], "ck4"); // k-space of cr4 + sprintf(Qname[Nq + dkk], "dkk"); // Noise correlation + sprintf(Qname[Nq + nw], "nw"); // local number of worms + sprintf(Qname[Nq + nw2], "nw2"); // square of nw + sprintf(Qname[Nq + lw], "lw"); // square of nw // int S=Nc+Nq; newcall_zero(values_S, Nq); newcall_zero(MCmean_S, Nq * 2); newcall_zero(BINmean_S, Nq * 2 * MC->Nbin); - //newcall_zero(RNDmean_S,Nq*2*PR->Npara); + // newcall_zero(RNDmean_S,Nq*2*PR->Npara); newcall_zero(values_L, Lsize); newcall_zero(MCmean_L, Lsize * 2); @@ -137,7 +136,7 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral newcall_zero(EXPrk, 4 * Nkmax * V); - Cknum = 16; + Cknum = 16; Nk_set = 5 + 2 * Nkmax * Cknum; Sk_set = 2; @@ -150,14 +149,15 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Paral int y = (int)(i / Nx) % PR->y + PR->ny * PR->y; int z = (int)(i / (Nx * PR->y)) + PR->nz * PR->z; - for (int k = -Nkmax + 1; k < Nkmax; k++) { //max(kx+kk)=Nkkmax-1 + Nkxmax-1 + for (int k = -Nkmax + 1; k < Nkmax; k++) { // max(kx+kk)=Nkkmax-1 + + // Nkxmax-1 - double phase = 2.0 * PI * x * k / (double)Nkxmax; //kx!=0,ky=kz=0 + double phase = 2.0 * PI * x * k / (double)Nkxmax; // kx!=0,ky=kz=0 complex phase_c(0.0, phase); EXPrk[theta(i, k, 0)] = exp(phase_c); - phase = 2.0 * PI * (x + y + z) * k / (double)Nkxmax; //kx=ky - phase_c = complex(0.0, phase); + phase = 2.0 * PI * (x + y + z) * k / (double)Nkxmax; // kx=ky + phase_c = complex(0.0, phase); EXPrk[theta(i, k, 1)] = exp(phase_c); } } @@ -190,7 +190,7 @@ Quantities::~Quantities() { delcall(values_L); delcall(MCmean_L); delcall(BINmean_L); - //delcall(RNDmean_L); + // delcall(RNDmean_L); delcall(m_val); @@ -219,18 +219,13 @@ Quantities::~Quantities() { } void Quantities::Init() { - for (int i = 0; i < Nq1; i++) - values_S[i] = 0; - for (int i = 0; i < Lsize; i++) - values_L[i] = 0; - for (int i = 0; i < Nq * 2; i++) - MCmean_S[i] = 0; - for (int i = 0; i < Lsize * 2; i++) - MCmean_L[i] = 0; + for (int i = 0; i < Nq1; i++) values_S[i] = 0; + for (int i = 0; i < Lsize; i++) values_L[i] = 0; + for (int i = 0; i < Nq * 2; i++) MCmean_S[i] = 0; + for (int i = 0; i < Lsize * 2; i++) MCmean_L[i] = 0; #ifdef SF for (int isf = 0; isf < NSF; isf++) - for (int it = 0; it < Ntau; it++) - MCmean_SF[isf][it] = 0; + for (int it = 0; it < Ntau; it++) MCmean_SF[isf][it] = 0; // for( int i=0; iNpara; i++ ) RNDmean_S[i]=0; // for( int i=0; iNpara; i++ ) RNDmean_L[i]=0; #endif @@ -242,11 +237,11 @@ void Quantities::read_sf() { int Nline = X["NumberOfElements"].getInteger(); - dtau = PR->B / (double)Ntau1; //in preparation for temporal pararellization + dtau = PR->B / (double)Ntau1; // in preparation for temporal pararellization - Ntau = X["CutoffOfNtau"].getInteger(); + Ntau = X["CutoffOfNtau"].getInteger(); NKMAX = X["NumberOfInverseLattice"].getInteger(); - NSF = NKMAX * 2; + NSF = NKMAX * 2; newcall_zero(MCmean_SF, NSF, Ntau); newcall_zero(BINmean_SF, NSF, Ntau); @@ -263,10 +258,10 @@ void Quantities::read_sf() { for (int i = 0; i < X.NumberOfBlocks(); i++) { XML::Block &BLCK = X[i]; if (BLCK.getName() == "SF") { - double COSrk_ = BLCK.getDouble(0); - double SINrk_ = BLCK.getDouble(1); - int isite = BLCK.getInteger(2); - int ksite = BLCK.getInteger(3); + double COSrk_ = BLCK.getDouble(0); + double SINrk_ = BLCK.getDouble(1); + int isite = BLCK.getInteger(2); + int ksite = BLCK.getInteger(3); COSrk[isite][ksite] = COSrk_; SINrk[isite][ksite] = SINrk_; count++; @@ -274,30 +269,33 @@ void Quantities::read_sf() { } if (count != Nline) { - cout << "ERROR Nline( " << Nline << " ) != count( " << count << " )" << endl; + cout << "ERROR Nline( " << Nline << " ) != count( " << count << " )" + << endl; exit(0); } }; #endif -void Quantities::Measure(int Nv, int Nk, vector &ev, vector WORM, - GraphSpace::Vertex *world, GraphSpace::Vertex *worldB, double length, int m_Wnum, int mcs) { +void Quantities::Measure(int Nv, int Nk, vector &ev, + vector WORM, + GraphSpace::Vertex *world, GraphSpace::Vertex *worldB, + double length, int m_Wnum, int mcs) { NVMAX = max(NVMAX, m_Wnum + Nv); NWMAX = max(NWMAX, m_Wnum); #ifdef CFOUT - WindingNumber(ev, mcs); //no MPI + WindingNumber(ev, mcs); // no MPI #endif - NumberOfVertices(m_Wnum + Nv, mcs); //no MPI - NumberOfWorms(ev, m_Wnum); //noMPI - NumberOfKinks(Nk, mcs); //no MPI - CondensateFraction(mcs, world); //MPI in correlation function1,2 - Density(world, worldB); //no MPI + NumberOfVertices(m_Wnum + Nv, mcs); // no MPI + NumberOfWorms(ev, m_Wnum); // noMPI + NumberOfKinks(Nk, mcs); // no MPI + CondensateFraction(mcs, world); // MPI in correlation function1,2 + Density(world, worldB); // no MPI CorrelationLength(length); SUM_OVER_T(); // for local nw and mz SUM_OVER_S(); // for amzu - SUM_OVER_ST(); //for values_S + SUM_OVER_ST(); // for values_S // cout<<"Sk"< &ev, vector< } void Quantities::Measure() { - Average(); if (PR->nst == 0) { @@ -338,7 +335,8 @@ void Quantities::BINsum(int bin) { for (int i = 0; i < NKMAX; i++) for (int it = 0; it < Ntau; it++) { BINmean_SF[2 * i][it] += MCmean_SF[2 * i][it]; - BINmean_SF[2 * i + 1][it] += MCmean_SF[2 * i][it] * MCmean_SF[2 * i][it]; + BINmean_SF[2 * i + 1][it] += + MCmean_SF[2 * i][it] * MCmean_SF[2 * i][it]; } #endif } @@ -353,10 +351,10 @@ void Quantities::BINaverage() { #ifdef SF for (int i = 0; i < NKMAX; i++) for (int it = 0; it < Ntau; it++) { - double mean = BINmean_SF[2 * i][it] / (double)MC->Nbin; - double smean = BINmean_SF[2 * i + 1][it] / (double)MC->Nbin; - double num = (MC->Nbin == 1) ? 1.0 : MC->Nbin - 1.0; - BINmean_SF[2 * i][it] = mean; + double mean = BINmean_SF[2 * i][it] / (double)MC->Nbin; + double smean = BINmean_SF[2 * i + 1][it] / (double)MC->Nbin; + double num = (MC->Nbin == 1) ? 1.0 : MC->Nbin - 1.0; + BINmean_SF[2 * i][it] = mean; BINmean_SF[2 * i + 1][it] = sqrt((smean - mean * mean) / num); } #endif @@ -364,11 +362,11 @@ void Quantities::BINaverage() { } void Quantities::BINsum(double *MCmean, double *BINmean, int Lmax, int bin) { - for (int i = 0; i < Lmax; i++) - BINmean[i + bin * Lmax] = MCmean[i]; + for (int i = 0; i < Lmax; i++) BINmean[i + bin * Lmax] = MCmean[i]; } -void Quantities::Average(double *g, int Nval, int S, double *MCmean, int kstep) { +void Quantities::Average(double *g, int Nval, int S, double *MCmean, + int kstep) { double num = (Nval == 1) ? 1.0 : Nval - 1.0; for (int k = 0; k < S; k += 2) { @@ -382,7 +380,7 @@ void Quantities::Average(double *g, int Nval, int S, double *MCmean, int kstep) mean /= (double)Nval; error /= (double)Nval; - MCmean[k] = mean; + MCmean[k] = mean; MCmean[k + 1] = (Nval == 1) ? 0 : sqrt((error - mean * mean) / num); } } @@ -392,7 +390,8 @@ void Quantities::show_S(ofstream &F) { //Ä̾ï int S = Nq * 2; for (int k = 0; k < S; k += 2) - F << "R " << Qname[k / 2] << " = " << MCmean_S[k] << " " << MCmean_S[k + 1] << endl; + F << "R " << Qname[k / 2] << " = " << MCmean_S[k] << " " << MCmean_S[k + 1] + << endl; } #ifdef SF @@ -407,7 +406,8 @@ void Quantities::dump(FILE *F) { inline void Quantities::show4SF(FILE *F) { for (int i = 0; i < NKMAX; i++) { for (int it = 0; it < Ntau; it++) { - fprintf(F, "R C%dt%d = %16.10e %16.10e\n", i, it, MCmean_SF[2 * i][it], MCmean_SF[2 * i + 1][it]); + fprintf(F, "R C%dt%d = %16.10e %16.10e\n", i, it, MCmean_SF[2 * i][it], + MCmean_SF[2 * i + 1][it]); } fprintf(F, "\n"); } @@ -415,123 +415,130 @@ inline void Quantities::show4SF(FILE *F) { #endif void Quantities::show_L() { - int k; long R, R_, Ry; string ll, Cname; std::ofstream F; - //Local density + // Local density F.open(file[Nq + mz], std::ios::app); F << "# Local density." << endl; F << "# R x-SITE " << endl; F << setprecision(16); for (int l = 0; l < Nx; l++) { - R = l; - k = f_ld(l) * 2; + R = l; + k = f_ld(l) * 2; Cname = "real_" + tostr(R); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //Local worm density + // Local worm density F.open(file[Nq + nw], std::ios::app); F << "# Local worm density." << endl; F << "# R x-SITE " << endl; F << setprecision(16); for (int l = 0; l < Nx; l++) { - R = l; - k = f_nw(l) * 2; + R = l; + k = f_nw(l) * 2; Cname = "real_" + tostr(R); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //worm length + // worm length F.open(file[Nq + lw], std::ios::app); F << "# worm length." << endl; F << "# R x-SITE " << endl; F << setprecision(16); for (int l = 0; l < V; l++) { - R = l; - k = f_lw(l) * 2; + R = l; + k = f_lw(l) * 2; Cname = "real_" + tostr(R); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //Local susceptibility + // Local susceptibility F.open(file[Nq + nw2], std::ios::app); F << "# Local susceptibility." << endl; F << "# R x-SITE " << endl; F << setprecision(16); for (int l = 0; l < Nx; l++) { - R = l; - k = f_nw2(l) * 2; + R = l; + k = f_nw2(l) * 2; Cname = "real_" + tostr(R); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //GF + // GF F.open(file[Nq + cr2], std::ios::app); F << "#2-point Correlation with sites." << endl; F << "# R x-distance " << endl; F << setprecision(16); for (int l = 0; l < Lmax[cr2]; l++) { - R = l * Nxstep; - k = f_gf(l) * 2; + R = l * Nxstep; + k = f_gf(l) * 2; Cname = "real_" + tostr(R); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //nk + // nk F.open(file[Nq + ck2], std::ios::app); F << "# 2-point Correlation with wave numbers." << endl; F << "# real/imag kx ky " << endl; F << setprecision(16); for (int l = 0; l < Lmax[ck2]; l++) { - R = l % Nkxmax; - Ry = ((int)(l / Nkxmax) % 2) * R; - ll = ((bool)(l / Nkmax)) ? "imag" : "real"; - k = f_nk(l) * 2; + R = l % Nkxmax; + Ry = ((int)(l / Nkxmax) % 2) * R; + ll = ((bool)(l / Nkmax)) ? "imag" : "real"; + k = f_nk(l) * 2; Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(Ry * Nkstep); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; } F.close(); - //4-point correlation + // 4-point correlation F.open(file[Nq + ck4], std::ios::app); F << "# 4-point Correlation with wave numbers." << endl; F << "# kx kx' " << endl; F << setprecision(16); for (int l = 0; l < Lmax[ck4]; l++) { - k = f_gk2(l) * 2; - R = l % Nkxmax; - R_ = (int)(l / Nkxmax) % Nkkmax; + k = f_gk2(l) * 2; + R = l % Nkxmax; + R_ = (int)(l / Nkxmax) % Nkkmax; bool kl = l / (Nkkmax * Nkxmax); - ll = (kl) ? "imag" : "real"; // real or imag - Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(R_ * Nkstep); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + ll = (kl) ? "imag" : "real"; // real or imag + Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(R_ * Nkstep); + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; if (R == Nkxmax - 1) F << endl; } F.close(); - //noise correlation + // noise correlation F.open(file[Nq + dkk], std::ios::app); F << "# Noise Correlation with wave numbers." << endl; F << "# kx kx' " << endl; F << setprecision(16); for (int l = 0; l < Lmax[dkk]; l++) { - k = f_noise(l) * 2; - R = l % Nkxmax; - R_ = (int)(l / Nkxmax); - ll = "real"; + k = f_noise(l) * 2; + R = l % Nkxmax; + R_ = (int)(l / Nkxmax); + ll = "real"; Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(R_ * Nkstep); - F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] << endl; + F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] + << endl; if (R == Nkxmax - 1) F << endl; } @@ -555,9 +562,10 @@ void Quantities::show(ofstream &F, FILE *SFF) { } ////// -void Quantities::Output(std::string const & fname, double g) { +void Quantities::Output(std::string const &fname, double g) { std::ofstream file(fname.c_str(), std::ios::app); - file << sp->Htr << " " << sp->mu << " " << sp->Vb1 << " " << sp->tb << " " << N->B << " " << g << endl; + file << sp->Htr << " " << sp->mu << " " << sp->Vb1 << " " << sp->tb << " " + << N->B << " " << g << endl; } //########################################################################################## @@ -571,7 +579,10 @@ void Quantities::WindingNumber(vector &ev, int mcs) { while (it != ev.end()) { int l = it->i / V; - if ((it->type == 2 && /*LT->bd[it->i%V][l*2] == it->nleg->i%V &&*/ it->i % V < it->nleg->i % V) || it->type == -1) { + if ((it->type == 2 && + /*LT->bd[it->i%V][l*2] == it->nleg->i%V &&*/ it->i % V < + it->nleg->i % V) || + it->type == -1) { int crr = (it->p < it->next[0]->p) ? 1 : -1; for (int d = 0; d < N->d; d++) if (LT->bond_vec[l][d] != 0.0) Wi[d] += crr; @@ -583,7 +594,6 @@ void Quantities::WindingNumber(vector &ev, int mcs) { for (int d = 0; d < N->d; d++) { values_S[wndx + d] = (double)Wi[d]; } //(double)NL[d]; } - } void Quantities::WindingNumber2() { @@ -593,11 +603,12 @@ void Quantities::WindingNumber2() { ww += MCmean_S[(wndx + d) * 2 + 1]; } - MCmean_S[wnd2 * 2] = ww; + MCmean_S[wnd2 * 2] = ww; MCmean_S[wnd2 * 2 + 1] = ww * ww; } -void Quantities::Density(GraphSpace::Vertex *world, GraphSpace::Vertex *worldB) { +void Quantities::Density(GraphSpace::Vertex *world, + GraphSpace::Vertex *worldB) { double ph[2] = {1.0, -1.0}; double atot = 0.0, btot = 0.0, stot = 0.0, xtot = 0.0; #ifdef SF @@ -605,14 +616,15 @@ void Quantities::Density(GraphSpace::Vertex *world, GraphSpace::Vertex *worldB) #endif for (int i = 0; i < V; i++) { - int it = 0; + int it = 0; double tau = 0.0; - double n0 = 0.0; + double n0 = 0.0; - for (GraphSpace::Vertex *wl = &(world[i]); wl != &(worldB[i]); wl = wl->next[1]) { + for (GraphSpace::Vertex *wl = &(world[i]); wl != &(worldB[i]); + wl = wl->next[1]) { double tTri = wl->next[1]->t; double bTri = wl->t; - double mz = wl->p - 0.5; + double mz = wl->p - 0.5; n0 += (tTri - bTri) * mz; @@ -651,8 +663,8 @@ void Quantities::Density(GraphSpace::Vertex *world, GraphSpace::Vertex *worldB) for (int it = 0; it < Ntau; it++) { double SZKT = 0.0; for (int tt = 0; tt < Ntau1; tt++) { - SZKT += counter4SFC[k][tt] * counter4SFC[k][(tt + it) % Ntau1] - + counter4SFS[k][tt] * counter4SFS[k][(tt + it) % Ntau1]; + SZKT += counter4SFC[k][tt] * counter4SFC[k][(tt + it) % Ntau1] + + counter4SFS[k][tt] * counter4SFS[k][(tt + it) % Ntau1]; } sfsamp[k][it] = SZKT / (double)Ntau1; } @@ -663,12 +675,16 @@ void Quantities::Density(GraphSpace::Vertex *world, GraphSpace::Vertex *worldB) void Quantities::Compressibility() { MCmean_S[comp * 2] = - N->B * N->V * (MCmean_S[smzu * 2] / (MCmean_S[amzu * 2] * MCmean_S[amzu * 2] * (double)N->V) - 1.0); + N->B * N->V * + (MCmean_S[smzu * 2] / + (MCmean_S[amzu * 2] * MCmean_S[amzu * 2] * (double)N->V) - + 1.0); MCmean_S[comp * 2 + 1] = MCmean_S[comp * 2] * MCmean_S[comp * 2]; } void Quantities::Energy() { - MCmean_S[ene * 2] = (sp->Eu + sp->Et - MCmean_S[nver * 2] / N->B) / (double)N->V; + MCmean_S[ene * 2] = + (sp->Eu + sp->Et - MCmean_S[nver * 2] / N->B) / (double)N->V; MCmean_S[ene * 2 + 1] = MCmean_S[ene * 2] * MCmean_S[ene * 2]; } @@ -678,14 +694,15 @@ void Quantities::NumberOfVertices(int countv, int mcs) { void Quantities::SpecificHeat() { MCmean_S[spe * 2] = - (MCmean_S[nver * 2 + 1] - MCmean_S[nver * 2] * MCmean_S[nver * 2] - MCmean_S[nver * 2]) / (double)N->V; + (MCmean_S[nver * 2 + 1] - MCmean_S[nver * 2] * MCmean_S[nver * 2] - + MCmean_S[nver * 2]) / + (double)N->V; MCmean_S[spe * 2 + 1] = MCmean_S[spe * 2] * MCmean_S[spe * 2]; } void Quantities::NumberOfWorms(vector &ev, int m_Nw) { #ifdef CFOUT - for (int i = 0; i < V; i++) - values_L[f_nw(i)] = 0; + for (int i = 0; i < V; i++) values_L[f_nw(i)] = 0; int Nw = 0; vector::iterator it = ev.begin(); @@ -704,7 +721,7 @@ void Quantities::NumberOfWorms(vector &ev, int m_Nw) { } void Quantities::NumberOfKinks(int Nk, int mcs) { values_S[nkin] = Nk; - values_S[ang] = 2 * (Nk % 2) - 1; + values_S[ang] = 2 * (Nk % 2) - 1; } void Quantities::Susceptibility() { @@ -713,16 +730,18 @@ void Quantities::Susceptibility() { for (int i = 0; i < V; i++) { MCmean_L[f_nw2(i)] = - (MCmean_L[f_nw2(i)] - MCmean_L[f_nw(i)] * MCmean_L[f_nw(i)]) / (4.0 * N->B * sp->Htr * sp->Htr); + (MCmean_L[f_nw2(i)] - MCmean_L[f_nw(i)] * MCmean_L[f_nw(i)]) / + (4.0 * N->B * sp->Htr * sp->Htr); lx += MCmean_L[f_nw2(i)]; } - MCmean_S[lxmx * 2] = lx / (double)V; + MCmean_S[lxmx * 2] = lx / (double)V; MCmean_S[lxmx * 2 + 1] = MCmean_S[lxmx * 2] * MCmean_S[lxmx * 2]; #endif MCmean_S[xmx * 2] = - (MCmean_S[nwor * 2 + 1] - MCmean_S[nwor * 2] * MCmean_S[nwor * 2]) / (4.0 * N->V * N->B * sp->Htr * sp->Htr); + (MCmean_S[nwor * 2 + 1] - MCmean_S[nwor * 2] * MCmean_S[nwor * 2]) / + (4.0 * N->V * N->B * sp->Htr * sp->Htr); MCmean_S[xmx * 2 + 1] = MCmean_S[xmx * 2] * MCmean_S[xmx * 2]; } @@ -743,7 +762,7 @@ void Quantities::CondensateFraction(int mcs, GraphSpace::Vertex *world) { values_S[magm] = ctot / PR->Ntdiv; #ifdef CFOUT CorrelationFunction1(); - //CorrelationFunction2(world); + // CorrelationFunction2(world); #endif } @@ -752,40 +771,36 @@ void Quantities::CorrelationLength(double length) { values_S[len] = length; } //////////////////////////////////// //***MC average -void Quantities::Average(){ - - +void Quantities::Average() { #ifdef REWEIGHT - double ZW=MCmean_S[2*ang]; + double ZW = MCmean_S[2 * ang]; #else - double ZW=MC->Nsample; + double ZW = MC->Nsample; #endif - for(int i=0; iNsample; - MCmean_S[ang*2+1] /= (double)MC->Nsample; + + MCmean_S[ang * 2] /= (double)MC->Nsample; + MCmean_S[ang * 2 + 1] /= (double)MC->Nsample; #endif - + #ifdef CFOUT - for(int i=0; int == 0) { //Sum over t + if (PR->nt == 0) { // Sum over t for (int tag = 1; tag < PR->Ntdiv; tag++) { - MPI_Recv(m_val, V * 2, MPI_DOUBLE, tag + PR->nt0, 0, MPI_COMM_WORLD, &status); - for (int i = 0; i < V * 2; i++) - values_L[f_ld(i)] += m_val[i]; + MPI_Recv(m_val, V * 2, MPI_DOUBLE, tag + PR->nt0, 0, MPI_COMM_WORLD, + &status); + for (int i = 0; i < V * 2; i++) values_L[f_ld(i)] += m_val[i]; } #ifdef CFOUT for (int i = 0; i < V; i++) { @@ -860,17 +875,19 @@ void Quantities::SUM_OVER_T() { #endif } else { - MPI_Send(&(values_L[f_ld(0)]), V * 2, MPI_DOUBLE, PR->nt0, 0, MPI_COMM_WORLD); + MPI_Send(&(values_L[f_ld(0)]), V * 2, MPI_DOUBLE, PR->nt0, 0, + MPI_COMM_WORLD); } } void Quantities::SUM_OVER_S() { - if (PR->ns == 0) { //Sum over s at same tau + if (PR->ns == 0) { // Sum over s at same tau double Norm = PR->Ntdiv; for (int tag = 1; tag < PR->Nsdiv; tag++) { - MPI_Recv(m_val, 2, MPI_DOUBLE, tag * PR->Ntdiv + PR->ns0, 0, MPI_COMM_WORLD, &status); + MPI_Recv(m_val, 2, MPI_DOUBLE, tag * PR->Ntdiv + PR->ns0, 0, + MPI_COMM_WORLD, &status); values_S[amzu] += m_val[0]; values_S[smzs] += m_val[1]; @@ -890,10 +907,11 @@ void Quantities::SUM_OVER_S() { } void Quantities::SUM_OVER_ST() { - if (PR->nst == 0) { //Sum over t and s + if (PR->nst == 0) { // Sum over t and s for (int tag = 1; tag < PR->NtNs; tag++) { - MPI_Recv(m_val, Nq1, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, &status); + MPI_Recv(m_val, Nq1, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, + &status); for (int i = 0; i < Nq1; i++) { values_S[i] += m_val[i]; } @@ -911,30 +929,29 @@ void Quantities::SUM_OVER_ST() { values_S[bmzu] /= (double)N->V; } -void Quantities::CorrelationFunction1() { //real space +void Quantities::CorrelationFunction1() { // real space //***MPI sum for G double ntot = 0.0; - int Lcr2 = Lmax[cr2]; - int ixmax = Lcr2 / PR->Nxdiv; + int Lcr2 = Lmax[cr2]; + int ixmax = Lcr2 / PR->Nxdiv; double Norm; - for (int i = 0; i < Lcr2; i++) - values_L[f_gf(i)] = 0.0; + for (int i = 0; i < Lcr2; i++) values_L[f_gf(i)] = 0.0; - if (PR->nx == 0) { //Sum over x at same tau + if (PR->nx == 0) { // Sum over x at same tau for (int i = 0; i < ixmax; i++) { - int ixx = i * Nxstep; - this->Q[i] = an[ixx]; - this->Q[i + Lcr2] = cr[ixx]; + int ixx = i * Nxstep; + this->Q[i] = an[ixx]; + this->Q[i + Lcr2] = cr[ixx]; this->Q[i + 2 * Lcr2] = ca[ixx]; } for (int tag = 1; tag < PR->Nxdiv; tag++) { - MPI_Recv(m_val, ixmax * 3, MPI_DOUBLE, tag * PR->Ntdiv + PR->nx0, 0, MPI_COMM_WORLD, &status); - for (int i = 0; i < ixmax; i++) - this->Q[i + tag * ixmax] = m_val[i]; + MPI_Recv(m_val, ixmax * 3, MPI_DOUBLE, tag * PR->Ntdiv + PR->nx0, 0, + MPI_COMM_WORLD, &status); + for (int i = 0; i < ixmax; i++) this->Q[i + tag * ixmax] = m_val[i]; for (int i = 0; i < ixmax; i++) this->Q[i + tag * ixmax + Lcr2] = m_val[i + ixmax]; for (int i = 0; i < ixmax; i++) @@ -947,63 +964,66 @@ void Quantities::CorrelationFunction1() { //real space if (ix == ixx) values_L[f_gf(0)] += this->Q[ix + 2 * Lcr2] * 2.0; else - values_L[f_gf(rx)] += this->Q[ix] * this->Q[ixx + Lcr2] + this->Q[ix + Lcr2] * this->Q[ixx]; + values_L[f_gf(rx)] += this->Q[ix] * this->Q[ixx + Lcr2] + + this->Q[ix + Lcr2] * this->Q[ixx]; } Norm = 2.0 * Lcr2 * PR->Ntdiv * PR->Nydiv * PR->Nzdiv; - for (int i = 0; i < Lcr2; i++) - values_L[f_gf(i)] /= Norm; + for (int i = 0; i < Lcr2; i++) values_L[f_gf(i)] /= Norm; } else { for (int i = 0; i < ixmax; i++) { - int ixx = i * Nxstep; - this->Q[i] = an[ixx]; - this->Q[i + ixmax] = cr[ixx]; + int ixx = i * Nxstep; + this->Q[i] = an[ixx]; + this->Q[i + ixmax] = cr[ixx]; this->Q[i + 2 * ixmax] = cr[ixx]; } MPI_Send(this->Q, ixmax * 3, MPI_DOUBLE, PR->nx0, 0, MPI_COMM_WORLD); } - if (PR->nst == 0) { //Sum over t at x=0 + if (PR->nst == 0) { // Sum over t at x=0 for (int tag = 1; tag < PR->NtNs; tag++) { if ((tag / PR->Ntdiv) % PR->Nxdiv != 0) continue; - MPI_Recv(m_val, Lcr2, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, &status); - for (int i = 0; i < Lcr2; i++) - values_L[f_gf(i)] += m_val[i]; + MPI_Recv(m_val, Lcr2, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, + &status); + for (int i = 0; i < Lcr2; i++) values_L[f_gf(i)] += m_val[i]; } } else if (PR->nx == 0) { - MPI_Send(&(values_L[f_gf(0)]), Lcr2, MPI_DOUBLE, PR->nst0, 0, MPI_COMM_WORLD); + MPI_Send(&(values_L[f_gf(0)]), Lcr2, MPI_DOUBLE, PR->nst0, 0, + MPI_COMM_WORLD); } } -void Quantities::CorrelationFunction2(GraphSpace::Vertex *world) { //momentum space +void Quantities::CorrelationFunction2( + GraphSpace::Vertex *world) { // momentum space MPI_Status status; complex Nk2; ////G2/// - for (int i = 0; i < Nk_set; i++) - Ck[i] = complex(0.0, 0.0); + for (int i = 0; i < Nk_set; i++) Ck[i] = complex(0.0, 0.0); - double rootV = sqrt((double)N->V); + double rootV = sqrt((double)N->V); double rootV2 = N->V; double rootV3 = rootV2 * rootV; double rootV4 = rootV2 * rootV2; for (int r = 0; r < V; r++) { double ancr = an[r] * cr[r]; - double n = world[r].p; - double ck0 = ancr - n; - double nn = 1.0 - n; + double n = world[r].p; + double ck0 = ancr - n; + double nn = 1.0 - n; Ck[0] += ck0 / rootV2; Ck[1] += ancr / rootV2; Ck[2] += (ancr * ancr - n) / rootV4; Ck[3] += n / rootV2; - Ck[4] += (5.0 * ancr * ancr - 6.0 * n * ancr - 2.0 * nn * ancr + 2.0 * ancr + n * n + n * nn) / rootV4; + Ck[4] += (5.0 * ancr * ancr - 6.0 * n * ancr - 2.0 * nn * ancr + + 2.0 * ancr + n * n + n * nn) / + rootV4; for (int a = 0; a < 2; a++) { for (int k = 0; k < Nkmax; k++) { @@ -1020,83 +1040,102 @@ void Quantities::CorrelationFunction2(GraphSpace::Vertex *world) { //momentum s Ck[f_ck(k, 10, a)] += ck0 * an[r] * EXPrk[theta(r, -k, a)] / rootV3; Ck[f_ck(k, 11, a)] += ck0 * cr[r] * EXPrk[theta(r, k, a)] / rootV3; - Ck[f_ck(k, 12, a)] += (ancr - nn) * an[r] * EXPrk[theta(r, -k, a)] / rootV3; - Ck[f_ck(k, 13, a)] += (ancr - nn) * cr[r] * EXPrk[theta(r, k, a)] / rootV3; + Ck[f_ck(k, 12, a)] += + (ancr - nn) * an[r] * EXPrk[theta(r, -k, a)] / rootV3; + Ck[f_ck(k, 13, a)] += + (ancr - nn) * cr[r] * EXPrk[theta(r, k, a)] / rootV3; Ck[f_ck(k, 14, a)] += ancr * an[r] * EXPrk[theta(r, -k, a)] / rootV3; Ck[f_ck(k, 15, a)] += ancr * cr[r] * EXPrk[theta(r, k, a)] / rootV3; } for (int k = 1; k < Nkmax; k++) { - Ck[f_ck(-k, 5, a)] += ancr * EXPrk[theta(r, -k, a)] / rootV2; //ck(4)<=ck(-k)<=ck(5) + Ck[f_ck(-k, 5, a)] += + ancr * EXPrk[theta(r, -k, a)] / rootV2; // ck(4)<=ck(-k)<=ck(5) Ck[f_ck(-k, 7, a)] += n * EXPrk[theta(r, -k, a)] / rootV2; Ck[f_ck(-k, 9, a)] += nn * EXPrk[theta(r, -k, a)] / rootV2; } } } - if (PR->ns == 0) { //Sum over site at same tau + if (PR->ns == 0) { // Sum over site at same tau for (int tag = 1; tag < PR->Nsdiv; tag++) { - MPI_Recv(Ck_m, Nk_set + Sk_set, MPI_DOUBLE_COMPLEX, tag * PR->Ntdiv + PR->ns0, 0, MPI_COMM_WORLD, &status); - for (int i = 0; i < Nk_set + Sk_set; i++) - Ck[i] += Ck_m[i]; + MPI_Recv(Ck_m, Nk_set + Sk_set, MPI_DOUBLE_COMPLEX, + tag * PR->Ntdiv + PR->ns0, 0, MPI_COMM_WORLD, &status); + for (int i = 0; i < Nk_set + Sk_set; i++) Ck[i] += Ck_m[i]; } ///////////////// Gk ////////////////////// for (int a = 0; a < 2; a++) { for (int k = 0; k < Nkxmax; k++) { - Nk2 = (Ck[f_ck(k, 0, a)] * Ck[f_ck(k, 1, a)] - Ck[0]) / (double)N->V; + Nk2 = (Ck[f_ck(k, 0, a)] * Ck[f_ck(k, 1, a)] - Ck[0]) / (double)N->V; values_L[f_nkr(k + a * Nkxmax)] = real(Nk2); values_L[f_nki(k + a * Nkxmax)] = imag(Nk2); } } ////////////////////////////////////////// ///////////////// Sk ////////////////////// - //for(int k=0;kNtdiv; //Structure factor //} ////////////////////////////////////////// } else { - MPI_Send(Ck, Nk_set + Sk_set, MPI_DOUBLE_COMPLEX, PR->ns0, 0, MPI_COMM_WORLD); + MPI_Send(Ck, Nk_set + Sk_set, MPI_DOUBLE_COMPLEX, PR->ns0, 0, + MPI_COMM_WORLD); } // complex Gk2, Dkkk; if (PR->ns == 0) { - for (int kx = 0; kx < Nkxmax; kx++) { //(kx,ky,kz)=(0~Nkmax,0,0); (0~Nkmax,kx,kx) - - for (int kk = 0; kk < Nkkmax; kk++) { //(k'x,k'y,k'z)=(0,0,0);...(depends on CKK)...; (kx,ky,kz) - - Gk2 = Ck[f_ck(kx, 0)] * Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 0)] * Ck[f_ck(kk, 1)] - - - (Ck[0] * (Ck[f_ck(kk, 1)] * Ck[f_ck(kk, 0)] - Ck[1]) - Ck[f_ck(kk, 11)] * Ck[f_ck(kk, 0)] - - Ck[f_ck(kk, 10)] * Ck[f_ck(kk, 1)]) //i=j - - (Ck[f_ck(kk + kx, 3)] * (Ck[f_ck(kx, 0)] * Ck[f_ck(kk, 0)] - Ck[f_ck(kk + kx, 2)]) - - Ck[f_ck(kk, 15)] * Ck[f_ck(kk, 0)] - Ck[f_ck(kx, 15)] * Ck[f_ck(kx, 0)]) //i=l - - ((Ck[f_ck(kx - kk, 5)] - Ck[f_ck(kx - kk, 7)]) - * (Ck[f_ck(kx, 0)] * Ck[f_ck(kk, 1)] - Ck[f_ck(kk - kx, 5)]) - - Ck[f_ck(kk, 10)] * Ck[f_ck(kk, 1)] - Ck[f_ck(kx, 11)] * Ck[f_ck(kx, 0)]) //i=m - - (Ck[f_ck(kx + kk, 2)] * (Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 1)] - Ck[f_ck(kk + kx, 3)]) - - Ck[f_ck(kx, 14)] * Ck[f_ck(kx, 1)] - Ck[f_ck(kk, 14)] * Ck[f_ck(kk, 1)]) //j=m - - ((Ck[f_ck(kk - kx, 5)] - Ck[f_ck(kk - kx, 9)]) - * (Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 0)] - Ck[f_ck(kx - kk, 5)]) - - Ck[f_ck(kx, 12)] * Ck[f_ck(kx, 1)] - Ck[f_ck(kk, 13)] * Ck[f_ck(kk, 0)]) //j=l - - (Ck[0] * (Ck[f_ck(kx, 1)] * Ck[f_ck(kx, 0)] - Ck[1]) - Ck[f_ck(kx, 11)] * Ck[f_ck(kx, 0)] - - Ck[f_ck(kx, 10)] * Ck[f_ck(kx, 1)]) //l=m - - - (Ck[f_ck(kk, 15)] - Ck[f_ck(kk, 1)] / rootV2) * Ck[f_ck(kk, 0)] //i=j=l - - Ck[f_ck(kk, 14)] * Ck[f_ck(kk, 1)] //i=j=m - - Ck[f_ck(kx, 15)] * Ck[f_ck(kx, 0)] //i=m=l - - (Ck[f_ck(kx, 14)] - Ck[f_ck(kx, 0)] / rootV2) * Ck[f_ck(kx, 1)] //j=l=m - - - (Ck[1] * Ck[1] - Ck[3] * Ck[3]) //i=j,l=m - - (Ck[f_ck(kx - kk, 5)] * Ck[f_ck(kk - kx, 5)] - Ck[f_ck(kx - kk, 7)] * Ck[f_ck(kk - kx, 9)]) //i=m,j=l - - Ck[f_ck(kk + kx, 3)] * Ck[f_ck(kk + kx, 2)] //i=l,j=m - - Ck[2] //i=j=l=m - - Ck[4]; - - Dkkk = Gk2; //vol2; + for (int kx = 0; kx < Nkxmax; + kx++) { //(kx,ky,kz)=(0~Nkmax,0,0); (0~Nkmax,kx,kx) + + for (int kk = 0; kk < Nkkmax; + kk++) { //(k'x,k'y,k'z)=(0,0,0);...(depends on CKK)...; (kx,ky,kz) + + Gk2 = + Ck[f_ck(kx, 0)] * Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 0)] * + Ck[f_ck(kk, 1)] + + - (Ck[0] * (Ck[f_ck(kk, 1)] * Ck[f_ck(kk, 0)] - Ck[1]) - + Ck[f_ck(kk, 11)] * Ck[f_ck(kk, 0)] - + Ck[f_ck(kk, 10)] * Ck[f_ck(kk, 1)]) // i=j + - (Ck[f_ck(kk + kx, 3)] * + (Ck[f_ck(kx, 0)] * Ck[f_ck(kk, 0)] - Ck[f_ck(kk + kx, 2)]) - + Ck[f_ck(kk, 15)] * Ck[f_ck(kk, 0)] - + Ck[f_ck(kx, 15)] * Ck[f_ck(kx, 0)]) // i=l + - ((Ck[f_ck(kx - kk, 5)] - Ck[f_ck(kx - kk, 7)]) * + (Ck[f_ck(kx, 0)] * Ck[f_ck(kk, 1)] - Ck[f_ck(kk - kx, 5)]) - + Ck[f_ck(kk, 10)] * Ck[f_ck(kk, 1)] - + Ck[f_ck(kx, 11)] * Ck[f_ck(kx, 0)]) // i=m + - (Ck[f_ck(kx + kk, 2)] * + (Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 1)] - Ck[f_ck(kk + kx, 3)]) - + Ck[f_ck(kx, 14)] * Ck[f_ck(kx, 1)] - + Ck[f_ck(kk, 14)] * Ck[f_ck(kk, 1)]) // j=m + - ((Ck[f_ck(kk - kx, 5)] - Ck[f_ck(kk - kx, 9)]) * + (Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 0)] - Ck[f_ck(kx - kk, 5)]) - + Ck[f_ck(kx, 12)] * Ck[f_ck(kx, 1)] - + Ck[f_ck(kk, 13)] * Ck[f_ck(kk, 0)]) // j=l + - (Ck[0] * (Ck[f_ck(kx, 1)] * Ck[f_ck(kx, 0)] - Ck[1]) - + Ck[f_ck(kx, 11)] * Ck[f_ck(kx, 0)] - + Ck[f_ck(kx, 10)] * Ck[f_ck(kx, 1)]) // l=m + + - (Ck[f_ck(kk, 15)] - Ck[f_ck(kk, 1)] / rootV2) * + Ck[f_ck(kk, 0)] // i=j=l + - Ck[f_ck(kk, 14)] * Ck[f_ck(kk, 1)] // i=j=m + - Ck[f_ck(kx, 15)] * Ck[f_ck(kx, 0)] // i=m=l + - (Ck[f_ck(kx, 14)] - Ck[f_ck(kx, 0)] / rootV2) * + Ck[f_ck(kx, 1)] // j=l=m + + - (Ck[1] * Ck[1] - Ck[3] * Ck[3]) // i=j,l=m + - (Ck[f_ck(kx - kk, 5)] * Ck[f_ck(kk - kx, 5)] - + Ck[f_ck(kx - kk, 7)] * Ck[f_ck(kk - kx, 9)]) // i=m,j=l + - Ck[f_ck(kk + kx, 3)] * Ck[f_ck(kk + kx, 2)] // i=l,j=m + - Ck[2] // i=j=l=m + - Ck[4]; + + Dkkk = Gk2; // vol2; // for(int kky=0; kky<1; kky++){ //ky=kky= 0 or kx(kkx) values_L[f_gk2r(kx, kk)] = real(Dkkk); @@ -1107,20 +1146,19 @@ void Quantities::CorrelationFunction2(GraphSpace::Vertex *world) { //momentum s } //******* - int L3 = Lmax[ck2] + Lmax[ck4]; //for nk, gk2 + int L3 = Lmax[ck2] + Lmax[ck4]; // for nk, gk2 - if (PR->nst == 0) { //Sum over t=0 + if (PR->nst == 0) { // Sum over t=0 for (int tag = 1; tag < PR->Ntdiv; tag++) { - MPI_Recv(m_val, L3, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, &status); - for (int i = 0; i < L3; i++) - values_L[f_nk(i)] += m_val[i]; + MPI_Recv(m_val, L3, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, + &status); + for (int i = 0; i < L3; i++) values_L[f_nk(i)] += m_val[i]; } - for (int i = 0; i < L3; i++) - values_L[f_nk(i)] /= (double)PR->Ntdiv; + for (int i = 0; i < L3; i++) values_L[f_nk(i)] /= (double)PR->Ntdiv; - } else if (PR->ns == 0) { //Ntdiv prosessors for nk, gf2, gk2 + } else if (PR->ns == 0) { // Ntdiv prosessors for nk, gf2, gk2 MPI_Send(&(values_L[f_nk(0)]), L3, MPI_DOUBLE, PR->nst0, 0, MPI_COMM_WORLD); } } diff --git a/src/pmwa/sfgene.cc b/src/pmwa/sfgene.cc index cbce9a4f..a3e884ae 100644 --- a/src/pmwa/sfgene.cc +++ b/src/pmwa/sfgene.cc @@ -4,24 +4,27 @@ ----------------------------------------------*/ +#include #include -#include #include + #include -#include +#include using namespace std; //-------------------------------------------------------------- void ShowUsage(int argc, char **argv) { - cout << "usage: $ " << argv[0] << " [ D, L0 , L1 , Ntau, Ntau_cutoff, KTYPE ] \n"; + cout << "usage: $ " << argv[0] + << " [ D, L0 , L1 , Ntau, Ntau_cutoff, KTYPE ] \n"; cout << " Hypercubic lattice L0 x L1 x L2... \n"; cout << " \n"; cout << " L0, L1 ... the liner size of the lattice. \n"; cout << " ( L0, L1, ..., must be even number. )\n"; cout << " available KTYPE=0: kx=pi n/L, n=0,2, 4,,,, L" << endl; cout << " available KTYPE=1: k=(pi,0),(pi,pi),(0,pi),(pi/2,pi/2)" << endl; - cout << " available KTYPE=2: k=(pi 7/8,pi 1/8),(pi 3/4,pi/4),(pi 5/8,pi 3/8)" << endl; + cout << " available KTYPE=2: k=(pi 7/8,pi 1/8),(pi 3/4,pi/4),(pi 5/8,pi 3/8)" + << endl; cout << " available KTYPE=3: k=(pi 7/8,pi 7/8)" << endl; } @@ -29,7 +32,7 @@ void ShowUsage(int argc, char **argv) { void WriteXML(int D, int L[], int Ntau, int CutoffOfNtau, int KTYPE) { ofstream fout("sf.xml"); fout.precision(8); - int N = 1; //number of sites. + int N = 1; // number of sites. for (int i = 0; i < D; i++) { N *= L[i]; } @@ -67,9 +70,12 @@ void WriteXML(int D, int L[], int Ntau, int CutoffOfNtau, int KTYPE) { fout << "" << endl << endl; fout << " " << Ntau << " " << endl; - fout << " " << NumberOfElements << " " << endl; - fout << " " << CutoffOfNtau << " " << endl; - fout << " " << KMAX << " " << endl; + fout << " " << NumberOfElements + << " " << endl; + fout << " " << CutoffOfNtau << " " + << endl; + fout << " " << KMAX << " " + << endl; fout << endl; fout << "" << endl << endl; @@ -87,10 +93,12 @@ void WriteXML(int D, int L[], int Ntau, int CutoffOfNtau, int KTYPE) { } fout << endl; - fout << "" << endl << endl; + fout << "" + << endl + << endl; - int NB = 0; //3 * N ; // number of bonds - int *x = new int[D]; + int NB = 0; // 3 * N ; // number of bonds + int *x = new int[D]; int *dx = new int[D]; double PI = M_PI; @@ -99,7 +107,8 @@ void WriteXML(int D, int L[], int Ntau, int CutoffOfNtau, int KTYPE) { for (int q = 0; q < KMAX; q++) { int rx = i % L[0]; double phase; - if (KTYPE == 0) phase = rx * ksite[q] * PI / (double)L[0]; // r_x * q_x + if (KTYPE == 0) + phase = rx * ksite[q] * PI / (double)L[0]; // r_x * q_x else if (KTYPE == 1) { int ry = (i / L[0]) % L[1]; double qx; @@ -119,8 +128,7 @@ void WriteXML(int D, int L[], int Ntau, int CutoffOfNtau, int KTYPE) { } phase = rx * qx * PI + ry * qy * PI; // r_x * q_x - } - else if (KTYPE == 2) { + } else if (KTYPE == 2) { int ry = (i / L[0]) % L[1]; double qx; double qy; @@ -136,8 +144,7 @@ void WriteXML(int D, int L[], int Ntau, int CutoffOfNtau, int KTYPE) { } phase = rx * qx * PI + ry * qy * PI; // r_x * q_x - } - else if (KTYPE == 3) { + } else if (KTYPE == 3) { int ry = (i / L[0]) % L[1]; double qx; double qy; @@ -160,7 +167,8 @@ void WriteXML(int D, int L[], int Ntau, int CutoffOfNtau, int KTYPE) { if (fabs(COSrk) < 1.0e-12) COSrk = 0.0; if (fabs(SINrk) < 1.0e-12) SINrk = 0.0; - fout << " " << COSrk << " " << SINrk << " " << i << " " << q << " " << endl; + fout << " " << COSrk << " " << SINrk << " " << i << " " << q + << " " << endl; } } @@ -177,7 +185,7 @@ int main(int argc, char **argv) { ShowUsage(argc, argv); exit(0); } - int iarg = 1; + int iarg = 1; const int D = atoi(argv[iarg]); iarg++; if (argc != D + 5) { @@ -207,7 +215,9 @@ int main(int argc, char **argv) { EvenOrOdd += L[i] % 2; } - if (EvenOrOdd) { cout << "Warnig: L should be an even number." << endl; } + if (EvenOrOdd) { + cout << "Warnig: L should be an even number." << endl; + } WriteXML(D, L, Ntau, Ntcut, KTYPE); cout << "... done." << endl; diff --git a/src/pmwa/worm.h b/src/pmwa/worm.h index 09be04c3..ff4943f3 100644 --- a/src/pmwa/worm.h +++ b/src/pmwa/worm.h @@ -7,7 +7,9 @@ void GraphSpace::Worm_Update(My_rdm *MR) { while (it != WORM.end()) { worm = *it; - if (Next_event(MR)) { transition(MR); } + if (Next_event(MR)) { + transition(MR); + } ++it; } @@ -20,7 +22,7 @@ bool GraphSpace::Next_event(My_rdm *MR) { bool dir; short type; - dir = worm->dir; + dir = worm->dir; type = worm->next[dir]->type; if (type == 0) @@ -39,7 +41,7 @@ bool GraphSpace::Next_event(My_rdm *MR) { if (For_Nworm) Wlen += Ib + la; - worm->t = (dir) ? worm->next[1]->t - la : worm->next[0]->t + la; + worm->t = (dir) ? worm->next[1]->t - la : worm->next[0]->t + la; worm->dir = !dir; return false; @@ -47,71 +49,71 @@ bool GraphSpace::Next_event(My_rdm *MR) { } void GraphSpace::transition(My_rdm *MR) { - int a; // after - int b; // before + int a; // after + int b; // before int ni, nj; //,xl; double R, Pt; double dla; // dir == false : downward // dir == true : upward - bool dir = worm->dir; + bool dir = worm->dir; // oh == false : annihilation // oh == true : creation - bool oh = worm->type - 4; + bool oh = worm->type - 4; short next_type = vertex[0]->type; - //a,b : worm position - //0: below the next vertex - //1: above the next vertex - //2: above the next kink - //3: below the next kink + // a,b : worm position + // 0: below the next vertex + // 1: above the next vertex + // 2: above the next kink + // 3: below the next kink switch (next_type) { - case 0: //Onsite + case 0: // Onsite - b = (oh == dir) ? 0 : 1; + b = (oh == dir) ? 0 : 1; - if (MR->rdm() < P->u[b][vertex[0]->p][vertex[0]->i]) { //pass - (oh == dir) ? vertex[0]->p++ : vertex[0]->p--; - relink(dir, dir, 0); - } else - worm->dir = !dir; //bounce + if (MR->rdm() < P->u[b][vertex[0]->p][vertex[0]->i]) { // pass + (oh == dir) ? vertex[0]->p++ : vertex[0]->p--; + relink(dir, dir, 0); + } else + worm->dir = !dir; // bounce - dir = worm->dir; //new direction + dir = worm->dir; // new direction - dla = I[dir] * MR->rdm(); - worm->t = tA + sgn[dir] * dla; + dla = I[dir] * MR->rdm(); + worm->t = tA + sgn[dir] * dla; - if (For_Nworm) Wlen += dla; + if (For_Nworm) Wlen += dla; - return; + return; - case 1: //nearest-Vertex + case 1: // nearest-Vertex - b = !dir; + b = !dir; - ni = worm->p; - nj = vertex[1]->p; - // xl = LT->lx[worm->i%V]; - break; - case 2: //Kink + ni = worm->p; + nj = vertex[1]->p; + // xl = LT->lx[worm->i%V]; + break; + case 2: // Kink - ni = vertex[1]->p; - // xl = LT->lx[vertex[1]->i%V]; - b = 2 + dir; + ni = vertex[1]->p; + // xl = LT->lx[vertex[1]->i%V]; + b = 2 + dir; - if (!dir) - nj = worm->p; //b=2; - else - nj = vertex[0]->p; //b=3; + if (!dir) + nj = worm->p; // b=2; + else + nj = vertex[0]->p; // b=3; - break; + break; } - R = MR->rdm(); + R = MR->rdm(); Pt = 0.0; for (a = 0; a < 4; a++) { @@ -180,7 +182,7 @@ void GraphSpace::turn(bool oh, bool dir, int b, int a, double dla) { void GraphSpace::k_neibor() { vertex[0]->type = vertex[1]->type = 1; - worm->i = vertex[1]->i % V; + worm->i = vertex[1]->i % V; } void GraphSpace::k_neibor_dir() { // w/ changing direction @@ -191,7 +193,7 @@ void GraphSpace::k_neibor_dir() { // w/ changing direction void GraphSpace::v_neibor() { vertex[0]->type = vertex[1]->type = 2; - worm->i = vertex[1]->i % V; + worm->i = vertex[1]->i % V; } void GraphSpace::v_neibor_dir() { @@ -202,7 +204,7 @@ void GraphSpace::v_neibor_dir() { void GraphSpace::Newtime(int a, double dla) { double ta, tb; - bool dir = worm->dir; //new direction + bool dir = worm->dir; // new direction tb = tA; ta = dla + dir * tA + (!dir) * t[a]; @@ -217,14 +219,14 @@ inline double GraphSpace::LengthofWalk(double next_t, double curr_t, bool dir) { } void GraphSpace::relink(bool b_dir, bool a_dir, bool aside) { - vertex[aside]->next[a_dir]->next[!a_dir] = worm; //1 - worm->next[!b_dir]->next[b_dir] = vertex[0]; //2 + vertex[aside]->next[a_dir]->next[!a_dir] = worm; // 1 + worm->next[!b_dir]->next[b_dir] = vertex[0]; // 2 - vertex[0]->next[!b_dir] = worm->next[!b_dir]; //3 - worm->next[a_dir] = vertex[aside]->next[a_dir]; //4 + vertex[0]->next[!b_dir] = worm->next[!b_dir]; // 3 + worm->next[a_dir] = vertex[aside]->next[a_dir]; // 4 - vertex[aside]->next[a_dir] = worm; //5 - worm->next[!a_dir] = vertex[aside]; //6 + vertex[aside]->next[a_dir] = worm; // 5 + worm->next[!a_dir] = vertex[aside]; // 6 } bool GraphSpace::update_selection(My_rdm *MR, bool dir, short type) { @@ -233,12 +235,12 @@ bool GraphSpace::update_selection(My_rdm *MR, bool dir, short type) { vertex[0] = worm->next[dir]; vertex[1] = worm->next[dir]->nleg; - tA = vertex[0]->t; // time of the next vertex + tA = vertex[0]->t; // time of the next vertex double tc = worm->next[!dir]->t; // time of the previous vertex double Ic = (1.0 - 2.0 * dir) * (tc - tA); - // ratate vertex - + // ratate vertex + // cnum(type,dir): // cnum(1,0) = 1 // cnum(1,1) = 0 From be8a3eebf630fd7065072da322792edfe9a24d49 Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Thu, 4 Feb 2021 23:21:52 +0900 Subject: [PATCH 02/54] cpplint --- src/common/read_keyvalues.h | 10 +- src/common/timer.hpp | 10 +- src/common/tostring.h | 6 +- src/common/version.h | 6 +- src/dla/SPECIFIC/Boson/measure_specific.cc | 4 +- src/dla/SPECIFIC/Boson/measure_specific.h | 14 +- .../SPECIFIC/Heisenberg/measure_specific.cc | 2 +- .../SPECIFIC/Heisenberg/measure_specific.h | 14 +- src/dla/accumulator.hpp | 52 ++-- src/dla/algorithm.hpp | 284 +++++++++--------- src/dla/calctimer.hpp | 8 +- src/dla/cf.hpp | 15 +- src/dla/chainjob.hpp | 31 +- src/dla/ck.hpp | 19 +- src/dla/debug.hpp | 6 +- src/dla/displacement.hpp | 11 +- src/dla/dla.cc | 51 ++-- src/dla/io.h | 61 ++-- src/dla/lattice.hpp | 24 +- src/dla/link.hpp | 91 +++--- src/dla/measure.hpp | 17 +- src/dla/name.h | 45 ++- src/dla/objects.hpp | 173 +++++------ src/dla/parameter.hpp | 16 +- src/dla/random.cc | 9 +- src/dla/random.h | 2 +- src/dla/serialize.hpp | 7 +- src/dla/sf.hpp | 12 +- src/dla/util.hpp | 7 +- src/dla/wavevector.hpp | 9 +- src/dla/xml.h | 52 ++-- src/pmwa/PMWA.cpp | 8 +- src/pmwa/configuration.cpp | 49 +-- src/pmwa/graphspace.cpp | 72 +++-- src/pmwa/inc/Configuration.h | 7 +- src/pmwa/inc/Graph_functions.h | 20 +- src/pmwa/inc/PMWA.h | 10 +- src/pmwa/inc/Probability.h | 6 +- src/pmwa/inc/Quantities.h | 6 +- src/pmwa/inc/lattice.hpp | 13 +- src/pmwa/inc/systemparameter.h | 8 +- src/pmwa/inc/xml.hpp | 50 ++- src/pmwa/lattgene.cc | 9 +- src/pmwa/lattice.cpp | 14 +- src/pmwa/probability.B.cpp | 23 +- src/pmwa/probability.H.cpp | 39 ++- src/pmwa/quantities.B.cpp | 121 ++++---- src/pmwa/quantities.H.cpp | 128 ++++---- src/pmwa/sfgene.cc | 16 +- 49 files changed, 808 insertions(+), 859 deletions(-) diff --git a/src/common/read_keyvalues.h b/src/common/read_keyvalues.h index e7838225..61dd6d65 100644 --- a/src/common/read_keyvalues.h +++ b/src/common/read_keyvalues.h @@ -14,15 +14,15 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef READ_KEYVALUES_H -#define READ_KEYVALUES_H +#ifndef SRC_COMMON_READ_KEYVALUES_H_ +#define SRC_COMMON_READ_KEYVALUES_H_ -#include -#include #include +#include #include #include #include +#include void read_keyvalues(std::map& dict, std::string const& filename); @@ -98,4 +98,4 @@ bool parse_kvline(std::string& key, std::string& value, dict[new] = dict[old]; \ } -#endif // READ_KEYVALUES_H +#endif // SRC_COMMON_READ_KEYVALUES_H_ diff --git a/src/common/timer.hpp b/src/common/timer.hpp index 0a0b30a7..bc6d0c68 100644 --- a/src/common/timer.hpp +++ b/src/common/timer.hpp @@ -14,18 +14,22 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef TIMER_HPP -#define TIMER_HPP +#ifndef SRC_COMMON_TIMER_HPP_ +#define SRC_COMMON_TIMER_HPP_ #include #ifdef BOOST_NO_CXX11_HDR_CHRONO + #define BOOST_CHRONO_HEADER_ONLY #include namespace CHRONO = boost::chrono; + #else + #include namespace CHRONO = std::chrono; + #endif class Timer { @@ -41,4 +45,4 @@ class Timer { 1.0e-6; } }; -#endif // TIMER_HPP +#endif // SRC_COMMON_TIMER_HPP_ diff --git a/src/common/tostring.h b/src/common/tostring.h index f4f6f2ad..21e1df8c 100644 --- a/src/common/tostring.h +++ b/src/common/tostring.h @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef DSQSS_TOSTRING_H -#define DSQSS_TOSTRING_H +#ifndef SRC_COMMON_TOSTRING_H_ +#define SRC_COMMON_TOSTRING_H_ #include #include @@ -27,4 +27,4 @@ std::string tostring(T const& x) { return ss.str(); } -#endif +#endif // SRC_COMMON_TOSTRING_H_ diff --git a/src/common/version.h b/src/common/version.h index 25660e3a..a7d0703f 100644 --- a/src/common/version.h +++ b/src/common/version.h @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef VERSION_H -#define VERSION_H +#ifndef SRC_COMMON_VERSION_H_ +#define SRC_COMMON_VERSION_H_ #define DSQSS_VERSION "v2.0.3" -#endif +#endif // SRC_COMMON_VERSION_H_ diff --git a/src/dla/SPECIFIC/Boson/measure_specific.cc b/src/dla/SPECIFIC/Boson/measure_specific.cc index 7d2e96f3..525e9d9f 100644 --- a/src/dla/SPECIFIC/Boson/measure_specific.cc +++ b/src/dla/SPECIFIC/Boson/measure_specific.cc @@ -115,9 +115,9 @@ void Measurement::measure(double sgn) { Segment& S = *p; if (xlast != S.X()) { if ((*S.bottom().S(0).getONSITE()).id() - 1 == Bsite) { - wind[dim] += (double)(S.bottom().S(1).X() - S.bottom().S(0).X()); + wind[dim] += static_cast(S.bottom().S(1).X() - S.bottom().S(0).X()); } else if ((*S.bottom().S(2).getONSITE()).id() - 1 == Bsite) { - wind[dim] += (double)(S.bottom().S(3).X() - S.bottom().S(2).X()); + wind[dim] += static_cast(S.bottom().S(3).X() - S.bottom().S(2).X()); } xlast = S.X(); } diff --git a/src/dla/SPECIFIC/Boson/measure_specific.h b/src/dla/SPECIFIC/Boson/measure_specific.h index 88ad6547..d95ca46d 100644 --- a/src/dla/SPECIFIC/Boson/measure_specific.h +++ b/src/dla/SPECIFIC/Boson/measure_specific.h @@ -1,5 +1,5 @@ -#ifndef MEASURE_SPECIFIC_IMPL_H -#define MEASURE_SPECIFIC_IMPL_H +#ifndef SRC_DLA_SPECIFIC_BOSON_MEASURE_SPECIFIC_IMPL_H_ +#define SRC_DLA_SPECIFIC_BOSON_MEASURE_SPECIFIC_IMPL_H_ #include @@ -38,9 +38,9 @@ enum { Wxy2, NACC, // number of quantities measured at each MC step }; -static std::string ANAME[NACC] = {"sgn", "nv1", "eb1", "eb2", "le1", - "mzua1", "mzua2", "mzub1", "mzub2", "mzsa1", - "mzsa2", "mzsb1", "mzsb2", "nh1", "wxy2"}; +static const char ANAME[][NACC] = { + "sgn", "nv1", "eb1", "eb2", "le1", "mzua1", "mzua2", "mzub1", + "mzub2", "mzsa1", "mzsa2", "mzsb1", "mzsb2", "nh1", "wxy2"}; // observable specifier enum { @@ -73,10 +73,10 @@ enum { NPHY, // number of quantities computed at each set }; -static std::string PNAME[NPHY] = { +static const char PNAME[][NPHY] = { "sign", "anv", "ene", "spe", "len", "xmx", "amzu", "bmzu", "smzu", "xmzu", "amzs", "bmzs", "smzs", "xmzs", "ds1", "wi2", "rhos", "comp"}; } // namespace Specific -#endif // MEASURE_SPECIFIC_IMPL_H +#endif // SRC_DLA_SPECIFIC_BOSON_MEASURE_SPECIFIC_IMPL_H_ diff --git a/src/dla/SPECIFIC/Heisenberg/measure_specific.cc b/src/dla/SPECIFIC/Heisenberg/measure_specific.cc index ab19e59b..6e09a323 100644 --- a/src/dla/SPECIFIC/Heisenberg/measure_specific.cc +++ b/src/dla/SPECIFIC/Heisenberg/measure_specific.cc @@ -44,7 +44,7 @@ void Measurement::measure(double sgn) { MZUB *= T; MZSB *= T; - double EBSAMP = -(double)NV; + double EBSAMP = -1.0*NV; for (int b = 0; b < LAT.NINT; b++) { Interaction& I = LAT.I(b); diff --git a/src/dla/SPECIFIC/Heisenberg/measure_specific.h b/src/dla/SPECIFIC/Heisenberg/measure_specific.h index 88fd7223..f6cdd167 100644 --- a/src/dla/SPECIFIC/Heisenberg/measure_specific.h +++ b/src/dla/SPECIFIC/Heisenberg/measure_specific.h @@ -1,5 +1,5 @@ -#ifndef MEASURE_SPECIFIC_IMPL_H -#define MEASURE_SPECIFIC_IMPL_H +#ifndef SRC_DLA_SPECIFIC_HEISENBERG_MEASURE_SPECIFIC_H_ +#define SRC_DLA_SPECIFIC_HEISENBERG_MEASURE_SPECIFIC_H_ #include @@ -36,9 +36,9 @@ enum { NACC, // number of quantities measured at each MC step }; -static std::string ANAME[NACC] = {"sgn", "nv1", "eb1", "eb2", "le1", - "mzua1", "mzua2", "mzub1", "mzub2", "mzsa1", - "mzsa2", "mzsb1", "mzsb2"}; +static const char ANAME[][NACC] = {"sgn", "nv1", "eb1", "eb2", "le1", + "mzua1", "mzua2", "mzub1", "mzub2", "mzsa1", + "mzsa2", "mzsb1", "mzsb2"}; // observable specifier enum { @@ -67,11 +67,11 @@ enum { NPHY, // number of quantities computed at each set }; -static std::string PNAME[NPHY] = { +static const char PNAME[][NPHY] = { "sign", "anv", "ene", "spe", "len", "xmx", "amzu", "bmzu", "smzu", "xmzu", "amzs", "bmzs", "smzs", "xmzs", }; } // namespace Specific -#endif // MEASURE_SPECIFIC_IMPL_H +#endif // SRC_DLA_SPECIFIC_HEISENBERG_MEASURE_SPECIFIC_H_ diff --git a/src/dla/accumulator.hpp b/src/dla/accumulator.hpp index cfe00b17..64bc62a2 100644 --- a/src/dla/accumulator.hpp +++ b/src/dla/accumulator.hpp @@ -1,3 +1,19 @@ +// DSQSS (Discrete Space Quantum Systems Solver) +// Copyright (C) 2018- The University of Tokyo +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + //###################################################################### //#### //#### World-Line Monte Carlo simulation @@ -16,24 +32,8 @@ //#### //###################################################################### -// DSQSS (Discrete Space Quantum Systems Solver) -// Copyright (C) 2018- The University of Tokyo -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#ifndef ACCUMULATOR_H -#define ACCUMULATOR_H +#ifndef SRC_DLA_ACCUMULATOR_HPP_ +#define SRC_DLA_ACCUMULATOR_HPP_ //###################################################################### @@ -61,8 +61,8 @@ class Accumulator { int n; public: - Accumulator() : k("Unset"){}; - explicit Accumulator(std::string const& s) : k(s){}; + Accumulator() : k("Unset"){} + explicit Accumulator(std::string const& s) : k(s){} void reset() { k = "Unset"; @@ -71,18 +71,18 @@ class Accumulator { s1 = 0.0; s2 = 0.0; n = 0; - }; + } void reset(std::string const& s) { reset(); set_key(s); - }; - void set_key(std::string const& s) { k = s; }; + } + void set_key(std::string const& s) { k = s; } void accumulate(double x) { n++; s1 += x; s2 += (x * x); - }; + } void average() { value = 0.0; @@ -98,7 +98,7 @@ class Accumulator { error = 0.0; } } - }; + } const char* ckey() const { return k.c_str(); } std::string key() const { return k; } @@ -168,4 +168,4 @@ void load(std::ifstream& F, Accumulator& acc) { } } // namespace Serialize -#endif // ACCUMULATOR_H +#endif // SRC_DLA_ACCUMULATOR_HPP_ diff --git a/src/dla/algorithm.hpp b/src/dla/algorithm.hpp index 8dd4d048..60d69403 100644 --- a/src/dla/algorithm.hpp +++ b/src/dla/algorithm.hpp @@ -1,3 +1,19 @@ +// DSQSS (Discrete Space Quantum Systems Solver) +// Copyright (C) 2018- The University of Tokyo +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + //###################################################################### //#### //#### World-Line Monte Carlo simulation @@ -16,30 +32,16 @@ //#### //###################################################################### -// DSQSS (Discrete Space Quantum Systems Solver) -// Copyright (C) 2018- The University of Tokyo -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - - -#ifndef ALGORITHM_H -#define ALGORITHM_H +#ifndef SRC_DLA_ALGORITHM_HPP_ +#define SRC_DLA_ALGORITHM_HPP_ #include #include -#include "debug.hpp" +#include +#include + #include "array.h" +#include "debug.hpp" #include "io.h" #include "link.hpp" #include "name.h" @@ -58,18 +60,18 @@ class ScatteringChannel; //###################################################################### class SiteInitialConfiguration { -public: + public: int State; int NCH; Array CH; - SiteInitialConfiguration() { CH.setLabel("SiteInitialConfiguration::CH"); }; - int id() { return State; }; + SiteInitialConfiguration() { CH.setLabel("SiteInitialConfiguration::CH"); } + int id() { return State; } void initialize(XML::Block& X); void dump(); }; class SiteProperty { -public: + public: int STYPE; int VTYPE; VertexProperty* _VP; @@ -79,16 +81,16 @@ class SiteProperty { Array IC; SiteProperty() : _VP(0) { IC.setLabel("SiteProperty::IC"); }; - int id() { return STYPE; }; + int id() { return STYPE; } void initialize(XML::Block& X); - void setVertexProperty(VertexProperty& VP) { _VP = &VP; }; - VertexProperty& getVertexProperty() { return *_VP; }; + void setVertexProperty(VertexProperty& VP) { _VP = &VP; } + VertexProperty& getVertexProperty() { return *_VP; } SiteInitialConfiguration& getInitialConfiguration(int x) { return IC[x]; } void dump(); }; class ScatteringChannel { -public: + public: int OUT; int XOUT; double PROB; @@ -98,7 +100,7 @@ class ScatteringChannel { }; class InteractionProperty { -public: + public: int ITYPE; int VTYPE; int NBODY; @@ -116,20 +118,19 @@ class InteractionProperty { AverageInterval.setLabel("InteractionProperty::AverageInterval"); }; - void setVertexProperty(VertexProperty& vp) { _VP = &vp; }; - VertexProperty& getVertexProperty() { return *_VP; }; + void setVertexProperty(VertexProperty& vp) { _VP = &vp; } + VertexProperty& getVertexProperty() { return *_VP; } - double sign(int *x) {return Sign(x);} - double sign(std::vector const& x) {return Sign(x);} + double sign(int* x) { return Sign(x); } + double sign(std::vector const& x) { return Sign(x); } - int id() { return ITYPE; }; + int id() { return ITYPE; } void initialize(XML::Block& X); void dump(); }; class VertexProperty { -private: -public: + public: int VTYPE; int VCAT; int NBODY; @@ -151,22 +152,21 @@ class VertexProperty { _IC.setLabel("VertexProperty::_IC"); StateCode.setLabel("VertexProperty::StateCode"); SCNK.setLabel("VertexProperty::StateCode4NON-KINK"); - }; + } - int id() { return VTYPE; }; + int id() { return VTYPE; } void initialize(XML::Block& X, int i); int getSiteType(int out); - bool isTerminal() { return VCAT == VCAT::TERM; }; + bool isTerminal() { return VCAT == VCAT::TERM; } VertexInitialConfiguration& getIC(int st, int inc, int xinc); void dump(); }; class VertexInitialConfiguration { -private: -public: + public: int ID; Array CH; @@ -174,11 +174,11 @@ class VertexInitialConfiguration { VertexInitialConfiguration() : State(0) { ID = -1; CH.setLabel("VertexInitialConfiguration::CH"); - }; + } ~VertexInitialConfiguration() { if (State != 0) delete[] State; - }; + } int NLEG; int* State; @@ -186,10 +186,10 @@ class VertexInitialConfiguration { int XINC; int NCH; - int MCH; // max of NCH + int MCH; // max of NCH double dRHO; // [vertex density] * [1-p1] - void setID(int i) { ID = i; }; - int id() { return ID; }; + void setID(int i) { ID = i; } + int id() { return ID; } void initialize(XML::Block& X); void initialize(); @@ -199,21 +199,24 @@ class VertexInitialConfiguration { }; class Algorithm { -private: + private: XML::Block X; Array SPROP; Array IPROP; Array VPROP; int ix; -public: + + public: double getBlock(const std::string& s, double i) { return X["General"][s].getDouble(); } - int getBlock(const std::string& s, int i) { return X["General"][s].getInteger(); } + int getBlock(const std::string& s, int i) { + return X["General"][s].getInteger(); + } - Algorithm(std::string const& FNAME); - Algorithm(){} + explicit Algorithm(std::string const& FNAME); + Algorithm() {} ~Algorithm(); int NSTYPE; // Number of site types @@ -221,7 +224,7 @@ class Algorithm { int NVTYPE; // Number of bond types int NXMAX; // Maximum number of segment states - //double WDIAG; // Artifitial weight attached to the diagonal state + // double WDIAG; // Artifitial weight attached to the diagonal state // Used in relating the worm-head mean-path to the susceptibility void read(); @@ -231,18 +234,18 @@ class Algorithm { void set_i(int n) { ix = n; } void set_alg(int n); - SiteProperty& getSiteProperty(int i) { return SPROP[i]; }; //return val[i] - InteractionProperty& getInteractionProperty(int i) { return IPROP[i]; }; - VertexProperty& getVertexProperty(int i) { return VPROP[i]; }; + SiteProperty& getSiteProperty(int i) { return SPROP[i]; } + InteractionProperty& getInteractionProperty(int i) { return IPROP[i]; } + VertexProperty& getVertexProperty(int i) { return VPROP[i]; } - void dump() { X.dump(); }; + void dump() { X.dump(); } }; //###################################################################### //########### Member Functions ####################################### //###################################################################### -inline Algorithm::Algorithm(std::string const & FNAME) { +inline Algorithm::Algorithm(std::string const& FNAME) { AutoDebugDump("Algorithm::Algorithm"); SPROP.setLabel("Algorithm::SPROP"); @@ -252,7 +255,7 @@ inline Algorithm::Algorithm(std::string const & FNAME) { X.initialize(FNAME.c_str()); int ixx = X["General"]["NXMAX"].getInteger(); - MXNIC1 = 24 * (ixx - 1) * (ixx - 1); + MXNIC1 = 24 * (ixx - 1) * (ixx - 1); read(); initialize(); @@ -277,41 +280,42 @@ void Algorithm::set_alg(int ix) { void Algorithm::read() { AutoDebugDump("Algorithm::read"); - NSTYPE = X["General"]["NSTYPE"].getInteger(); //1 []operator - NITYPE = X["General"]["NITYPE"].getInteger(); //1 - NVTYPE = X["General"]["NVTYPE"].getInteger(); //2 - NXMAX = X["General"]["NXMAX"].getInteger(); //2 + NSTYPE = X["General"]["NSTYPE"].getInteger(); // 1 []operator + NITYPE = X["General"]["NITYPE"].getInteger(); // 1 + NVTYPE = X["General"]["NVTYPE"].getInteger(); // 2 + NXMAX = X["General"]["NXMAX"].getInteger(); // 2 // WDIAG = X["General"]["WDIAG" ].getDouble(); // 0.25 - SPROP.init(1, NSTYPE); //1,SiteProperty - IPROP.init(1, NITYPE); //1,InteractionProperty - VPROP.init(1, NVTYPE); //2,VertexProperty + SPROP.init(1, NSTYPE); // 1,SiteProperty + IPROP.init(1, NITYPE); // 1,InteractionProperty + VPROP.init(1, NVTYPE); // 2,VertexProperty - for (int i = 0; i < NITYPE; i++) { //1 IPROP(i) : return val[i] + for (int i = 0; i < NITYPE; i++) { // 1 IPROP(i) : return val[i] IPROP(i).NXMAX = NXMAX; } - for (int i = 0; i < NVTYPE; i++) { //2 + for (int i = 0; i < NVTYPE; i++) { // 2 VPROP(i).NXMAX = NXMAX; } - for (int i = 0; i < X.NumberOfBlocks(); i++) { //X.numberofblocks=6 - XML::Block& B = X[i]; + for (int i = 0; i < X.NumberOfBlocks(); i++) { // X.numberofblocks=6 + XML::Block& B = X[i]; const std::string& name = B.getName(); if (name == "Site") { - int id = B["STYPE"].getInteger(); //id=0 - SPROP(id).initialize(B); // SitePropertyClass setting is finished at this point - //SPROP(0) returns SiteProperty& val[0] + int id = B["STYPE"].getInteger(); // id=0 + SPROP(id).initialize( + B); // SitePropertyClass setting is finished at this point + // SPROP(0) returns SiteProperty& val[0] } if (name == "Interaction") { - int id = B["ITYPE"].getInteger(); //id=0 + int id = B["ITYPE"].getInteger(); // id=0 IPROP(id).initialize(B); } if (name == "Vertex") { - int id = B["VTYPE"].getInteger(); //id=0,1 + int id = B["VTYPE"].getInteger(); // id=0,1 VPROP(id).initialize(B, MXNIC1); } } @@ -321,25 +325,24 @@ void Algorithm::initialize() { AutoDebugDump("Algorithm::initialize"); // Site::_VP - for (int i = 0; i < NSTYPE; i++) { //1 - int vt = SPROP(i).VTYPE; //2 - SPROP(i).setVertexProperty(VPROP(vt)); //VPROP(vt) {return val} - + for (int i = 0; i < NSTYPE; i++) { // 1 + int vt = SPROP(i).VTYPE; // 2 + SPROP(i).setVertexProperty(VPROP(vt)); // VPROP(vt) {return val} } // scattering prob - for (int i = 0; i < NSTYPE; i++) { //1 + for (int i = 0; i < NSTYPE; i++) { // 1 SiteProperty& SP = SPROP(i); - for (int j = 0; j < SP.NIC; j++) { //NIC=NX=Numberofstates 2 - SiteInitialConfiguration& IC = SP.IC[j]; //[]operator return val[i] - double p = 0.0; + for (int j = 0; j < SP.NIC; j++) { // NIC=NX=Numberofstates 2 + SiteInitialConfiguration& IC = SP.IC[j]; // operator return val[i] + double p = 0.0; - for (int k = 0; k < IC.NCH; k++) { //numberofchannnels + for (int k = 0; k < IC.NCH; k++) { // numberofchannnels ScatteringChannel& SC = IC.CH[k]; p += SC.PROB; SC.PROB = p; } - if (fabs(p - 1.0) > EPS) { //EPS=1.d-14 + if (fabs(p - 1.0) > EPS) { // EPS=1.d-14 printf("Algorithm::initialize> Error.\n"); printf(" The sum of probabilities is not equal to 1.\n"); SP.dump(); @@ -352,7 +355,7 @@ void Algorithm::initialize() { // Sitetype of vertices for (int i = 0; i < NSTYPE; i++) { - SiteProperty& S = SPROP(i); + SiteProperty& S = SPROP(i); VertexProperty& V = VPROP(S.VTYPE); int NLEG = 2; @@ -362,8 +365,8 @@ void Algorithm::initialize() { } for (int i = 0; i < NITYPE; i++) { InteractionProperty& I = IPROP(i); - VertexProperty& V = VPROP(I.VTYPE); - int NLEG = 2 * I.NBODY; + VertexProperty& V = VPROP(I.VTYPE); + int NLEG = 2 * I.NBODY; for (int l = 0; l < NLEG; l++) { V.STYPE[l] = I.STYPE[l / 2]; } @@ -379,13 +382,13 @@ void Algorithm::initialize() { for (int ic = 0; ic < VP.NIC; ic++) { VertexInitialConfiguration& IC = VP.IC[ic]; - int nl = VP.NLEG; - int* x = IC.State; - int inc = IC.INC; + int nl = VP.NLEG; + int* x = IC.State; + int inc = IC.INC; int xinc = IC.XINC; int st; bool isKink = false; - std::vector xx(nl/2); + std::vector xx(nl / 2); for (int il = 0; il < nl; il += 2) { if (x[il] != x[il + 1]) @@ -394,9 +397,9 @@ void Algorithm::initialize() { xx[il / 2] = x[il]; } - if (VP.StateCode(x) == STATE::UNDEF) { //operator return val(ID(x)) + if (VP.StateCode(x) == STATE::UNDEF) { // operator return val(ID(x)) VP.StateCode(x) = nst; - st = nst; + st = nst; if (!isKink) VP.SCNK(xx) = nst; nst++; } else { @@ -404,7 +407,7 @@ void Algorithm::initialize() { } VP._IC(st, inc, xinc) = &IC; // generate INDEX using st,inc,xinc - } //end VP.NICloop + } // end VP.NICloop } // _VP of InteractionProperty @@ -424,19 +427,22 @@ void Algorithm::initialize() { bool isKink = false; std::vector x(VP.NBODY); for (int ileg = 0; ileg < IC.NLEG; ileg += 2) { - if (IC.State[ileg] != IC.State[ileg + 1]) { isKink = true; } + if (IC.State[ileg] != IC.State[ileg + 1]) { + isKink = true; + } x[ileg / 2] = IC.State[ileg]; } double p = 0.0; bool isVertex = false; // false: kink or term , true: means interaction - int i_type = 0; + int i_type = 0; for (i_type = 0; i_type < NITYPE; i_type++) { if (IPROP[i_type].VTYPE == i) { isVertex = true; break; } - } // If VTYPE is for Vertex (not for term or tail), there should be InteractionProperty with density of vertex. + } // If VTYPE is for Vertex (not for term or tail), there should be + // InteractionProperty with density of vertex. if (isKink || (!isVertex)) { // printf("i=%d j=%d iskink \n",i,j); @@ -449,8 +455,8 @@ void Algorithm::initialize() { } else { double Vdensity = IPROP[i_type].VertexDensity(x); - int count_ch = 0; - double dR = Vdensity; + int count_ch = 0; + double dR = Vdensity; // printf("i=%d j=%d dR=%f \n",i,j,dR); for (int k = 0; k < IC.NCH; k++) { @@ -459,13 +465,13 @@ void Algorithm::initialize() { dR = (1.0 - SC.PROB) * Vdensity; } else { p += (SC.PROB * Vdensity); - IC.CH[count_ch] = SC; + IC.CH[count_ch] = SC; IC.CH[count_ch].PROB = p; count_ch++; } } IC.dRHO = dR; - IC.NCH = count_ch; + IC.NCH = count_ch; } if (fabs(p - IC.dRHO) > EPS * 10.0) { printf("Algorithm::initialize> Error.\n"); @@ -484,22 +490,20 @@ void Algorithm::initialize() { } } +inline Algorithm::~Algorithm() {} -inline Algorithm::~Algorithm() { -} - -void SiteProperty::initialize(XML::Block& X) { // +void SiteProperty::initialize(XML::Block& X) { // AutoDebugDump("SiteProperty::initialize"); STYPE = X["STYPE"].getInteger(); - NX = X["NumberOfStates"].getInteger(); + NX = X["NumberOfStates"].getInteger(); VTYPE = X["VertexTypeOfSource"].getInteger(); - NIC = NX; + NIC = NX; IC.init(1, NIC); XVALS.resize(NX); - for (int i=0; i\n"); } - void SiteInitialConfiguration::initialize(XML::Block& X) { AutoDebugDump("SiteInitialConfiguration::initialize"); State = X["State"].getInteger(); - NCH = X["NumberOfChannels"].getInteger(); + NCH = X["NumberOfChannels"].getInteger(); CH.init("SCH", 1, NCH); int ch = 0; @@ -552,14 +554,12 @@ void SiteInitialConfiguration::dump() { printf("\n"); printf(" State= %d\n", State); printf(" NCH= %d\n", NCH); - for (int i = 0; i < NCH; i++) - CH[i].dump(); + for (int i = 0; i < NCH; i++) CH[i].dump(); printf("\n"); } - void ScatteringChannel::initialize(XML::Block& X) { - OUT = X.getInteger(0); + OUT = X.getInteger(0); XOUT = X.getInteger(1); PROB = X.getDouble(2); } @@ -573,7 +573,6 @@ void ScatteringChannel::dump() { printf("\n"); } - void InteractionProperty::initialize(XML::Block& X) { AutoDebugDump("InteractionProperty::initialize"); ITYPE = X["ITYPE"].getInteger(); @@ -586,7 +585,7 @@ void InteractionProperty::initialize(XML::Block& X) { VertexDensity.set_all(0.0); AverageInterval.init(NBODY, NXMAX, ARRAY::EOL); AverageInterval.set_all(-1.0); - Sign.init(2*NBODY, NXMAX, ARRAY::EOL); + Sign.init(2 * NBODY, NXMAX, ARRAY::EOL); Sign.set_all(1.0); for (int i = 0; i < X.NumberOfBlocks(); i++) { @@ -603,11 +602,11 @@ void InteractionProperty::initialize(XML::Block& X) { AverageInterval(x) = 1.0 / d; } if (B.getName() == "Sign") { - std::vector x(2*NBODY); - for (int ii = 0; ii < 2*NBODY; ii++) { + std::vector x(2 * NBODY); + for (int ii = 0; ii < 2 * NBODY; ii++) { x[ii] = B.getInteger(ii); } - double sgn = B.getDouble(2*NBODY); + double sgn = B.getDouble(2 * NBODY); Sign(x) = sgn; } } @@ -631,21 +630,18 @@ inline void InteractionProperty::dump() { for (int j = 0; j < I.dimension(); j++) { printf(" %1d", x[j]); } - printf(") --> %8.3f, %8.3f\n", VertexDensity(x), - AverageInterval(x)); + printf(") --> %8.3f, %8.3f\n", VertexDensity(x), AverageInterval(x)); } printf("\n"); } - - void VertexProperty::initialize(XML::Block& X, int mx) { AutoDebugDump("VertexProperty::initialize"); VTYPE = X["VTYPE"].getInteger(); - VCAT = X["VCATEGORY"].getInteger(); + VCAT = X["VCATEGORY"].getInteger(); NBODY = X["NBODY"].getInteger(); - NIC = X["NumberOfInitialConfigurations"].getInteger(); - NLEG = 2 * NBODY; + NIC = X["NumberOfInitialConfigurations"].getInteger(); + NLEG = 2 * NBODY; STYPE.init(1, NLEG); STYPE.set_all(STYPE::UNDEF); @@ -691,7 +687,6 @@ void VertexProperty::initialize(XML::Block& X, int mx) { } } - inline int VertexProperty::getSiteType(int out) { #ifdef DEB if (out < 0 || out >= NLEG) { @@ -704,8 +699,6 @@ inline int VertexProperty::getSiteType(int out) { return STYPE[out]; } - - inline VertexInitialConfiguration& VertexProperty::getIC(int st, int inc, int xinc) { return *_IC(st, inc, xinc); @@ -722,8 +715,7 @@ void VertexProperty::dump() { printf(" NIC = %d\n", NIC); printf(" NXMAX = %d\n", NXMAX); printf(" STYPE = "); - for (int i = 0; i < NLEG; i++) - printf(" %d", STYPE[i]); + for (int i = 0; i < NLEG; i++) printf(" %d", STYPE[i]); printf("\n"); std::vector x(NLEG); IndexSystem& I = StateCode.index_system(); @@ -738,7 +730,7 @@ void VertexProperty::dump() { } IndexSystem& I2 = SCNK.index_system(); for (int i = 0; i < I2.size(); i++) { - I2.coord(i,&(x[0])); + I2.coord(i, &(x[0])); int sc = SCNK[i]; printf(" StateCode4NON-KINK"); for (int j = 0; j < I2.dimension(); j++) { @@ -756,12 +748,11 @@ void VertexProperty::dump() { printf(" (_IC[%1d][%1d][%1d])->id() = %d\n", y[0], y[1], y[2], icc); } } - for (int i = 0; i < NIC; i++) - IC[i].dump(); + for (int i = 0; i < NIC; i++) IC[i].dump(); printf("\n"); } -void VertexInitialConfiguration::initialize(XML::Block& X) { // +void VertexInitialConfiguration::initialize(XML::Block& X) { // AutoDebugDump("VertexInitialConfiguration::initialize"); if (NLEG == 0) { @@ -775,9 +766,9 @@ void VertexInitialConfiguration::initialize(XML::Block& X) { // State[i] = X["State"].getInteger(i); } - INC = X["IncomingDirection"].getInteger(); + INC = X["IncomingDirection"].getInteger(); XINC = X["NewState"].getInteger(); - NCH = X["NumberOfChannels"].getInteger(); + NCH = X["NumberOfChannels"].getInteger(); MCH = 4; CH.init("VCH", 1, MCH); @@ -795,8 +786,7 @@ void VertexInitialConfiguration::initialize(XML::Block& X) { // } } - -void VertexInitialConfiguration::initialize() { // +void VertexInitialConfiguration::initialize() { // AutoDebugDump("VertexInitialConfiguration::initialize"); if (NLEG == 0) { @@ -807,11 +797,10 @@ void VertexInitialConfiguration::initialize() { // State = new int[NLEG]; - NCH = 4; //X["NumberOfChannels"].getInteger(); + NCH = 4; // X["NumberOfChannels"].getInteger(); CH.init("VCH", 1, NCH); } - inline ScatteringChannel& VertexInitialConfiguration::getScatteringChannel() { double p; if (NCH == 1) return CH[0]; @@ -850,7 +839,6 @@ inline ScatteringChannel& VertexInitialConfiguration::getScatteringChannel( return CH[ch]; } - void VertexInitialConfiguration::dump() { AutoDebugDump("VertexInitialConfiguration::dump"); printf("\n"); @@ -862,12 +850,10 @@ void VertexInitialConfiguration::dump() { printf(", dRHO= %f", dRHO); printf(", X= ("); - for (int i = 0; i < NLEG; i++) - printf(" %1d", State[i]); + for (int i = 0; i < NLEG; i++) printf(" %1d", State[i]); printf(")\n"); - for (int i = 0; i < NCH; i++) - CH[i].dump(); + for (int i = 0; i < NCH; i++) CH[i].dump(); printf("\n"); } -#endif +#endif // SRC_DLA_ALGORITHM_HPP_ diff --git a/src/dla/calctimer.hpp b/src/dla/calctimer.hpp index a39bc123..a8b3dfbd 100644 --- a/src/dla/calctimer.hpp +++ b/src/dla/calctimer.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef CALCTIMER_HPP -#define CALCTIMER_HPP +#ifndef SRC_DLA_CALCTIMER_HPP_ +#define SRC_DLA_CALCTIMER_HPP_ #include "../common/timer.hpp" #include "accumulator.hpp" @@ -27,7 +27,7 @@ class CalcTimer { Accumulator PHY; public: - CalcTimer(int nmcs) : NMCS(nmcs) { PHY.reset("time"); } + explicit CalcTimer(int nmcs) : NMCS(nmcs) { PHY.reset("time"); } void reset_timer() { timer.reset(); } void setinit() { ACC.reset("time"); } void measure() { ACC.accumulate(timer.elapsed() / NMCS); } @@ -50,4 +50,4 @@ class CalcTimer { } }; -#endif // TIMER_HPP +#endif // SRC_DLA_CALCTIMER_HPP_ diff --git a/src/dla/cf.hpp b/src/dla/cf.hpp index 1d2ab79b..558b64d7 100644 --- a/src/dla/cf.hpp +++ b/src/dla/cf.hpp @@ -14,13 +14,14 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef CF_H -#define CF_H +#ifndef SRC_DLA_CF_HPP_ +#define SRC_DLA_CF_HPP_ #include #include #include #include +#include #include "accumulator.hpp" #include "algorithm.hpp" @@ -93,7 +94,7 @@ CF::CF(Parameter const& param, Lattice& lat, Algorithm& alg, Displacement& disp) counter.push_back(std::vector(Ntau)); } } -}; +} inline void CF::setinit() { if (!to_be_calc) { @@ -116,7 +117,7 @@ inline void CF::show(FILE* F) { } std::fprintf(F, "\n"); } -}; +} inline void CF::accumulate(int NCYC, double sgn) { if (!to_be_calc) { @@ -128,7 +129,7 @@ inline void CF::accumulate(int NCYC, double sgn) { for (int icf = 0; icf < nkinds; icf++) for (int it = 0; it < Ntau; it++) ACC[icf][it].accumulate(sgn * invNCYC * counter[icf][it]); -}; +} inline void CF::summary() { if (!to_be_calc) { @@ -191,7 +192,7 @@ void CF::setsummary() { AutoDebugDump("CF::setsummary"); const double V = LAT.NSITE; const double testDIAG = ALG.getBlock( - "WDIAG", (double)1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 + "WDIAG", 1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 SIGN.average(); const double sgn = SIGN.mean(); if (sgn != 0.0) { @@ -242,4 +243,4 @@ void CF::load(std::ifstream& F) { Serialize::load(F, PHY); } -#endif // CF_H +#endif // SRC_DLA_CF_HPP_ diff --git a/src/dla/chainjob.hpp b/src/dla/chainjob.hpp index 572549ed..5f60872e 100644 --- a/src/dla/chainjob.hpp +++ b/src/dla/chainjob.hpp @@ -14,14 +14,17 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef CHAINJOB_HPP -#define CHAINJOB_HPP +#ifndef SRC_DLA_CHAINJOB_HPP_ +#define SRC_DLA_CHAINJOB_HPP_ // BINARY FILE -#include #include #include #include +#include +#include + +#include #include "../common/timer.hpp" #include "dla.hpp" @@ -42,9 +45,7 @@ void Simulation::BinaryIO() { isChainjob = true; load(); } -}; - -//----------------------------------------------------------------------------------------- +} void Simulation::save() { using Serialize::save; @@ -87,7 +88,7 @@ void Simulation::save() { } int NVER_ = - P.NVERMAX - TheVertexPool.count() - LAT.NSITE - 1; //-1 means warm's tail + P.NVERMAX - TheVertexPool.count() - LAT.NSITE - 1; // -1 means warm's tail save(cjobout, NVER_); int NVER_count = 0; for (int interaction_ = 0; interaction_ < LAT.NINT; interaction_++) { @@ -156,7 +157,7 @@ void Simulation::save() { ck.save(cjobout); cjobout.close(); -}; +} void Simulation::load() { using Serialize::load; @@ -248,7 +249,7 @@ void Simulation::load() { int NLEG_ = load(cjobin); if (VPID_ == VTYPE::UNDEF) { std::cout << "NLEG_" << NLEG_ << std::endl; - }; + } for (int leg = 0; leg < NLEG_; leg++) { int SID_ = load(cjobin); Segment *findingS = (oldID_S.find(SID_))->second; @@ -317,8 +318,8 @@ void Simulation::load() { oldID_V.clear(); oldID_S.clear(); newID2V.clear(); -}; -//----------------------------------------------------------------------------------------- +} + void Simulation::end_cjob() { cjobout.close(); cjobout.open(CJOBFILE.c_str(), std::ios::out | std::ios::binary); // reset @@ -326,8 +327,8 @@ void Simulation::end_cjob() { cjobout.close(); std::cout << "Save checkpoint file and stop the simulation." << std::endl; end_job(); -}; -//----------------------------------------------------------------------------------------- +} + void Simulation::end_job() { std::cout << cjob_timer.elapsed() << " seconds have passed." << std::endl; @@ -336,6 +337,6 @@ void Simulation::end_job() { MPI_Finalize(); #endif exit(0); -}; +} -#endif // CHAINJOB_HPP +#endif // SRC_DLA_CHAINJOB_HPP_ diff --git a/src/dla/ck.hpp b/src/dla/ck.hpp index fd27d588..1a1c7077 100644 --- a/src/dla/ck.hpp +++ b/src/dla/ck.hpp @@ -14,12 +14,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef CK_H -#define CK_H +#ifndef SRC_DLA_CK_HPP_ +#define SRC_DLA_CK_HPP_ #include #include #include +#include #include "accumulator.hpp" #include "algorithm.hpp" @@ -89,7 +90,7 @@ CK::CK(Parameter const& param, Lattice& lat, Algorithm& alg, WaveVector& wv) counterC.push_back(std::vector(Ntau)); } } -}; +} inline void CK::setinit() { if (!to_be_calc) { @@ -112,7 +113,7 @@ inline void CK::show(FILE* F) { } fprintf(F, "\n"); } -}; +} inline void CK::accumulate(int NCYC, double sgn) { if (!to_be_calc) { @@ -125,7 +126,7 @@ inline void CK::accumulate(int NCYC, double sgn) { for (int ik = 0; ik < NK; ik++) for (int it = 0; it < Ntau; it++) ACC[ik][it].accumulate(sgn * invNCYC * counterC[ik][it]); -}; +} inline void CK::summary() { if (!to_be_calc) { @@ -168,7 +169,7 @@ void CK::count(int s, double tT, double bT, double tail_tau) { } } } -}; +} void CK::reset() { if (!to_be_calc) { @@ -181,7 +182,7 @@ void CK::reset() { // counterS[ik][it] = 0.0; } } -}; +} void CK::setsummary() { if (!to_be_calc) { return; @@ -190,7 +191,7 @@ void CK::setsummary() { const double factor = 2 * ALG.getBlock( "WDIAG", - (double)1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 + 1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 SIGN.average(); const double sgn = SIGN.mean(); if (sgn != 0.0) { @@ -240,4 +241,4 @@ void CK::load(std::ifstream& F) { Serialize::load(F, PHY); } -#endif // CK_H +#endif // SRC_DLA_CK_HPP_ diff --git a/src/dla/debug.hpp b/src/dla/debug.hpp index ae8229d6..6474522d 100644 --- a/src/dla/debug.hpp +++ b/src/dla/debug.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef DEBUG_H -#define DEBUG_H +#ifndef SRC_DLA_DEBUG_HPP_ +#define SRC_DLA_DEBUG_HPP_ #ifdef DEB #include @@ -52,4 +52,4 @@ class AutoDebugDump_impl { #endif // DEB -#endif // DEBUG_H +#endif // SRC_DLA_DEBUG_HPP_ diff --git a/src/dla/displacement.hpp b/src/dla/displacement.hpp index 73971eb3..1c474dec 100644 --- a/src/dla/displacement.hpp +++ b/src/dla/displacement.hpp @@ -14,13 +14,14 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef DISPLACEMENT_H -#define DISPLACEMENT_H +#ifndef SRC_DLA_DISPLACEMENT_HPP_ +#define SRC_DLA_DISPLACEMENT_HPP_ #include #include #include #include +#include #include "accumulator.hpp" #include "debug.hpp" @@ -35,7 +36,7 @@ struct Displacement { std::vector NR; // the number of pairs with the same dR std::vector > IR; // IR[isite][jsite] == disp_index - Displacement(Parameter const& param); + explicit Displacement(Parameter const& param); void read(XML::Block const& X); }; @@ -66,6 +67,6 @@ Displacement::Displacement(Parameter const& param) } } } -}; +} -#endif // DISPLACEMENT_H +#endif // SRC_DLA_DISPLACEMENT_HPP_ diff --git a/src/dla/dla.cc b/src/dla/dla.cc index 393d6a03..3e125d89 100644 --- a/src/dla/dla.cc +++ b/src/dla/dla.cc @@ -1,3 +1,19 @@ +// DSQSS (Discrete Space Quantum Systems Solver) +// Copyright (C) 2018- The University of Tokyo +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + //###################################################################### //#### //#### World-Line Monte Carlo simulation @@ -16,32 +32,17 @@ //#### //###################################################################### -// DSQSS (Discrete Space Quantum Systems Solver) -// Copyright (C) 2018- The University of Tokyo -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#include "dla.hpp" - #include #include +#include #include "../common/version.h" #include "chainjob.hpp" #include "debug.hpp" #include "util.hpp" +#include "dla.hpp" + //###################################################################### int main(int argc, char* argv[]) { @@ -236,7 +237,7 @@ void Simulation::set_NCYC() { } ncycSAMP[IMCSE % NSAMP] = ncyc; - }; + } int ncycSUM = 0; for (int isamp = 0; isamp < NSAMP; isamp++) { @@ -311,14 +312,14 @@ void Simulation::Sweep(bool thermalized) { for (ICYC = 0; ICYC < P.NCYC; ICYC++) { len += Cycle(thermalized); } - AMP = len / (double)P.NCYC; -}; + AMP = len / P.NCYC; +} double Simulation::Cycle(bool thermalized) { AutoDebugDump("Simulation::Cycle"); if (!PlaceWorm()) return 0.0; return MoveHead(thermalized); -}; +} /* * Try to place a pair of wormheads uniform randomly @@ -409,7 +410,7 @@ double Simulation::MoveHead(bool thermalized) { W.remove(); return len; -}; +} double Simulation::UP_ONESTEP(bool thermalized) { AutoDebugDump("Simulation::UP_ONESTEP"); @@ -613,7 +614,7 @@ double Simulation::UP_ONESTEP(bool thermalized) { RegVInfo& DRVI = RingRVI.first(); DRVI.remove(); TheRVIPool.push(DRVI); - }; + } if (thermalized) { const int head_site = c_Site.id() - 1; @@ -827,7 +828,7 @@ double Simulation::DOWN_ONESTEP(bool thermalized) { RegVInfo& DRVI = RingRVI.first(); DRVI.remove(); TheRVIPool.push(DRVI); - }; + } if (thermalized) { const int head_site = c_Site.id() - 1; diff --git a/src/dla/io.h b/src/dla/io.h index c11c74d1..165e2219 100644 --- a/src/dla/io.h +++ b/src/dla/io.h @@ -1,10 +1,8 @@ - -#ifndef IO_H -#define IO_H +#ifndef SRC_DLA_IO_H_ +#define SRC_DLA_IO_H_ //###################################################################### -#include #include #include #include @@ -14,17 +12,15 @@ #include #include +#include + #include "../common/tostring.h" #include "array.h" #include "util.hpp" #define BLEN 256 -//###################################################################### - -std::string EOL = "_E_O_L_"; - -//====================================================================== +static const char EOL[] = "_E_O_L_"; inline void reform_end_of_line(std::string& line) { int n = line.size(); @@ -34,20 +30,15 @@ inline void reform_end_of_line(std::string& line) { } } -//====================================================================== - inline int line_split(char* line, std::string* w) { std::string s(line); std::istringstream ist(s); int nw = 0; - while (ist >> w[nw++]) - ; + while (ist >> w[nw++]){;} nw--; return nw; } -//====================================================================== - inline void get_line(FILE* F, char* line) { char buff[256]; strcpy(buff, ""); @@ -66,8 +57,6 @@ inline void get_line(FILE* F, char* line) { } } -//====================================================================== - inline void get_nbl(FILE* F, char* line) { // get the next non-blank line strcpy(line, ""); while (!strcmp(line, "")) { @@ -77,8 +66,6 @@ inline void get_nbl(FILE* F, char* line) { // get the next non-blank line } } -//====================================================================== - inline int break_into_words(char* line, char* delim, char** word) { char* last = line + strlen(line) - 1; // printf( "line = '%s'\n", line); @@ -100,8 +87,6 @@ inline int break_into_words(char* line, char* delim, char** word) { return n; } -//###################################################################### - class FileReader { private: char NAME[BLEN]; @@ -124,23 +109,23 @@ class FileReader { } top = INS.tellg(); IL = 0; - }; + } - FileReader(){}; + FileReader(){} - FileReader(const char* name) { open(name); }; + FileReader(const char* name) { open(name); } void rewind() { INS.clear(); INS.seekg(top); - }; + } - void set_mark() { mark = INS.tellg(); }; + void set_mark() { mark = INS.tellg(); } void goto_mark() { INS.clear(); INS.seekg(mark); - }; + } bool read() { bool b = static_cast(INS.getline(LINE, BLEN)); @@ -148,14 +133,14 @@ class FileReader { IL++; } return b; - }; + } - char* line() { return LINE; }; + char* line() { return LINE; } int split() { NW = line_split(LINE, WORD); return NW; - }; + } std::string& word(int i) { if (i < 0 && i >= NW) { @@ -164,13 +149,13 @@ class FileReader { throw std::runtime_error(msg); } return WORD[i]; - }; + } - int as_int(int i) { return atoi(WORD[i].c_str()); }; + int as_int(int i) { return atoi(WORD[i].c_str()); } - double as_double(int i) { return (double)atof(WORD[i].c_str()); }; + double as_double(int i) { return (double)atof(WORD[i].c_str()); } - void show() { std::cout << LINE << std::endl; }; + void show() { std::cout << LINE << std::endl; } void dump() { std::cout << NAME << "[" << IL << "]> "; @@ -178,7 +163,7 @@ class FileReader { std::cout << " " << WORD[i]; } std::cout << std::endl; - }; + } std::string get(char* key); @@ -208,8 +193,6 @@ inline void FileReader::getWordList(int& NW, std::string*& W) { W[NW] = EOL; } -//====================================================================== - inline std::string FileReader::get(char* key) { std::string ans; char key_open[BLEN]; @@ -238,8 +221,6 @@ inline std::string FileReader::get(char* key) { return ans; } -//====================================================================== - inline int FileReader::makeIndex(const char* scope, const char* field, const char* k0, Array& index) { // printf("FileReader::makeIndex> start.\n"); @@ -305,4 +286,4 @@ inline int FileReader::makeIndex(const char* scope, const char* field, return n; } -#endif +#endif // SRC_DLA_IO_H_ diff --git a/src/dla/lattice.hpp b/src/dla/lattice.hpp index 1e7ab0d2..ffbe6c6e 100644 --- a/src/dla/lattice.hpp +++ b/src/dla/lattice.hpp @@ -14,24 +14,22 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef LATTICE_H -#define LATTICE_H +#ifndef SRC_DLA_LATTICE_HPP_ +#define SRC_DLA_LATTICE_HPP_ -//###################################################################### - -#include #include #include #include #include +#include + +#include #include "debug.hpp" #include "io.h" #include "objects.hpp" #include "parameter.hpp" -//###################################################################### - class Lattice { public: class Edge { @@ -40,7 +38,7 @@ class Lattice { bd = _d; A = _a; B = _b; - }; + } int A; int B; @@ -95,7 +93,7 @@ class Lattice { } fprintf(F, "\n"); fprintf(F, "P BETA = %24.16f\n", BETA); - }; + } void dump(); }; @@ -166,8 +164,8 @@ void Lattice::read() { int sid = B.getInteger(3 + ii); I(id).setSite(ii, S(sid)); } - //#ifdef WINDING +// #ifdef WINDING if (B.NumberOfValues() > 3 + nb) { if (INIT_I) { NEDGE = X["NumberOfEdgeInteractions"].getInteger(); @@ -181,7 +179,7 @@ void Lattice::read() { EDGE(eid).init(edim, I(id).site(0).id() - 1, I(id).site(1).id() - 1); } } - //#endif +// #endif } if (B.getName() == "Direction") { if (INIT_V) { @@ -205,8 +203,6 @@ void Lattice::read() { if (DEBUG) dump(); } -//====================================================================== -#include void Lattice::initialize() { AutoDebugDump("Lattice::initialize"); @@ -311,4 +307,4 @@ void Lattice::setBeta(double beta) { } } -#endif +#endif // SRC_DLA_LATTICE_HPP_ diff --git a/src/dla/link.hpp b/src/dla/link.hpp index d1a95851..0d0a2c2e 100644 --- a/src/dla/link.hpp +++ b/src/dla/link.hpp @@ -1,6 +1,5 @@ - -#ifndef LINK_H -#define LINK_H +#ifndef SRC_DLA_LINK_HPP_ +#define SRC_DLA_LINK_HPP_ #include @@ -35,19 +34,19 @@ class Linked : public C { C::init(); p = this; n = this; - }; + } - Linked() { init(); }; + Linked() { init(); } - ~Linked(){}; + ~Linked() {} - Linked& prev() { return *p; }; + Linked& prev() { return *p; } - Linked& next() { return *n; }; + Linked& next() { return *n; } - void set_prev(Linked& x) { p = &x; }; + void set_prev(Linked& x) { p = &x; } - void set_next(Linked& x) { n = &x; }; + void set_next(Linked& x) { n = &x; } void insert_after(Linked& x); @@ -76,60 +75,60 @@ class RingIterator { void init(C& x) { org = &x; cur = org; - }; + } void init(Ring& r) { org = &r.root(); cur = org; - }; + } - RingIterator(){}; + RingIterator() {} RingIterator(const RingIterator& p) { org = p.org; cur = p.cur; - }; + } - RingIterator(C& x) { init(x); }; + RingIterator(C& x) { init(x); } - RingIterator(Ring& r) { init(r); }; + RingIterator(Ring& r) { init(r); } - bool atOrigin() { return cur == org; }; + bool atOrigin() { return cur == org; } RingIterator operator+(int i) { RingIterator p; p.org = org; p.cur = &(cur->next()); return p; - }; + } RingIterator& operator++() { cur = &(cur->next()); return *this; - }; + } RingIterator operator++(int) { RingIterator ret(*this); operator++(); return ret; - }; + } RingIterator& operator--() { cur = &(cur->prev()); return *this; - }; + } RingIterator operator--(int) { RingIterator ret(*this); operator--(); return ret; - }; + } - C* operator->() { return cur; }; - C& operator*() { return *cur; }; - void operator=(const C* p) { cur = p; }; - bool operator==(const C* p) { return cur == p; }; - bool operator!=(const C* p) { return cur != p; }; + C* operator->() { return cur; } + C& operator*() { return *cur; } + void operator=(const C* p) { cur = p; } + bool operator==(const C* p) { return cur == p; } + bool operator!=(const C* p) { return cur != p; } }; //###################################################################### @@ -150,40 +149,40 @@ class Ring { // C ROOT; public: C ROOT; - C& head() { return ROOT.next(); }; - C& tail() { return ROOT.prev(); }; + C& head() { return ROOT.next(); } + C& tail() { return ROOT.prev(); } typedef RingIterator iterator; - Ring(){}; + Ring() {} - ~Ring(){}; + ~Ring() {} - bool empty() { return (&(ROOT.next()) == &ROOT); }; + bool empty() { return (&(ROOT.next()) == &ROOT); } - C& root() { return ROOT; }; + C& root() { return ROOT; } - C& first() { return ROOT.next(); }; + C& first() { return ROOT.next(); } - void add_head(C& x) { ROOT.insert_after(x); }; + void add_head(C& x) { ROOT.insert_after(x); } - void add_tail(C& x) { ROOT.insert_before(x); }; + void add_tail(C& x) { ROOT.insert_before(x); } C& remove_head() { C& x = head(); x.remove(); return x; - }; + } C& remove_tail() { C& x = tail(); x.remove(); return x; - }; + } - void push(C& x) { add_head(x); }; + void push(C& x) { add_head(x); } - C& pop() { return remove_head(); }; + C& pop() { return remove_head(); } int count(); @@ -209,7 +208,7 @@ class Pool : public Ring { int size; public: - Pool() : Ring() { size = 0; }; + Pool() : Ring() { size = 0; } ~Pool(); @@ -219,7 +218,7 @@ class Pool : public Ring { size++; x.init(); Ring::push(x); - }; + } C& pop() { if (size == 0) { @@ -232,10 +231,10 @@ class Pool : public Ring { C& x = Ring::pop(); // x.init(); return x; - }; + } - int number_of_used_elements() { return size_max - size_min; }; - void set_n_of_used_elements(int s_used) { size_min = size_max - s_used; }; + int number_of_used_elements() { return size_max - size_min; } + void set_n_of_used_elements(int s_used) { size_min = size_max - s_used; } }; //###################################################################### @@ -359,4 +358,4 @@ inline Pool::~Pool() { } } -#endif +#endif // SRC_DLA_LINK_HPP_ diff --git a/src/dla/measure.hpp b/src/dla/measure.hpp index 25745b36..0dcf5f1a 100644 --- a/src/dla/measure.hpp +++ b/src/dla/measure.hpp @@ -14,11 +14,12 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef MEASURE_H -#define MEASURE_H +#ifndef SRC_DLA_MEASURE_HPP_ +#define SRC_DLA_MEASURE_HPP_ #include #include +#include #include "accumulator.hpp" #include "algorithm.hpp" @@ -338,7 +339,7 @@ void Measurement::measure(double sgn) { MZSB[k] *= T; } - double EBSAMP = -(double)NV; + double EBSAMP = -NV; for (int b = 0; b < LAT.NINT; b++) { Interaction& I = LAT.I(b); @@ -412,9 +413,11 @@ void Measurement::measure(double sgn) { Segment& S = *p; if (xlast != S.X()) { if ((*S.bottom().S(0).getONSITE()).id() - 1 == Bsite) { - wind[dim] += (double)(S.bottom().S(1).X() - S.bottom().S(0).X()); + wind[dim] += + static_cast(S.bottom().S(1).X() - S.bottom().S(0).X()); } else if ((*S.bottom().S(2).getONSITE()).id() - 1 == Bsite) { - wind[dim] += (double)(S.bottom().S(3).X() - S.bottom().S(2).X()); + wind[dim] += + static_cast(S.bottom().S(3).X() - S.bottom().S(2).X()); } xlast = S.X(); } @@ -436,7 +439,7 @@ void Measurement::measure(double sgn) { void Measurement::setsummary() { using namespace Specific; double WDIAG = ALG.getBlock( - "WDIAG", (double)1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 + "WDIAG", 1.0); // ALG.X["General"]["WDIAG" ].getDouble(); // 0.25 std::vector X(NACC); @@ -507,4 +510,4 @@ void Measurement::setsummary() { } } -#endif +#endif // SRC_DLA_MEASURE_HPP_ diff --git a/src/dla/name.h b/src/dla/name.h index a56a38bf..96bf1c17 100644 --- a/src/dla/name.h +++ b/src/dla/name.h @@ -1,49 +1,48 @@ - -#ifndef NAME_H -#define NAME_H +#ifndef SRC_DLA_NAME_H_ +#define SRC_DLA_NAME_H_ namespace STYPE { -int UNDEF = -1; +static const int UNDEF = -1; } namespace HTYPE { -int UNDEF = -1; -int ABSENT = -2; +static const int UNDEF = -1; +static const int ABSENT = -2; } // namespace HTYPE namespace TTYPE { -int UNDEF = -1; +static const int UNDEF = -1; } namespace ITYPE { -int UNDEF = -1; +static const int UNDEF = -1; } namespace VTYPE { -int UNDEF = -1; +static const int UNDEF = -1; } namespace DIR { -int UNDEF = -1; +static const int UNDEF = -1; } namespace STATE { -int UNDEF = -1; +static const int UNDEF = -1; } namespace ICONF { -int UNDEF = -1; +static const int UNDEF = -1; } namespace ICC { -int UNDEF = -1; +static const int UNDEF = -1; } namespace UORD { -int UNDEF = -1; -int UP = 0; -int DOWN = 1; +static const int UNDEF = -1; +static const int UP = 0; +static const int DOWN = 1; } // namespace UORD namespace VCAT { -int UNDEF = -1; -int TERM = 0; -int WORM = 1; -int INT = 2; +static const int UNDEF = -1; +static const int TERM = 0; +static const int WORM = 1; +static const int INT = 2; } // namespace VCAT -const double INF = 1.0e+14; -const double EPS = 1.0e-10; +static const double INF = 1.0e+14; +static const double EPS = 1.0e-10; -#endif +#endif // SRC_DLA_NAME_H_ diff --git a/src/dla/objects.hpp b/src/dla/objects.hpp index 7edd7fea..594aca0f 100644 --- a/src/dla/objects.hpp +++ b/src/dla/objects.hpp @@ -1,5 +1,5 @@ -#ifndef OBJECTS_H -#define OBJECTS_H +#ifndef SRC_DLA_OBJECTS_HPP_ +#define SRC_DLA_OBJECTS_HPP_ //###################################################################### @@ -37,43 +37,43 @@ class BareSegment { _v[0] = 0; _v[1] = 0; ONSITE = 0; - }; + } void set(int x, Vertex& v0, Vertex& v1) { val = x; _v[0] = &v0; _v[1] = &v1; - }; + } BareSegment() : ONSITE(0) { lastID++; IDX = lastID; init(); - }; - - ~BareSegment(){ - // printf("*** Destroying BareSegment\n"); - }; - - int id() const { return IDX; }; - Vertex& V(int i) { return *_v[i]; }; - Vertex& bottom() { return *_v[0]; }; - Vertex& top() { return *_v[1]; }; - void setV(int i, Vertex& v) { _v[i] = &v; }; - void setBottom(Vertex& v) { _v[0] = &v; }; - void setTop(Vertex& v) { _v[1] = &v; }; - int X() { return val; }; - void setX(int x) { val = x; }; + } + + ~BareSegment() { + // printf("*** Destroying BareSegment\n"); + } + + int id() const { return IDX; } + Vertex& V(int i) { return *_v[i]; } + Vertex& bottom() { return *_v[0]; } + Vertex& top() { return *_v[1]; } + void setV(int i, Vertex& v) { _v[i] = &v; } + void setBottom(Vertex& v) { _v[0] = &v; } + void setTop(Vertex& v) { _v[1] = &v; } + int X() { return val; } + void setX(int x) { val = x; } double topTime(); double bottomTime(); double length(); void dump(); bool check(); - void dump_id() { std::cout << IDX << std::endl; }; + void dump_id() { std::cout << IDX << std::endl; } - Site* getONSITE() { return ONSITE; }; - void setONSITE(Site* on_site) { ONSITE = on_site; }; + Site* getONSITE() { return ONSITE; } + void setONSITE(Site* on_site) { ONSITE = on_site; } }; int BareSegment::lastID = 0; @@ -85,9 +85,9 @@ class Segment : public Linked { Segment& cut(Vertex& V, int side); void erase(); void absorbNext(); - Segment& prev() { return (Segment&)Linked::prev(); }; - Segment& next() { return (Segment&)Linked::next(); }; - bool operator==(Segment& s) { return this == &s; }; + Segment& prev() { return (Segment&)Linked::prev(); } + Segment& next() { return (Segment&)Linked::next(); } + bool operator==(Segment& s) { return this == &s; } }; //###################################################################### @@ -106,7 +106,7 @@ class BareVertex { _VP = 0; TIME = -1.0; _s.init(); - }; + } void init_WORM(); @@ -118,7 +118,7 @@ class BareVertex { _s.init(1, VP.NLEG); // koko !!! _s.set_all(0); _VP = &VP; - }; + } void init(Interaction* O_I, double t, VertexProperty& VP) { TIME = t; @@ -126,32 +126,32 @@ class BareVertex { _s.set_all(0); _VP = &VP; ONINTERACTION = O_I; - }; + } BareVertex() { _s.setLabel("BareVertex::_s"); lastID++; ID = lastID; ONINTERACTION = 0; init(); - }; + } - ~BareVertex(){ - // printf("*** Destroying BareVertex (%d)\n", this); - }; + ~BareVertex() { + // printf("*** Destroying BareVertex (%d)\n", this); + } int NBODY() const { if (isTerminal()) return 1; return (*_VP).NBODY; - }; + } - int NLEG() const { return 2 * NBODY(); }; + int NLEG() const { return 2 * NBODY(); } bool isTerminal() const; bool isTail() const; - int id() const { return ID; }; + int id() const { return ID; } - int size() const { return 2 * NBODY(); }; + int size() const { return 2 * NBODY(); } bool isKink(); @@ -163,15 +163,15 @@ class BareVertex { } #endif return *_s[i]; - }; + } - void setS(int dir, Segment& s) { _s[dir] = &s; }; + void setS(int dir, Segment& s) { _s[dir] = &s; } int X(int i); - double time() const { return TIME; }; + double time() const { return TIME; } - void setTime(double t) { TIME = t; }; + void setTime(double t) { TIME = t; } int which(Segment& s); @@ -179,7 +179,7 @@ class BareVertex { bool check(); - void setProperty(VertexProperty& P) { _VP = &P; }; + void setProperty(VertexProperty& P) { _VP = &P; } int type() { if (_VP == 0) { @@ -206,15 +206,15 @@ class BareVertex { } #endif return *_VP; - }; + } VertexInitialConfiguration& getInitialConfiguration(int inc, int xinc); void dump(); - Interaction* getONINTERACTION() { return ONINTERACTION; }; + Interaction* getONINTERACTION() { return ONINTERACTION; } void setONINTERACTION(Interaction* on_interaction) { ONINTERACTION = on_interaction; - }; + } }; int BareVertex::lastID = 0; @@ -225,9 +225,9 @@ class Vertex : public Linked { public: void reconnect(); // reconnect the segments attached to the vertex void erase(); // remove from the linked list and push back to the pool - Vertex& prev() { return (Vertex&)Linked::prev(); }; - Vertex& next() { return (Vertex&)Linked::next(); }; - bool operator==(Vertex& v) { return this == &v; }; + Vertex& prev() { return (Vertex&)Linked::prev(); } + Vertex& next() { return (Vertex&)Linked::next(); } + bool operator==(Vertex& v) { return this == &v; } }; //###################################################################### @@ -248,21 +248,21 @@ class Worm { Vertex* _v = &(_scur->bottom()); if (_v == _vcur) _v = &(_scur->top()); return *_v; - }; + } - Vertex& origin() { return *_vorg; }; + Vertex& origin() { return *_vorg; } - Vertex& getCurrentVertex() { return *_vcur; }; + Vertex& getCurrentVertex() { return *_vcur; } - void setCurrentVertex(Vertex& v) { _vcur = &v; }; + void setCurrentVertex(Vertex& v) { _vcur = &v; } - Segment& getCurrentSegment() { return *_scur; }; + Segment& getCurrentSegment() { return *_scur; } - void setCurrentSegment(Segment& s) { _scur = &s; }; + void setCurrentSegment(Segment& s) { _scur = &s; } - void setXBEHIND() { x_behind = STATE::UNDEF; }; + void setXBEHIND() { x_behind = STATE::UNDEF; } - void setXBEHIND(int x) { x_behind = x; }; + void setXBEHIND(int x) { x_behind = x; } int getXBEHIND() { #ifdef DEB @@ -272,16 +272,16 @@ class Worm { } #endif return x_behind; - }; + } - bool atOrigin() { return (_vcur == _vorg); }; + bool atOrigin() { return (_vcur == _vorg); } bool getUORD() { return (_vcur == &((*_scur).top())); - }; // up -> false 0, down -> true 1 + } // up -> false 0, down -> true 1 void getV() { printf("top,bottom = %d, %d ", (*_scur).top().id(), (*_scur).bottom().id()); - }; + } void remove(); @@ -300,6 +300,7 @@ class Site : public Ring { int NCI; // the number of connected interactions Interaction** ConnectedInteraction; // Interaction* ConnectedInteraction [ NCI ]; + public: void setNCI(int ni) { NCI = ni; @@ -315,19 +316,19 @@ class Site : public Ring { ~Site(); - int id() { return ID; }; + int id() { return ID; } int type() { if (_SP == 0) return STYPE::UNDEF; return (*_SP).STYPE; - }; + } - void setProperty(SiteProperty& sp) { _SP = &sp; }; + void setProperty(SiteProperty& sp) { _SP = &sp; } - SiteProperty& Property() { return *_SP; }; + SiteProperty& Property() { return *_SP; } double getBeta() const { return _vterm->time(); } - void setBeta(double b) { _vterm->setTime(b); }; + void setBeta(double b) { _vterm->setTime(b); } Segment& findS(double t); @@ -338,12 +339,12 @@ class Site : public Ring { printf("Site(%2d) type= %d | ", id(), type()); Ring::dump(); printf("\n"); - }; + } - void idclear() { lastID = 0; }; + void idclear() { lastID = 0; } // void idclear() { cout << "dddd " << endl; }; - Vertex& getVterm() { return (*_vterm); }; + Vertex& getVterm() { return (*_vterm); } }; int Site::lastID = 0; @@ -363,25 +364,25 @@ class Interaction : public Ring { if (_s != 0) { delete[] _s; } - }; + } void init(InteractionProperty& IP) { init(); _IP = &IP; _s = new Site*[(*_IP).NBODY]; - }; + } Interaction(); ~Interaction(); - int id() { return ID; }; + int id() { return ID; } - int NBODY() { return (*_IP).NBODY; }; + int NBODY() { return (*_IP).NBODY; } - int type() { return (*_IP).ITYPE; }; + int type() { return (*_IP).ITYPE; } - void setProperty(InteractionProperty& ip) { _IP = &ip; }; + void setProperty(InteractionProperty& ip) { _IP = &ip; } InteractionProperty& property() { #ifdef DEB @@ -392,9 +393,9 @@ class Interaction : public Ring { } #endif return *_IP; - }; + } - Site& site(int i) { return *(_s[i]); }; + Site& site(int i) { return *(_s[i]); } void setSite(int i, Site& s) { #ifdef DEB @@ -405,7 +406,7 @@ class Interaction : public Ring { } #endif _s[i] = &s; - }; + } void dump() { int* sid = new int[NBODY()]; @@ -418,9 +419,9 @@ class Interaction : public Ring { printf(" ), type= %2d | ", type()); Ring::dump(); delete[] sid; - }; + } - void idclear() { lastID = 0; }; + void idclear() { lastID = 0; } }; int Interaction::lastID = 0; @@ -769,7 +770,7 @@ inline Site::~Site() { Segment& S = first(); S.remove(); TheSegmentPool.push(S); - }; + } TheVertexPool.push(*_vterm); } @@ -800,11 +801,11 @@ inline Interaction::~Interaction() { Vertex& V = first(); V.remove(); TheVertexPool.push(V); - }; + } if (_s != 0) delete[] _s; } -//##########################katou####################################### +// ##########################katou####################################### class UniformInterval { public: Interaction* I_n; @@ -865,7 +866,7 @@ class RegisteredVertexInfo { V_time = Vtime; } RegisteredVertexInfo() : V_x(0) {} - void init(){}; + void init(){} }; inline bool operator<(const RegisteredVertexInfo& obj0, const RegisteredVertexInfo& obj) { @@ -881,9 +882,9 @@ inline bool operator>(const RegisteredVertexInfo& obj0, class RegVInfo : public Linked { public: void erase(); - RegVInfo& prev() { return (RegVInfo&)Linked::prev(); }; - RegVInfo& next() { return (RegVInfo&)Linked::next(); }; - bool operator==(RegVInfo& s) { return this == &s; }; + RegVInfo& prev() { return (RegVInfo&)Linked::prev(); } + RegVInfo& next() { return (RegVInfo&)Linked::next(); } + bool operator==(RegVInfo& s) { return this == &s; } }; Pool TheRVIPool; @@ -893,4 +894,4 @@ inline void RegVInfo::erase() { TheRVIPool.push(*this); } -#endif +#endif // SRC_DLA_OBJECTS_HPP_ diff --git a/src/dla/parameter.hpp b/src/dla/parameter.hpp index a36fd785..5ae04b93 100644 --- a/src/dla/parameter.hpp +++ b/src/dla/parameter.hpp @@ -1,19 +1,21 @@ -#ifndef PARAMETER_H -#define PARAMETER_H +#ifndef SRC_DLA_PARAMETER_HPP_ +#define SRC_DLA_PARAMETER_HPP_ -#include -#include -#include #include #include #include #include + +#include #include #include #include #include #include +#include +#include + #include "../common/read_keyvalues.h" #include "debug.hpp" #include "util.hpp" @@ -157,7 +159,7 @@ void Parameter::readfile(std::string const& filename) { CKOUTFILE = dict["ckoutfile"]; RUNTYPE = lexical_cast(dict["runtype"]); -}; +} inline Parameter::Parameter(int NP, char** PLIST) { AutoDebugDump("Parameter::Parameter"); @@ -269,4 +271,4 @@ inline void Parameter::dump(FILE* F) { fprintf(F, "P CKOUTFILE = %s\n", CKOUTFILE.c_str()); fprintf(F, "P SIMULATIONTIME = %12lf\n", SIMTIME); } -#endif +#endif // SRC_DLA_PARAMETER_HPP_ diff --git a/src/dla/random.cc b/src/dla/random.cc index 6b51af3e..d0a559c4 100644 --- a/src/dla/random.cc +++ b/src/dla/random.cc @@ -18,12 +18,13 @@ *================================================================= */ -#include "random.h" - #include #include -double Random::Dicex(void) { return (double)rand() / RAND_MAX; } -void Random::InitRand() { srand((unsigned)time(NULL)); } + +#include "random.h" + +double Random::Dicex(void) { return static_cast(rand()) / RAND_MAX; } +void Random::InitRand() { srand(static_cast(time(NULL))); } // Uniform [0,1) double Random::Uniform(void) { diff --git a/src/dla/random.h b/src/dla/random.h index f2d0a140..c6f1d0de 100644 --- a/src/dla/random.h +++ b/src/dla/random.h @@ -99,7 +99,7 @@ class Random { double Exp() { return -log(1e0 - Uniform()); } - int Binary(double P) { return ((int)(Uniform() / P)); } + int Binary(double P) { return (static_cast(Uniform() / P)); } void Perm(Rint, int *); diff --git a/src/dla/serialize.hpp b/src/dla/serialize.hpp index 1c513e5e..ee9ba351 100644 --- a/src/dla/serialize.hpp +++ b/src/dla/serialize.hpp @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef SERIALIZE_H -#define SERIALIZE_H +#ifndef SRC_DLA_SERIALIZE_HPP_ +#define SRC_DLA_SERIALIZE_HPP_ #include + #include #include #include @@ -86,4 +87,4 @@ void load(std::ifstream& ifs, std::vector& val) { } // namespace Serialize -#endif // SERIALIZE_H +#endif // SRC_DLA_SERIALIZE_HPP_ diff --git a/src/dla/sf.hpp b/src/dla/sf.hpp index fdf3825b..ee2162b7 100644 --- a/src/dla/sf.hpp +++ b/src/dla/sf.hpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef SF_H -#define SF_H +#ifndef SRC_DLA_SF_HPP_ +#define SRC_DLA_SF_HPP_ #include #include @@ -65,7 +65,7 @@ class SF { counterS[ik][it] = 0.0; } } - }; + } void save(std::ofstream& F) const; void load(std::ifstream& F); @@ -100,7 +100,7 @@ SF::SF(Parameter const& param, Lattice& lat, Algorithm& alg, WaveVector& wv) counterS.push_back(std::vector(Ntau)); } } -}; +} inline void SF::setinit() { if (!to_be_calc) { @@ -174,7 +174,7 @@ inline void SF::show(FILE* F) { } fprintf(F, "\n"); } -}; +} inline void SF::summary() { if (!to_be_calc) { @@ -241,4 +241,4 @@ void SF::load(std::ifstream& F) { Serialize::load(F, PHY); } -#endif // SF_H +#endif // SRC_DLA_SF_HPP_ diff --git a/src/dla/util.hpp b/src/dla/util.hpp index 41b0306f..397e26f3 100644 --- a/src/dla/util.hpp +++ b/src/dla/util.hpp @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef UTIL_HPP -#define UTIL_HPP +#ifndef SRC_DLA_UTIL_HPP_ +#define SRC_DLA_UTIL_HPP_ #include + #include #include @@ -56,4 +57,4 @@ void ERROR(const char* msg) { } // namespace util -#endif // UTIL_HPP +#endif // SRC_DLA_UTIL_HPP_ diff --git a/src/dla/wavevector.hpp b/src/dla/wavevector.hpp index 472202c8..c514e1fb 100644 --- a/src/dla/wavevector.hpp +++ b/src/dla/wavevector.hpp @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef WAVEVECTOR_HPP -#define WAVEVECTOR_HPP +#ifndef SRC_DLA_WAVEVECTOR_HPP_ +#define SRC_DLA_WAVEVECTOR_HPP_ #include + #include #include #include @@ -35,7 +36,7 @@ struct WaveVector { std::vector > COSrk; std::vector > SINrk; - WaveVector(Parameter const& param); + explicit WaveVector(Parameter const& param); }; WaveVector::WaveVector(Parameter const& param) @@ -68,4 +69,4 @@ WaveVector::WaveVector(Parameter const& param) } }; -#endif // WaveVector_H +#endif // SRC_DLA_WAVEVECTOR_HPP_ diff --git a/src/dla/xml.h b/src/dla/xml.h index 94619341..be548883 100644 --- a/src/dla/xml.h +++ b/src/dla/xml.h @@ -1,3 +1,19 @@ +// DSQSS (Discrete Space Quantum Systems Solver) +// Copyright (C) 2018- The University of Tokyo +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + //###################################################################### //#### //#### World-Line Monte Carlo simulation @@ -16,30 +32,14 @@ //#### //###################################################################### -// DSQSS (Discrete Space Quantum Systems Solver) -// Copyright (C) 2018- The University of Tokyo -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - // Known bugs: // (1) Tags must be separated from other words by one or more spaces or // line breaks. Otherwise they are not recognized. // (2) The comment identifiers must be separated by spaces or // line breaks, too. -#ifndef XML_H -#define XML_H +#ifndef SRC_DLA_XML_H_ +#define SRC_DLA_XML_H_ #include "array.h" #include "io.h" @@ -106,20 +106,20 @@ class Block { Block() { NB = 0; NV = 0; - }; + } Block(const std::string& FNAME, const std::string& BNAME = "") { NB = 0; NV = 0; initialize(FNAME, BNAME); - }; + } ~Block(){ // printf("*** Destroying XML::Block (%s)\n", Name.c_str()); - }; + } - const int& NumberOfBlocks() const { return NB; }; - const int& NumberOfValues() const { return NV; }; + const int& NumberOfBlocks() const { return NB; } + const int& NumberOfValues() const { return NV; } std::string getJoinedString(); const std::string& getName() const; bool syntax_error(); @@ -131,7 +131,7 @@ class Block { Block& getElement(const std::string& name); Block& getElement(const std::string& name, const std::string& idkey, const int id); - Block& operator[](const int& i) { return SubBlock[i]; }; + Block& operator[](const int& i) { return SubBlock[i]; } Block& operator[](const std::string& name); void dump(const std::string& prompt = ""); }; @@ -322,7 +322,7 @@ inline double Block::getDouble(const int i) { } #endif std::string& s = getString(i); - return (double)atof(s.c_str()); + return static_cast(atof(s.c_str())); } inline Block& Block::getElement(const int i) { return SubBlock[i]; } @@ -391,4 +391,4 @@ inline void Block::dump(const std::string& prompt) { } // namespace XML -#endif +#endif // SRC_DLA_XML_H_ diff --git a/src/pmwa/PMWA.cpp b/src/pmwa/PMWA.cpp index 96babfc1..2f496486 100644 --- a/src/pmwa/PMWA.cpp +++ b/src/pmwa/PMWA.cpp @@ -26,9 +26,7 @@ int main(int argc, char **argv) { Dla Sim(argc, argv); - //////////////////////////////////////////////////////////// Sim.PMWA(); - //////////////////////////////////////////////////////////// return 0; } @@ -291,8 +289,8 @@ void Dla::init_paramdict(std::map &dict) { } void Dla::set_Parallel() { - PR.B = N.B / (double)PR.Ntdiv; // beta for a domain. - PR.oldB = N.oldB / (double)PR.Ntdiv; // for annealing. + PR.B = N.B / PR.Ntdiv; // beta for a domain. + PR.oldB = N.oldB / PR.Ntdiv; // for annealing. PR.Nsdiv = PR.Nxdiv * PR.Nydiv * PR.Nzdiv; // the number of spatial decompositions. @@ -309,7 +307,7 @@ void Dla::set_Parallel() { PR.nt = PR.my_rank % PR.Ntdiv; // the temporal domain number for the processor. - PR.ns = (int)(PR.my_rank / PR.Ntdiv) % + PR.ns = static_cast(PR.my_rank / PR.Ntdiv) % PR.Nsdiv; // the spatial domain number for the processor. PR.nx = diff --git a/src/pmwa/configuration.cpp b/src/pmwa/configuration.cpp index 5d100fd1..1a18a0e4 100644 --- a/src/pmwa/configuration.cpp +++ b/src/pmwa/configuration.cpp @@ -1,13 +1,14 @@ +#include + #include #include #include -#include #include "../common/timer.hpp" -//#define Bcheck -//#include "graphspace.cpp" +// #define Bcheck +// #include "graphspace.cpp" Configuration::Configuration(MC_p *m_MC, Size *m_N, int m_nmax, Lattice *m_LT, Probability *m_P, Parallel *PR, long long m_IMAX, @@ -69,11 +70,12 @@ void Configuration::updateAnner(int MCS, My_rdm *MR, Quantities *QNT) { // cout << i <<"-th step:: Ncyc="<my_rank<<"::Wnum="<NtNs; tag++) { if (pcyc[tag] > 0) { count++; - // cout<<"rank"< PR->NtNs / 2) + if (count > PR->NtNs / 2) { Ncyc /= count; - else { + } else { cout << "Larger eta is recommended." << endl; Ncyc = 100000; } @@ -112,16 +115,19 @@ void Configuration::updateAnner(int MCS, My_rdm *MR, Quantities *QNT) { // cout << i+step1 <<"-th step:: Ncyc="< PR->NtNs / 2) + if (count > PR->NtNs / 2) { Ncyc /= count; - else { + } else { cout << "Larger eta is recommended." << endl; Ncyc = 100000; } - if (Ncyc > 100000) Ncyc = 100000; + if (Ncyc > 100000) { + Ncyc = 100000; + } // cout<<"final ::rank"<my_rank<<":: Wlen="<Pd); newcall_zero(NewVertex_th1, LT->Pd); - int alpha = (int)(sqrt(B)); + int alpha = sqrt(B); if (alpha == 0) alpha = 1; newcall_zero(BoxSpace_t_th0, LT->Pd, alpha * ES * boxsize); @@ -232,15 +231,20 @@ void GraphSpace::initialev(std::string const &Eventfile_old, My_rdm *MR, int cb, } } else { Ncyc = 30; - if (cb == 1) - for (int i = 0; i < V; i++) + if (cb == 1) { + for (int i = 0; i < V; i++) { world[i].p = worldB[i].p = - ((i % PR->x + (int)(i / PR->x)) % 2 == 0) ? 1 : 0; - else if (cb == 2) - for (int i = 0; i < V; i++) + ((i % PR->x + static_cast(i / PR->x)) % 2 == 0) ? 1 : 0; + } + } else if (cb == 2) { + for (int i = 0; i < V; i++) { world[i].p = worldB[i].p = (nmax + 1) * MR->rdm(); - else - for (int i = 0; i < V; i++) world[i].p = worldB[i].p = 0; + } + } else { + for (int i = 0; i < V; i++) { + world[i].p = worldB[i].p = 0; + } + } } fin.close(); @@ -257,7 +261,7 @@ void GraphSpace::initialev(std::string const &Eventfile_old, My_rdm *MR, int cb, Pv1 = rt_tot / rtot; - //境界 + // Boundary PBv1 = rt_tot / rtot; //################################### @@ -268,19 +272,16 @@ void GraphSpace::initialev(std::string const &Eventfile_old, My_rdm *MR, int cb, Switch[a][b] = 0; // bounce After[0][a] = b; // bounce } else if (a + b == 3) { // hop and turn - Switch[a][b] = 3; Switch[b][a] = 3; After[3][b] = a; After[3][a] = b; } else if (a - b == 2) { // hop - Switch[a][b] = 2; Switch[b][a] = 2; After[2][b] = a; After[2][a] = b; } else { // pass - Switch[a][b] = 1; Switch[b][a] = 1; After[1][b] = a; @@ -427,9 +428,10 @@ void GraphSpace::Remove_Vertex() { Nu = 0; for (int i = 0; i < V; i++) { for (Vertex *wx = &(world[i]); wx != &(worldB[i]); wx = wx->next[1]) { - if (wx->type != 2 && wx->type != 4 && wx->type != 5 && wx->type % 2 != -1) + if (wx->type != 2 && wx->type != 4 && wx->type != 5 && + wx->type % 2 != -1) { release(wx); - else if (wx->type == 2 || wx->type == -1 || wx->type == -3) { + } else if (wx->type == 2 || wx->type == -1 || wx->type == -3) { INmax[i]++; if (wx->type == 2) { Nv++; @@ -528,8 +530,8 @@ void GraphSpace::Assign_TwoSiteVertex(My_rdm *MR) { R = MR->rdm(); if (Pv1 > R) { - site = (int)(V * MR->rdm()); - d = (int)(LT->Pd * MR->rdm()); //(LT->bnum*MR->rdm()); + site = V * MR->rdm(); + d = LT->Pd * MR->rdm(); // (LT->bnum*MR->rdm()); xl = site; xr = LT->bd[site][d]; } else { @@ -549,8 +551,8 @@ void GraphSpace::Assign_TwoSiteVertex(My_rdm *MR) { //////////////////////////////////////////////////////////////////////// - if (LT->frame[d][xl]) { // interbond - + if (LT->frame[d][xl]) { + // interbond xnum = LT->frame_rnum[d][xr]; while (BoxSpace_t_th1[d][f(d, xnum, wf[d][xnum] + 1)] < targ_time) { wf[d][xnum]++; @@ -567,8 +569,8 @@ void GraphSpace::Assign_TwoSiteVertex(My_rdm *MR) { Nv++; } - } else { // innerbond - + } else { + // innerbond while (w[xr]->next[1] != &(worldB[xr])) { if (targ_time < w[xr]->next[1]->t) break; w[xr] = w[xr]->next[1]; @@ -623,8 +625,9 @@ void GraphSpace::Assign_TwoSiteVertex(My_rdm *MR) { INmax[xr]++; w[xr] = w[xr]->next[1]; k++; - } else + } else { w[xr] = w[xr]->next[1]; + } } } } @@ -770,7 +773,6 @@ void GraphSpace::Assign_Worm(My_rdm *MR) { for (int site = 0; site < V; site++) { for (Vertex *wl = world[site].next[1]; wl != &(world[site]); wl = wl->next[1]) { // until worldB - j = 0; dw = wl->next[0]; dtn[0] = dw->t; @@ -779,10 +781,9 @@ void GraphSpace::Assign_Worm(My_rdm *MR) { parity_check(MR, (wl->dir) % 2, dtn, j, wl->t, dw->t); for (int l = 0; l < j; l++) { // insert j worms - insert(dw, 4 + n0, dtn[l], site, !n0, 0); WORM.push_back(wl->next[0]); - wl->next[0]->dir = (int)(2 * MR->rdm()); + wl->next[0]->dir = static_cast(2 * MR->rdm()); dw = wl->next[0]; n0 = !n0; } @@ -809,12 +810,12 @@ void GraphSpace::parity_check(My_rdm *MR, int py, double *x, int &j, j = (Ia == 0.0) ? 0 : NumberOfVertex(MR, Ia, py); if (j != 0) { - if (Il <= (double)(j + 1) * NMIN) { + if (Il <= (j + 1) * NMIN) { if (PR->my_rank == 0) cout << "Il is too small: Il=" << Il << ", topt=" << topt << ", bottomt=" << bottomt << endl; j = py % 2; - if (Il <= (double)(j + 1) * NMIN) { + if (Il <= (j + 1) * NMIN) { if (PR->my_rank == 0) cout << "///Il has error" << endl; } } @@ -845,7 +846,7 @@ int GraphSpace::NumberOfVertex(My_rdm *MR, double m, int py) { while (1) { FAC *= fn; // factorial( n ); - pos = POW / (double)FAC; + pos = POW / FAC; Pn += pos; @@ -878,10 +879,9 @@ void GraphSpace::SpatialDomainBoundary(My_rdm *MR) { k = 0; for (Vertex *wl = world[right].next[1]; wl != &(world[right]); wl = wl->next[1]) { // until worldB - if (((wl->i) / V == d && wl->type <= -3 && wl->type >= -4) || next) { BoxSpace_t_th0[d][f(d, i, k)] = wl->t - wl->next[0]->t; - BoxSpace_py_th0[f(d, i, k)] = (short)wl->dir; + BoxSpace_py_th0[f(d, i, k)] = wl->dir; if ((wl->i) / V != d || wl->type > -3 || wl->type < -4) { BoxSpace_type_th0[f(d, i, k)] = 7; next = false; @@ -923,7 +923,6 @@ void GraphSpace::SpatialDomainBoundary(My_rdm *MR) { wl = wl->next[1]) { if ((wl->i) / V == d && (wl->type == -1 || wl->type == -2)) { // judge by the left - while (BoxSpace_type_th1[f(d, i, rnum)] == 7) { rnum++; } @@ -942,10 +941,10 @@ void GraphSpace::SpatialDomainBoundary(My_rdm *MR) { py1 = wl->dir; py2 = wl->next[1]->dir; - py3 = (bool)BoxSpace_py_th1[f(d, i, rnum + 1)]; - py4 = (bool)BoxSpace_py_th1[f(d, i, rnum)]; + py3 = BoxSpace_py_th1[f(d, i, rnum + 1)]; + py4 = BoxSpace_py_th1[f(d, i, rnum)]; - // int xl=LT->lx[left]; + // int xl=LT->lx[left]; PP[0] = (this->*Form[b][0])(I1, I2, I3, I4, py1, py2, py3, py4) * P->FracW[b][0][0]; @@ -987,15 +986,15 @@ void GraphSpace::SpatialDomainBoundary(My_rdm *MR) { k = 0; for (Vertex *wl = world[right].next[1]; wl != &(world[right]); wl = wl->next[1]) { // until worldB - if (((wl->i) / V == d && wl->type <= -3 && wl->type >= -4) || next) { wl->dir = BoxSpace_py_th0[f(d, i, k)]; if (BoxSpace_type_th0[f(d, i, k)] != 7) { wl->type = BoxSpace_type_th0[f(d, i, k)]; wl->p = BoxSpace_p_th0[d][f(d, i, k)]; next = true; - } else + } else { next = false; + } k++; } } @@ -1043,7 +1042,6 @@ void GraphSpace::TemporalDomainBoundary(My_rdm *MR, Quantities *QNT) { P_i = Om0 * Om1; if (P_i > R) { // update the temporal domain boundary. - world[site].next[1]->dir = !(py0); p0_box[site] = !(py1); py0 = world[site].p; diff --git a/src/pmwa/inc/Configuration.h b/src/pmwa/inc/Configuration.h index e6bc8cc8..2fea2cf8 100644 --- a/src/pmwa/inc/Configuration.h +++ b/src/pmwa/inc/Configuration.h @@ -1,5 +1,5 @@ -#ifndef CONFIGURATION_H -#define CONFIGURATION_H +#ifndef SRC_PMWA_INC_CONFIGURATION_H_ +#define SRC_PMWA_INC_CONFIGURATION_H_ #include #include @@ -16,6 +16,7 @@ #include #include #include +#include #include "mpi.h" @@ -347,4 +348,4 @@ class Configuration : public GraphSpace { // void update( int MCS, My_rdm *MR, int &Wnum ); }; -#endif +#endif // SRC_PMWA_INC_CONFIGURATION_H_ diff --git a/src/pmwa/inc/Graph_functions.h b/src/pmwa/inc/Graph_functions.h index 4f58d954..de898477 100644 --- a/src/pmwa/inc/Graph_functions.h +++ b/src/pmwa/inc/Graph_functions.h @@ -165,14 +165,16 @@ void GraphSpace::All(Vertex *wl, int d, int i, int rnum) { wl->dir = !wl->dir; wl->next[1]->dir = !wl->next[1]->dir; BoxSpace_py_th1[f(d, i, rnum + 1)] = - !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); - BoxSpace_py_th1[f(d, i, rnum)] = !((bool)BoxSpace_py_th1[f(d, i, rnum)]); + !(static_cast(BoxSpace_py_th1[f(d, i, rnum + 1)])); + BoxSpace_py_th1[f(d, i, rnum)] = + !(static_cast(BoxSpace_py_th1[f(d, i, rnum)])); } void GraphSpace::Right(Vertex *wl, int d, int i, int rnum) { BoxSpace_py_th1[f(d, i, rnum + 1)] = - !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); - BoxSpace_py_th1[f(d, i, rnum)] = !((bool)BoxSpace_py_th1[f(d, i, rnum)]); + !(static_cast(BoxSpace_py_th1[f(d, i, rnum + 1)])); + BoxSpace_py_th1[f(d, i, rnum)] = + !(static_cast(BoxSpace_py_th1[f(d, i, rnum)])); } void GraphSpace::Left(Vertex *wl, int d, int i, int rnum) { @@ -183,23 +185,25 @@ void GraphSpace::Left(Vertex *wl, int d, int i, int rnum) { void GraphSpace::LdRu(Vertex *wl, int d, int i, int rnum) { wl->dir = !wl->dir; BoxSpace_py_th1[f(d, i, rnum + 1)] = - !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); + !(static_cast(BoxSpace_py_th1[f(d, i, rnum + 1)])); } void GraphSpace::LuRd(Vertex *wl, int d, int i, int rnum) { wl->next[1]->dir = !wl->next[1]->dir; - BoxSpace_py_th1[f(d, i, rnum)] = !((bool)BoxSpace_py_th1[f(d, i, rnum)]); + BoxSpace_py_th1[f(d, i, rnum)] = + !(static_cast(BoxSpace_py_th1[f(d, i, rnum)])); } void GraphSpace::LuRu(Vertex *wl, int d, int i, int rnum) { wl->next[1]->dir = !wl->next[1]->dir; BoxSpace_py_th1[f(d, i, rnum + 1)] = - !((bool)BoxSpace_py_th1[f(d, i, rnum + 1)]); + !(static_cast(BoxSpace_py_th1[f(d, i, rnum + 1)])); } void GraphSpace::LdRd(Vertex *wl, int d, int i, int rnum) { wl->dir = !wl->dir; - BoxSpace_py_th1[f(d, i, rnum)] = !((bool)BoxSpace_py_th1[f(d, i, rnum)]); + BoxSpace_py_th1[f(d, i, rnum)] = + !(static_cast(BoxSpace_py_th1[f(d, i, rnum)])); } //####################################################################################################### diff --git a/src/pmwa/inc/PMWA.h b/src/pmwa/inc/PMWA.h index 261d136c..21122204 100644 --- a/src/pmwa/inc/PMWA.h +++ b/src/pmwa/inc/PMWA.h @@ -1,5 +1,5 @@ -#ifndef PMWA_H -#define PMWA_H +#ifndef SRC_PMWA_INC_PMWA_H_ +#define SRC_PMWA_INC_PMWA_H_ #include #include @@ -97,7 +97,7 @@ class Dla { << ", lower= " << PR.lower << ", right(x)= " << PR.right[0] << ", left(x)= " << PR.left[0] << ", right(y)= " << PR.right[1] << ", left(y)= " << PR.left[1] << endl; - }; + } inline void show_SP() { std::cout << "step =" << MC.Nstep << " thermal=" << MC.Nthermal @@ -110,7 +110,7 @@ class Dla { << " Htr=" << sp.Htr << " Ntvid=" << PR.Ntdiv << " Npara=" << PR.Npara << " Nsdiv=" << PR.Nsdiv << " outfile=" << outfile << std::endl; - }; + } inline void show_TIME() { ftest << "Testing Time for Ncyc = " << pend - pstart << endl; @@ -120,4 +120,4 @@ class Dla { } }; -#endif +#endif // SRC_PMWA_INC_PMWA_H_ diff --git a/src/pmwa/inc/Probability.h b/src/pmwa/inc/Probability.h index 023d41cc..98e254f4 100644 --- a/src/pmwa/inc/Probability.h +++ b/src/pmwa/inc/Probability.h @@ -1,5 +1,5 @@ -#ifndef PROB_H -#define PROB_H +#ifndef SRC_PMWA_INC_PROBABILITY_H_ +#define SRC_PMWA_INC_PROBABILITY_H_ #include #include @@ -67,4 +67,4 @@ class Probability { double Tuab(int i, int j, int x); }; -#endif +#endif // SRC_PMWA_INC_PROBABILITY_H_ diff --git a/src/pmwa/inc/Quantities.h b/src/pmwa/inc/Quantities.h index 3e9c676f..6fc805f4 100644 --- a/src/pmwa/inc/Quantities.h +++ b/src/pmwa/inc/Quantities.h @@ -1,5 +1,5 @@ -#ifndef QUANTITIES_H -#define QUANTITIES_H +#ifndef SRC_PMWA_INC_QUANTITIES_H_ +#define SRC_PMWA_INC_QUANTITIES_H_ #include #include @@ -278,4 +278,4 @@ class Quantities { void show(ofstream &F, FILE *SFF); }; -#endif +#endif // SRC_PMWA_INC_QUANTITIES_H_ diff --git a/src/pmwa/inc/lattice.hpp b/src/pmwa/inc/lattice.hpp index 2c741ad1..37617724 100644 --- a/src/pmwa/inc/lattice.hpp +++ b/src/pmwa/inc/lattice.hpp @@ -1,5 +1,5 @@ -#ifndef LATTICE_HPP -#define LATTICE_HPP +#ifndef SRC_PMWA_INC_LATTICE_HPP_ +#define SRC_PMWA_INC_LATTICE_HPP_ //###################################################################### @@ -12,7 +12,6 @@ #include #include #include -//###################################################################### class Lattice { private: @@ -36,7 +35,7 @@ class Lattice { int NFIELD; Size *N; - ////domain/// + //// domain Parallel *PR; int V, Nx, Ny, Nz; double B; @@ -55,8 +54,8 @@ class Lattice { int rmax; - Lattice(const char *FNAME); - Lattice(std::string const &FNAME); + explicit Lattice(const char *FNAME); + explicit Lattice(std::string const &FNAME); ~Lattice(); @@ -75,4 +74,4 @@ class Lattice { void read(); }; -#endif +#endif // SRC_PMWA_INC_LATTICE_HPP_ diff --git a/src/pmwa/inc/systemparameter.h b/src/pmwa/inc/systemparameter.h index 6c68be12..b6966651 100644 --- a/src/pmwa/inc/systemparameter.h +++ b/src/pmwa/inc/systemparameter.h @@ -1,5 +1,5 @@ -#ifndef SYSTEMPARAM_H -#define SYSTEMPARAM_H +#ifndef SRC_PMWA_INC_SYSTEMPARAMETER_H_ +#define SRC_PMWA_INC_SYSTEMPARAMETER_H_ #define VAL 10 #define INF 1.0e+14 @@ -48,7 +48,7 @@ struct MC_p { int Nbin; int Ntest; int nc; - int runtype; //{0: normal, 1:restart, 2:annealing} + int runtype; // {0: normal, 1:restart, 2:annealing} MC_p() : seed(0), Nstep(0), @@ -147,4 +147,4 @@ struct Parallel { } }; -#endif +#endif // SRC_PMWA_INC_SYSTEMPARAMETER_H_ diff --git a/src/pmwa/inc/xml.hpp b/src/pmwa/inc/xml.hpp index 295c9e9a..a0ffa9b6 100644 --- a/src/pmwa/inc/xml.hpp +++ b/src/pmwa/inc/xml.hpp @@ -1,5 +1,5 @@ -#ifndef XML_H -#define XML_H +#ifndef SRC_PMWA_INC_XML_HPP_ +#define SRC_PMWA_INC_XML_HPP_ #include #include @@ -19,8 +19,8 @@ inline int line_split(char *line, std::string *w) { std::string s(line); std::istringstream ist(s); int nw = 0; - while (ist >> w[nw++]) - ; + while (ist >> w[nw++]) { + } nw--; return nw; } @@ -44,29 +44,29 @@ class FileReader { if (!INS) { printf("FILEIO::FILEIO> Error.\n"); exit(0); - }; + } IL = 0; - }; + } - FileReader() { EOL = "_E_O_L_"; }; + FileReader() { EOL = "_E_O_L_"; } void rewind() { INS.clear(); INS.seekg(top); - }; + } int split() { NW = line_split(LINE, WORD); return NW; - }; + } bool read() { - bool b = (bool)INS.getline(LINE, BLEN); + bool b = static_cast(INS.getline(LINE, BLEN)); if (b) { IL++; } return b; - }; + } std::string &word(int i) { if (i < 0 && i >= NW) { @@ -74,7 +74,7 @@ class FileReader { exit(0); } return WORD[i]; - }; + } void getWordList(int &NW, std::string *&W); }; @@ -93,13 +93,13 @@ class IndexSystem { public: void init(const int d, const int *l, const std::string &LBL0 = ""); - IndexSystem() { INI = false; }; + IndexSystem() { INI = false; } ~IndexSystem() { if (initialized()) delete[] L; - }; + } - bool initialized() const { return INI; }; + bool initialized() const { return INI; } }; //------------------------------ @@ -117,7 +117,7 @@ class Array { Array() { LBL = ""; val = 0; - }; + } ~Array(); @@ -162,17 +162,15 @@ class Block { NB = 0; NV = 0; EOL = "_E_O_L_"; - }; + } - ~Block(){ - // printf("*** Destroying XML::Block (%s)\n", Name.c_str()); - }; + ~Block() { + // printf("*** Destroying XML::Block (%s)\n", Name.c_str()); + } void read(); - //// bool syntax_error(); - /// Block &operator[](const int &i); @@ -188,9 +186,9 @@ class Block { Block &getElement(const std::string &name); - const int &NumberOfBlocks() const { return NB; }; + const int &NumberOfBlocks() const { return NB; } - const int &NumberOfValues() const { return NV; }; + const int &NumberOfValues() const { return NV; } }; inline int Block::getInteger(const int i) { @@ -215,7 +213,7 @@ inline double Block::getDouble(const int i) { } #endif std::string &s = getString(i); - return (double)atof(s.c_str()); + return atof(s.c_str()); } inline const std::string &Block::getName() const { return Name; } @@ -240,4 +238,4 @@ inline std::string &Block::getString(const int i) { } // namespace XML -#endif +#endif // SRC_PMWA_INC_XML_HPP_ diff --git a/src/pmwa/lattgene.cc b/src/pmwa/lattgene.cc index 25456397..f192a855 100644 --- a/src/pmwa/lattgene.cc +++ b/src/pmwa/lattgene.cc @@ -45,7 +45,7 @@ void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, for (int i = 0; i < D; i++) { L[i] = orgL[i] / NLD; } - double B = orgB / (double)NBD; + double B = orgB / NBD; int N = 1; // number of sites per domain. for (int i = 0; i < D; i++) { @@ -141,8 +141,9 @@ void WriteXML(int D, int orgL[], double orgB, double orgOB, int NLD, int NBD, if (x[p] == L[p] - 1) { etype = eid; eid++; - } else + } else{ etype = -1; + } x[p] = (x[p] + 1) % L[p]; int j = 0; @@ -194,7 +195,7 @@ int main(int argc, char **argv) { for (int i = 0; i < D; i++) { L[i] = lx; } - B = (double)atof(argv[3]); + B = atof(argv[3]); NLD = atoi(argv[4]); NBD = atoi(argv[5]); NF = atoi(argv[6]); @@ -202,7 +203,7 @@ int main(int argc, char **argv) { for (int i = 0; i < D; i++) { L[i] = atoi(argv[2 + i]); } - B = (double)atof(argv[D + NARG - 4]); + B = atof(argv[D + NARG - 4]); NLD = atoi(argv[D + NARG - 3]); NBD = atoi(argv[D + NARG - 2]); NF = atoi(argv[D + NARG - 1]); diff --git a/src/pmwa/lattice.cpp b/src/pmwa/lattice.cpp index d4a95a93..9eca290d 100644 --- a/src/pmwa/lattice.cpp +++ b/src/pmwa/lattice.cpp @@ -43,7 +43,7 @@ void IndexSystem::init(const int d, const int *l, const std::string &LBL0) { printf("IndexSystem::init> Error. N = 0.\n"); for (int i = 0; i < d; i++) printf(" L[%d] = %d\n", i, L[i]); exit(0); - }; + } } template @@ -115,7 +115,7 @@ inline Block &Block::getElement(const std::string &name) { } } -Block &Block::operator[](const int &i) { return SubBlock[i]; }; +Block &Block::operator[](const int &i) { return SubBlock[i]; } Block &Block::operator[](const std::string &name) { Block &B = getElement(name); @@ -275,9 +275,9 @@ void Block::read() { int i = 0; while (true) { std::string &w = Word[i++]; - // cout << "### " << w << endl;//koko + // cout << "### " << w << endl; // koko if (w == Open) { - // printf("Opened. %s\n", w.c_str());//koko + // printf("Opened. %s\n", w.c_str()); // koko open = true; continue; } @@ -435,7 +435,7 @@ void Lattice::make_Parallel(Parallel *_PR) { PR->Rpara = NFIELD; PR->B = BETA / NBdiv; // beta for a domain. - PR->oldB = oldBETA / (double)NBdiv; // for annealing. + PR->oldB = oldBETA / NBdiv; // for annealing. PR->Nsdiv = PR->Nxdiv * PR->Nydiv * PR->Nzdiv; // the number of spatial decompositions. @@ -453,7 +453,7 @@ void Lattice::make_Parallel(Parallel *_PR) { PR->nt = PR->my_rank % PR->Ntdiv; // the temporal domain number for the processor. - PR->ns = (int)(PR->my_rank / PR->Ntdiv) % + PR->ns = static_cast(PR->my_rank / PR->Ntdiv) % PR->Nsdiv; // the spatial domain number for the processor. PR->nx = @@ -591,7 +591,7 @@ inline void Lattice::dump() { } void Lattice::show_param(std::ofstream &F) { - using namespace std; + using std::endl; F << "P D = " << N->d << endl; F << "P L = " << N->x << " " << N->y << " " << N->z << endl; F << "P BETA = " << BETA << endl; diff --git a/src/pmwa/probability.B.cpp b/src/pmwa/probability.B.cpp index 9b66c2ef..e0786aaa 100644 --- a/src/pmwa/probability.B.cpp +++ b/src/pmwa/probability.B.cpp @@ -76,7 +76,7 @@ void Probability::look(Size *N, System *sp) { for (int tag = 0; tag < PR->NtNs; tag++) { sp->Eu += peu[tag]; } - sp->Eu /= (double)PR->Ntdiv; // double count for Ntdiv + sp->Eu /= PR->Ntdiv; // double count for Ntdiv delcall(peu); MPI_Comm_free(&comm_nst0); @@ -129,18 +129,15 @@ void Probability::look(Size *N, System *sp) { int flaver = 4; for (int x = 0; x < XMAX; x++) { for (h = 0; h < 2; h++) { // head operator - oh = h * 2 - 1; for (int i = 0; i <= nmax; i++) { // # of particles on the left site - sql = sqrt(i - h + 1.0); for (int j = 0; j <= nmax; j++) { // # of particles on the right site - - if (h == i) + if (h == i){ type = 5; - else { + } else { type = 0; Om[0].val = at[i][j][x]; Om[1].val = at[i + oh][j][x]; @@ -157,7 +154,6 @@ void Probability::look(Size *N, System *sp) { for (int b = 0; b < 4; b++) // before update for (int a = 0; a < 4; a++) { // after update - //******************* scattering against t ****************** if (type == 5) t[h][a][b][i][j][x] = 0.0; @@ -259,15 +255,15 @@ void Probability::SolveWeightEquation(int cmax) { // introduce a transition between the max state and the second // and reduce weights of these states double x = V_first - V_second; - double y = (double)(N_second - 1) * (V_second - V_third); + double y = (N_second - 1) * (V_second - V_third); if (x < y) { - dw1 = (V_first - V_second) / (1.0 - 1.0 / (double)(N_second)); - dw2 = dw1 / (double)N_second; + dw1 = (V_first - V_second) / (1.0 - 1.0 / (N_second)); + dw2 = dw1 / N_second; V_second_new = V_second - dw2; V_first_new = V_second_new; } else { dw2 = V_second - V_third; - dw1 = dw2 * (double)N_second; + dw1 = dw2 * N_second; V_second_new = V_third; V_first_new = V_first - dw1; } @@ -281,7 +277,7 @@ void Probability::SolveWeightEquation(int cmax) { // When the maximum weight state is degenerated // introduce a transition between these states // and reduce weights of these states to the weight of the second largest. - dw1 = (V_first - V_second) / (double)(N_first - 1); + dw1 = (V_first - V_second) / (N_first - 1); for (int i = 0; i < N_first; i++) { ex_Wall[i] = V_second; for (int j = 0; j < N_first; j++) { @@ -298,13 +294,12 @@ void Probability::SolveWeightEquation(int cmax) { } double Probability::Tuab(int p, int q, int x) { // p(L)->q(S) - return au_make(q, x) / au_make(p, x); } // return t vertex density double Probability::at_make(int p, int q, int x) { - double Ht = -V1 * (double)(p * q); + double Ht = -V1 * (p * q); return (Ht + local_Et); } diff --git a/src/pmwa/probability.H.cpp b/src/pmwa/probability.H.cpp index 10d987af..a8940c07 100644 --- a/src/pmwa/probability.H.cpp +++ b/src/pmwa/probability.H.cpp @@ -76,7 +76,7 @@ void Probability::look(Size *N, System *sp) { for (int tag = 0; tag < PR->NtNs; tag++) { sp->Eu += peu[tag]; } - sp->Eu /= (double)PR->Ntdiv; // double count for Ntdiv + sp->Eu /= PR->Ntdiv; // double count for Ntdiv delcall(peu); MPI_Comm_free(&comm_nst0); @@ -87,13 +87,13 @@ void Probability::look(Size *N, System *sp) { rh_odd = sp->Htr; rh_even = sp->Htr; - //************ at ************** + // ************ at ************** for (int i = 0; i <= nmax; i++) for (int j = 0; j <= nmax; j++) for (int x = 0; x < XMAX; x++) at[i][j][x] = at_make(i, j, x); for (int i = 0; i <= nmax; i++) for (int x = 0; x < PR->V; x++) ru[i][x] = au_make(i, x); - //*************romax****************** + // *************romax****************** rtmax = rmin; for (int i = 0; i <= nmax; i++) for (int j = 0; j <= nmax; j++) @@ -120,28 +120,25 @@ void Probability::look(Size *N, System *sp) { u[b][i][x] = Tuab(i, j, x); // when i is larger(L), if L->S then P = // S/L, if L->L then 1.0 - S/L. - // if(PR->my_rank==0)cout <<"x="< +// #include #include -//#define KSTEPALL -//#define XSTEPALL -//#include +// #define KSTEPALL +// #define XSTEPALL +// #include Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Parallel *m_PR, std::string const &outfile) { @@ -53,11 +53,11 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Lmax[cr2] = Nxmax; // Lmax[sk]=Nkmax*2;//i.e. real and imaginary part Lmax[ck2] = Nkmax * 2; - //#ifdef GF22Gk2 + // #ifdef GF22Gk2 // Lmax[cr4]=N->x*N->x; - //#else - // Lmax[cr4]=Nxmax*PR->Nxdiv; - //#endif + // #else + // Lmax[cr4]=Nxmax*PR->Nxdiv; + // #endif Lmax[ck4] = Nkxmax * Nkkmax * 2; Lmax[dkk] = Nkxmax * Nkkmax; Lmax[nw] = V; @@ -121,13 +121,13 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, newcall_zero(values_L, Lsize); newcall_zero(MCmean_L, Lsize * 2); newcall_zero(BINmean_L, Lsize * MC->Nbin); - // newcall_zero(RNDmean_L,Lsize*PR->Npara); + // newcall_zero(RNDmean_L,Lsize*PR->Npara); - newcall_zero(m_val, max(Lsize, (int)Nq)); + newcall_zero(m_val, max(Lsize, static_cast(Nq))); newcall_zero(EXPrk, 4 * Nkmax * V); - // newcall_zero(COSnp,V); - // newcall_zero(SINnp,V); + // newcall_zero(COSnp,V); + // newcall_zero(SINnp,V); Cknum = 16; Nk_set = 5 + 2 * Nkmax * Cknum; @@ -139,17 +139,17 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, double PI = M_PI; for (int i = 0; i < V; i++) { int x = (i % Nx) + PR->nx * Nx; - int y = (int)(i / Nx) % PR->y + PR->ny * PR->y; - int z = (int)(i / (Nx * PR->y)) + PR->nz * PR->z; + int y = static_cast(i / Nx) % PR->y + PR->ny * PR->y; + int z = static_cast(i / (Nx * PR->y)) + PR->nz * PR->z; for (int k = -Nkmax + 1; k < Nkmax; k++) { // max(kx+kk)=Nkkmax-1 + // Nkxmax-1 - double phase = 2.0 * PI * x * k / (double)Nkxmax; // kx!=0,ky=kz=0 + double phase = (2.0 * PI * x * k) / Nkxmax; // kx!=0,ky=kz=0 complex phase_c(0.0, phase); EXPrk[theta(i, k, 0)] = exp(phase_c); - phase = 2.0 * PI * (x + y + z) * k / (double)Nkxmax; // kx=ky + phase = (2.0 * PI * (x + y + z) * k) / Nkxmax; // kx=ky phase_c = complex(0.0, phase); EXPrk[theta(i, k, 1)] = exp(phase_c); } @@ -233,9 +233,9 @@ void Quantities::Measure(int Nv, int Nk, vector &ev, //////////////////////// MCsum_S(); - //#ifdef CFOUT + // #ifdef CFOUT MCsum_L(); - //#endif + // #endif //////////////////////// } @@ -266,17 +266,16 @@ void Quantities::Average(double *g, int Nval, int S, double *MCmean, error += g[(k + i * S) / kstep] * g[(k + i * S) / kstep]; } - mean /= (double)Nval; - error /= (double)Nval; + mean /= Nval; + error /= Nval; MCmean[k] = mean; MCmean[k + 1] = - (Nval == 1) ? 0 : sqrt((error - mean * mean) / (double)(Nval - 1.0)); + (Nval == 1) ? 0 : sqrt((error - mean * mean) / (Nval - 1)); } } -void Quantities::show_S(ofstream &F) { //Ä̾ï - +void Quantities::show_S(ofstream &F) { int S = Nq * 2; for (int k = 0; k < S; k += 2) @@ -388,8 +387,8 @@ void Quantities::show_L() { F << setprecision(16); for (int l = 0; l < Lmax[ck2]; l++) { R = l % Nkxmax; - Ry = ((int)(l / Nkxmax) % 2) * R; - ll = ((bool)(l / Nkmax)) ? "imag" : "real"; + Ry = (static_cast(l / Nkxmax) % 2) * R; + ll = (static_cast(l / Nkmax)) ? "imag" : "real"; k = f_nk(l) * 2; Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(Ry * Nkstep); F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] @@ -405,7 +404,7 @@ void Quantities::show_L() { for (int l = 0; l < Lmax[ck4]; l++) { k = f_gk2(l) * 2; R = l % Nkxmax; - R_ = (int)(l / Nkxmax) % Nkkmax; + R_ = static_cast(l / Nkxmax) % Nkkmax; bool kl = l / (Nkkmax * Nkxmax); ll = (kl) ? "imag" : "real"; // real or imag Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(R_ * Nkstep); @@ -424,7 +423,7 @@ void Quantities::show_L() { for (int l = 0; l < Lmax[dkk]; l++) { k = f_noise(l) * 2; R = l % Nkxmax; - R_ = (int)(l / Nkxmax); + R_ = l / Nkxmax; ll = "real"; Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(R_ * Nkstep); F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] @@ -464,16 +463,15 @@ void Quantities::show(ofstream &F, FILE *SFF) { } } -////// void Quantities::Output(std::string const &fname, double g) { std::ofstream file(fname.c_str(), std::ios::app); file << sp->Htr << " " << sp->mu << " " << sp->Vb1 << " " << sp->tb << " " << N->B << " " << g << std::endl; } -//########################################################################################## +// ########################################################################################## -//*******************TYPEA************************ +// *******************TYPEA************************ void Quantities::WindingNumber(vector &ev, int mcs) { int Wi[3] = {0, 0, 0}; @@ -495,8 +493,8 @@ void Quantities::WindingNumber(vector &ev, int mcs) { } for (int d = 0; d < N->d; d++) { - values_S[wndx + d] = (double)Wi[d]; - } //(double)NL[d]; } + values_S[wndx + d] = Wi[d]; + } // (double)NL[d]; } } void Quantities::WindingNumber2() { @@ -544,14 +542,14 @@ void Quantities::Compressibility() { MCmean_S[comp * 2] = N->B * N->V * (MCmean_S[smzu * 2] / - (MCmean_S[amzu * 2] * MCmean_S[amzu * 2] * (double)N->V) - + (MCmean_S[amzu * 2] * MCmean_S[amzu * 2] * N->V) - 1.0); MCmean_S[comp * 2 + 1] = MCmean_S[comp * 2] * MCmean_S[comp * 2]; } void Quantities::Energy() { MCmean_S[ene * 2] = - (sp->Eu + sp->Et - MCmean_S[nver * 2] / N->B) / (double)N->V; + (sp->Eu + sp->Et - MCmean_S[nver * 2] / N->B) / N->V; MCmean_S[ene * 2 + 1] = MCmean_S[ene * 2] * MCmean_S[ene * 2]; } @@ -563,7 +561,7 @@ void Quantities::SpecificHeat() { MCmean_S[spe * 2] = (MCmean_S[nver * 2 + 1] - MCmean_S[nver * 2] * MCmean_S[nver * 2] - MCmean_S[nver * 2]) / - (double)N->V; + N->V; MCmean_S[spe * 2 + 1] = MCmean_S[spe * 2] * MCmean_S[spe * 2]; } @@ -596,7 +594,7 @@ void Quantities::Susceptibility() { lx += MCmean_L[f_nw2(i)]; } - MCmean_S[lxmx * 2] = lx / (double)V; + MCmean_S[lxmx * 2] = lx / V; MCmean_S[lxmx * 2 + 1] = MCmean_S[lxmx * 2] * MCmean_S[lxmx * 2]; MCmean_S[xmx * 2] = @@ -632,7 +630,6 @@ void Quantities::CorrelationLength(double length) { values_S[len] = length; } void Quantities::SUM_OVER_T() { if (PR->nt == 0) { // Sum over t - for (int tag = 1; tag < PR->Ntdiv; tag++) { MPI_Recv(m_val, V * 2, MPI_DOUBLE, tag + PR->nt0, 0, MPI_COMM_WORLD, &status); @@ -653,7 +650,6 @@ void Quantities::SUM_OVER_T() { void Quantities::SUM_OVER_S() { if (PR->ns == 0) { // Sum over s at same tau - double Norm = PR->Ntdiv; for (int tag = 1; tag < PR->Nsdiv; tag++) { @@ -681,7 +677,6 @@ void Quantities::SUM_OVER_S() { void Quantities::SUM_OVER_ST() { if (PR->nst == 0) { // Sum over t and s - for (int tag = 1; tag < PR->NtNs; tag++) { MPI_Recv(m_val, Nq1, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, &status); @@ -694,17 +689,16 @@ void Quantities::SUM_OVER_ST() { MPI_Send(values_S, Nq1, MPI_DOUBLE, PR->nst0, 0, MPI_COMM_WORLD); } - values_S[xmzu] = values_S[bmzu] * values_S[bmzu] / (double)N->V; - values_S[xmzs] = values_S[xmzs] * values_S[xmzs] / (double)N->V; - values_S[smzu] /= (double)N->V; - values_S[smzs] /= (double)N->V; - values_S[amzu] /= (double)N->V; - values_S[bmzu] /= (double)N->V; + values_S[xmzu] = values_S[bmzu] * values_S[bmzu] / N->V; + values_S[xmzs] = values_S[xmzs] * values_S[xmzs] / N->V; + values_S[smzu] /= N->V; + values_S[smzs] /= N->V; + values_S[amzu] /= N->V; + values_S[bmzu] /= N->V; } void Quantities::CorrelationFunction1() { // real space - - //***MPI sum for G + // ***MPI sum for G double ntot = 0.0; int Lcr2 = Lmax[cr2]; int ixmax = Lcr2 / PR->Nxdiv; @@ -713,7 +707,6 @@ void Quantities::CorrelationFunction1() { // real space for (int i = 0; i < Lcr2; i++) values_L[f_gf(i)] = 0.0; if (PR->nx == 0) { // Sum over x at same tau - for (int i = 0; i < ixmax; i++) { int ixx = i * Nxstep; this->Q[i] = an[ixx]; @@ -755,7 +748,6 @@ void Quantities::CorrelationFunction1() { // real space } if (PR->nst == 0) { // Sum over t at x=0 - for (int tag = 1; tag < PR->NtNs; tag++) { if ((tag / PR->Ntdiv) % PR->Nxdiv != 0) continue; @@ -775,11 +767,11 @@ void Quantities::CorrelationFunction2( MPI_Status status; complex Nk2; - ////G2/// + // G2 for (int i = 0; i < Nk_set; i++) Ck[i] = complex(0.0, 0.0); - double rootV = sqrt((double)N->V); + double rootV = sqrt(static_cast(N->V)); double rootV2 = N->V; double rootV3 = rootV2 * rootV; double rootV4 = rootV2 * rootV2; @@ -831,7 +823,6 @@ void Quantities::CorrelationFunction2( } if (PR->ns == 0) { // Sum over site at same tau - for (int tag = 1; tag < PR->Nsdiv; tag++) { MPI_Recv(Ck_m, Nk_set + Sk_set, MPI_DOUBLE_COMPLEX, tag * PR->Ntdiv + PR->ns0, 0, MPI_COMM_WORLD, &status); @@ -841,7 +832,7 @@ void Quantities::CorrelationFunction2( ///////////////// Gk ////////////////////// for (int a = 0; a < 2; a++) { for (int k = 0; k < Nkxmax; k++) { - Nk2 = (Ck[f_ck(k, 0, a)] * Ck[f_ck(k, 1, a)] - Ck[0]) / (double)N->V; + Nk2 = (Ck[f_ck(k, 0, a)] * Ck[f_ck(k, 1, a)] - Ck[0]) / static_cast(N->V); values_L[f_nkr(k + a * Nkxmax)] = real(Nk2); values_L[f_nki(k + a * Nkxmax)] = imag(Nk2); } @@ -854,15 +845,12 @@ void Quantities::CorrelationFunction2( MPI_COMM_WORLD); } - // complex Gk2, Dkkk; if (PR->ns == 0) { for (int kx = 0; kx < Nkxmax; - kx++) { //(kx,ky,kz)=(0~Nkmax,0,0); (0~Nkmax,kx,kx) - + kx++) { // (kx,ky,kz)=(0~Nkmax,0,0); (0~Nkmax,kx,kx) for (int kk = 0; kk < Nkkmax; - kk++) { //(k'x,k'y,k'z)=(0,0,0);...(depends on CKK)...; (kx,ky,kz) - + kk++) { // (k'x,k'y,k'z)=(0,0,0);...(depends on CKK)...; (kx,ky,kz) Gk2 = Ck[f_ck(kx, 0)] * Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 0)] * Ck[f_ck(kk, 1)] @@ -906,7 +894,7 @@ void Quantities::CorrelationFunction2( Dkkk = Gk2; // vol2; - // for(int kky=0; kky<1; kky++){ //ky=kky= 0 or kx(kkx) + // for(int kky=0; kky<1; kky++){ //ky=kky= 0 or kx(kkx) values_L[f_gk2r(kx, kk)] = real(Dkkk); values_L[f_gk2i(kx, kk)] = imag(Dkkk); // } @@ -918,14 +906,13 @@ void Quantities::CorrelationFunction2( int L3 = Lmax[ck2] + Lmax[ck4]; // for nk, gk2 if (PR->nst == 0) { // Sum over t=0 - for (int tag = 1; tag < PR->Ntdiv; tag++) { MPI_Recv(m_val, L3, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, &status); for (int i = 0; i < L3; i++) values_L[f_nk(i)] += m_val[i]; } - for (int i = 0; i < L3; i++) values_L[f_nk(i)] /= (double)PR->Ntdiv; + for (int i = 0; i < L3; i++) values_L[f_nk(i)] /= PR->Ntdiv; } else if (PR->ns == 0) { // Ntdiv prosessors for nk, gf2, gk2 MPI_Send(&(values_L[f_nk(0)]), L3, MPI_DOUBLE, PR->nst0, 0, MPI_COMM_WORLD); @@ -946,12 +933,12 @@ void Quantities::NoiseCorrelation() { } #endif -//****MC sum +// MC sum void Quantities::MCsum_S() { if (PR->nst == 0) { for (int i = 0; i < Nq1; i++) { - MCmean_S[2 * i] += values_S[i] / (double)MC->Nsample; - MCmean_S[2 * i + 1] += values_S[i] * values_S[i] / (double)MC->Nsample; + MCmean_S[2 * i] += values_S[i] / MC->Nsample; + MCmean_S[2 * i + 1] += values_S[i] * values_S[i] / MC->Nsample; } } } @@ -961,7 +948,7 @@ void Quantities::MCsum_SF() { for (int isf = 0; isf < NKMAX; isf++) for (int it = 0; it < Ntau; it++) MCmean_SF[2 * isf][it] += - sfsamp[isf][it] / (double)N->V / (double)MC->Nsample; + sfsamp[isf][it] / static_cast(N->V * MC->Nsample); } #endif @@ -970,13 +957,13 @@ void Quantities::MCsum_L() { if (PR->nt == 0) { for (int i = 0; i < ltoc; i++) { - MCmean_L[i] += values_L[i] / (double)MC->Nsample; + MCmean_L[i] += values_L[i] / MC->Nsample; } } if (PR->nst == 0) { for (int i = ltoc; i < Lsize; i++) { - MCmean_L[i] += values_L[i] / (double)MC->Nsample; + MCmean_L[i] += values_L[i] / MC->Nsample; } } } diff --git a/src/pmwa/quantities.H.cpp b/src/pmwa/quantities.H.cpp index a08f4e0c..99a2c129 100644 --- a/src/pmwa/quantities.H.cpp +++ b/src/pmwa/quantities.H.cpp @@ -1,9 +1,9 @@ -//#include +// #include #include -//#define REWEIGHT -//#define KSTEPALL -//#define XSTEPALL -//#include +// #define REWEIGHT +// #define KSTEPALL +// #define XSTEPALL +// #include Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Parallel *m_PR, std::string const &sfinfile) { @@ -29,7 +29,7 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, NL[1] = N->y; NL[2] = N->z; - SFD_Norm = (double)N->V * N->B * sp->tb * 2.0 * N->d; + SFD_Norm = N->V * N->B * sp->tb * 2.0 * N->d; NVMAX = 0; NWMAX = 0; @@ -60,13 +60,13 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, Lsum[mz] = Lmax[mz] = V; Lmax[cr2] = Nxmax; - // Lmax[sk]=Nkmax*2;//i.e. real and imaginary part + // Lmax[sk]=Nkmax*2;//i.e. real and imaginary part Lmax[ck2] = Nkmax * 2; - //#ifdef GF22Gk2 - // Lmax[cr4]=N->x*N->x; - //#else - // Lmax[cr4]=Nxmax*PR->Nxdiv; - //#endif + // #ifdef GF22Gk2 + // Lmax[cr4]=N->x*N->x; + // #else + // Lmax[cr4]=Nxmax*PR->Nxdiv; + // #endif Lmax[ck4] = Nkxmax * Nkkmax * 2; Lmax[dkk] = Nkxmax * Nkkmax; Lmax[nw] = V; @@ -132,7 +132,7 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, newcall_zero(BINmean_L, Lsize * MC->Nbin); // newcall_zero(RNDmean_L,Lsize*PR->Npara); - newcall_zero(m_val, max(Lsize, (int)Nq)); + newcall_zero(m_val, max(Lsize, static_cast(Nq))); newcall_zero(EXPrk, 4 * Nkmax * V); @@ -146,17 +146,17 @@ Quantities::Quantities(Size *m_N, MC_p *m_MC, System *m_sp, Lattice *m_LT, double PI = M_PI; for (int i = 0; i < V; i++) { int x = (i % Nx) + PR->nx * Nx; - int y = (int)(i / Nx) % PR->y + PR->ny * PR->y; - int z = (int)(i / (Nx * PR->y)) + PR->nz * PR->z; + int y = static_cast(i / Nx) % PR->y + PR->ny * PR->y; + int z = static_cast(i / (Nx * PR->y)) + PR->nz * PR->z; for (int k = -Nkmax + 1; k < Nkmax; k++) { // max(kx+kk)=Nkkmax-1 + // Nkxmax-1 - double phase = 2.0 * PI * x * k / (double)Nkxmax; // kx!=0,ky=kz=0 + double phase = 2.0 * PI * x * k / Nkxmax; // kx!=0,ky=kz=0 complex phase_c(0.0, phase); EXPrk[theta(i, k, 0)] = exp(phase_c); - phase = 2.0 * PI * (x + y + z) * k / (double)Nkxmax; // kx=ky + phase = 2.0 * PI * (x + y + z) * k / Nkxmax; // kx=ky phase_c = complex(0.0, phase); EXPrk[theta(i, k, 1)] = exp(phase_c); } @@ -237,7 +237,7 @@ void Quantities::read_sf() { int Nline = X["NumberOfElements"].getInteger(); - dtau = PR->B / (double)Ntau1; // in preparation for temporal pararellization + dtau = PR->B / Ntau1; // in preparation for temporal pararellization Ntau = X["CutoffOfNtau"].getInteger(); NKMAX = X["NumberOfInverseLattice"].getInteger(); @@ -273,7 +273,7 @@ void Quantities::read_sf() { << endl; exit(0); } -}; +} #endif void Quantities::Measure(int Nv, int Nk, vector &ev, @@ -351,8 +351,8 @@ void Quantities::BINaverage() { #ifdef SF for (int i = 0; i < NKMAX; i++) for (int it = 0; it < Ntau; it++) { - double mean = BINmean_SF[2 * i][it] / (double)MC->Nbin; - double smean = BINmean_SF[2 * i + 1][it] / (double)MC->Nbin; + double mean = BINmean_SF[2 * i][it] / MC->Nbin; + double smean = BINmean_SF[2 * i + 1][it] / MC->Nbin; double num = (MC->Nbin == 1) ? 1.0 : MC->Nbin - 1.0; BINmean_SF[2 * i][it] = mean; BINmean_SF[2 * i + 1][it] = sqrt((smean - mean * mean) / num); @@ -377,16 +377,15 @@ void Quantities::Average(double *g, int Nval, int S, double *MCmean, error += g[(k + i * S) / kstep] * g[(k + i * S) / kstep]; } - mean /= (double)Nval; - error /= (double)Nval; + mean /= Nval; + error /= Nval; MCmean[k] = mean; MCmean[k + 1] = (Nval == 1) ? 0 : sqrt((error - mean * mean) / num); } } -void Quantities::show_S(ofstream &F) { //Ä̾ï - +void Quantities::show_S(ofstream &F) { int S = Nq * 2; for (int k = 0; k < S; k += 2) @@ -498,8 +497,8 @@ void Quantities::show_L() { F << setprecision(16); for (int l = 0; l < Lmax[ck2]; l++) { R = l % Nkxmax; - Ry = ((int)(l / Nkxmax) % 2) * R; - ll = ((bool)(l / Nkmax)) ? "imag" : "real"; + Ry = (static_cast(l / Nkxmax) % 2) * R; + ll = (static_cast(l / Nkmax)) ? "imag" : "real"; k = f_nk(l) * 2; Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(Ry * Nkstep); F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] @@ -515,7 +514,7 @@ void Quantities::show_L() { for (int l = 0; l < Lmax[ck4]; l++) { k = f_gk2(l) * 2; R = l % Nkxmax; - R_ = (int)(l / Nkxmax) % Nkkmax; + R_ = static_cast(l / Nkxmax) % Nkkmax; bool kl = l / (Nkkmax * Nkxmax); ll = (kl) ? "imag" : "real"; // real or imag Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(R_ * Nkstep); @@ -534,7 +533,7 @@ void Quantities::show_L() { for (int l = 0; l < Lmax[dkk]; l++) { k = f_noise(l) * 2; R = l % Nkxmax; - R_ = (int)(l / Nkxmax); + R_ = static_cast(l / Nkxmax); ll = "real"; Cname = ll + "_" + tostr(R * Nkstep) + "_" + tostr(R_ * Nkstep); F << "R " << Cname << " = " << MCmean_L[k] << " " << MCmean_L[k + 1] @@ -568,9 +567,7 @@ void Quantities::Output(std::string const &fname, double g) { << N->B << " " << g << endl; } -//########################################################################################## - -//*******************TYPEA************************ +// *******************TYPEA************************ void Quantities::WindingNumber(vector &ev, int mcs) { int Wi[3] = {0, 0, 0}; @@ -592,8 +589,8 @@ void Quantities::WindingNumber(vector &ev, int mcs) { } for (int d = 0; d < N->d; d++) { - values_S[wndx + d] = (double)Wi[d]; - } //(double)NL[d]; } + values_S[wndx + d] = Wi[d]; + } // (double)NL[d]; } } void Quantities::WindingNumber2() { @@ -666,7 +663,7 @@ void Quantities::Density(GraphSpace::Vertex *world, SZKT += counter4SFC[k][tt] * counter4SFC[k][(tt + it) % Ntau1] + counter4SFS[k][tt] * counter4SFS[k][(tt + it) % Ntau1]; } - sfsamp[k][it] = SZKT / (double)Ntau1; + sfsamp[k][it] = SZKT / static_cast(double>(Ntau1); } } @@ -676,15 +673,13 @@ void Quantities::Density(GraphSpace::Vertex *world, void Quantities::Compressibility() { MCmean_S[comp * 2] = N->B * N->V * - (MCmean_S[smzu * 2] / - (MCmean_S[amzu * 2] * MCmean_S[amzu * 2] * (double)N->V) - + (MCmean_S[smzu * 2] / (MCmean_S[amzu * 2] * MCmean_S[amzu * 2] * N->V) - 1.0); MCmean_S[comp * 2 + 1] = MCmean_S[comp * 2] * MCmean_S[comp * 2]; } void Quantities::Energy() { - MCmean_S[ene * 2] = - (sp->Eu + sp->Et - MCmean_S[nver * 2] / N->B) / (double)N->V; + MCmean_S[ene * 2] = (sp->Eu + sp->Et - MCmean_S[nver * 2] / N->B) / N->V; MCmean_S[ene * 2 + 1] = MCmean_S[ene * 2] * MCmean_S[ene * 2]; } @@ -696,7 +691,7 @@ void Quantities::SpecificHeat() { MCmean_S[spe * 2] = (MCmean_S[nver * 2 + 1] - MCmean_S[nver * 2] * MCmean_S[nver * 2] - MCmean_S[nver * 2]) / - (double)N->V; + N->V; MCmean_S[spe * 2 + 1] = MCmean_S[spe * 2] * MCmean_S[spe * 2]; } @@ -735,7 +730,7 @@ void Quantities::Susceptibility() { lx += MCmean_L[f_nw2(i)]; } - MCmean_S[lxmx * 2] = lx / (double)V; + MCmean_S[lxmx * 2] = lx / V; MCmean_S[lxmx * 2 + 1] = MCmean_S[lxmx * 2] * MCmean_S[lxmx * 2]; #endif @@ -768,8 +763,7 @@ void Quantities::CondensateFraction(int mcs, GraphSpace::Vertex *world) { void Quantities::CorrelationLength(double length) { values_S[len] = length; } -//////////////////////////////////// -//***MC average +// ***MC average void Quantities::Average() { #ifdef REWEIGHT @@ -788,8 +782,8 @@ void Quantities::Average() { #ifdef REWEIGHT } - MCmean_S[ang * 2] /= (double)MC->Nsample; - MCmean_S[ang * 2 + 1] /= (double)MC->Nsample; + MCmean_S[ang * 2] /= MC->Nsample; + MCmean_S[ang * 2 + 1] /= MC->Nsample; #endif #ifdef CFOUT @@ -803,7 +797,7 @@ void Quantities::Average() { #endif } -//****MC sum +// ****MC sum void Quantities::MCsum_S() { if (PR->nst == 0) { for (int i = 0; i < Nq1; i++) { @@ -828,9 +822,9 @@ void Quantities::MCsum_SF() { for (int isf = 0; isf < NKMAX; isf++) for (int it = 0; it < Ntau; it++) #ifdef REWEIGHT - MCmean_SF[2 * isf][it] += sfsamp[isf][it] * values_S[ang] / (double)N->V; + MCmean_SF[2 * isf][it] += sfsamp[isf][it] * values_S[ang] / N->V; #else - MCmean_SF[2 * isf][it] += sfsamp[isf][it] / (double)N->V; + MCmean_SF[2 * isf][it] += sfsamp[isf][it] / N->V; #endif } #endif @@ -862,7 +856,6 @@ void Quantities::MCsum_L() { //////////////////////////////////// void Quantities::SUM_OVER_T() { if (PR->nt == 0) { // Sum over t - for (int tag = 1; tag < PR->Ntdiv; tag++) { MPI_Recv(m_val, V * 2, MPI_DOUBLE, tag + PR->nt0, 0, MPI_COMM_WORLD, &status); @@ -882,7 +875,6 @@ void Quantities::SUM_OVER_T() { void Quantities::SUM_OVER_S() { if (PR->ns == 0) { // Sum over s at same tau - double Norm = PR->Ntdiv; for (int tag = 1; tag < PR->Nsdiv; tag++) { @@ -908,7 +900,6 @@ void Quantities::SUM_OVER_S() { void Quantities::SUM_OVER_ST() { if (PR->nst == 0) { // Sum over t and s - for (int tag = 1; tag < PR->NtNs; tag++) { MPI_Recv(m_val, Nq1, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, &status); @@ -921,17 +912,16 @@ void Quantities::SUM_OVER_ST() { MPI_Send(values_S, Nq1, MPI_DOUBLE, PR->nst0, 0, MPI_COMM_WORLD); } - values_S[xmzu] = values_S[bmzu] * values_S[bmzu] / (double)N->V; - values_S[xmzs] = values_S[xmzs] * values_S[xmzs] / (double)N->V; - values_S[smzu] /= (double)N->V; - values_S[smzs] /= (double)N->V; - values_S[amzu] /= (double)N->V; - values_S[bmzu] /= (double)N->V; + values_S[xmzu] = values_S[bmzu] * values_S[bmzu] / N->V; + values_S[xmzs] = values_S[xmzs] * values_S[xmzs] / N->V; + values_S[smzu] /= N->V; + values_S[smzs] /= N->V; + values_S[amzu] /= N->V; + values_S[bmzu] /= N->V; } void Quantities::CorrelationFunction1() { // real space - - //***MPI sum for G + // ***MPI sum for G double ntot = 0.0; int Lcr2 = Lmax[cr2]; int ixmax = Lcr2 / PR->Nxdiv; @@ -940,7 +930,6 @@ void Quantities::CorrelationFunction1() { // real space for (int i = 0; i < Lcr2; i++) values_L[f_gf(i)] = 0.0; if (PR->nx == 0) { // Sum over x at same tau - for (int i = 0; i < ixmax; i++) { int ixx = i * Nxstep; this->Q[i] = an[ixx]; @@ -982,7 +971,6 @@ void Quantities::CorrelationFunction1() { // real space } if (PR->nst == 0) { // Sum over t at x=0 - for (int tag = 1; tag < PR->NtNs; tag++) { if ((tag / PR->Ntdiv) % PR->Nxdiv != 0) continue; @@ -1002,12 +990,12 @@ void Quantities::CorrelationFunction2( MPI_Status status; complex Nk2; - ////G2/// + // //G2/// for (int i = 0; i < Nk_set; i++) Ck[i] = complex(0.0, 0.0); - double rootV = sqrt((double)N->V); double rootV2 = N->V; + double rootV = sqrt(rootV2); double rootV3 = rootV2 * rootV; double rootV4 = rootV2 * rootV2; @@ -1058,7 +1046,6 @@ void Quantities::CorrelationFunction2( } if (PR->ns == 0) { // Sum over site at same tau - for (int tag = 1; tag < PR->Nsdiv; tag++) { MPI_Recv(Ck_m, Nk_set + Sk_set, MPI_DOUBLE_COMPLEX, tag * PR->Ntdiv + PR->ns0, 0, MPI_COMM_WORLD, &status); @@ -1068,7 +1055,7 @@ void Quantities::CorrelationFunction2( ///////////////// Gk ////////////////////// for (int a = 0; a < 2; a++) { for (int k = 0; k < Nkxmax; k++) { - Nk2 = (Ck[f_ck(k, 0, a)] * Ck[f_ck(k, 1, a)] - Ck[0]) / (double)N->V; + Nk2 = (Ck[f_ck(k, 0, a)] * Ck[f_ck(k, 1, a)] - Ck[0]) / static_cast(N->V); values_L[f_nkr(k + a * Nkxmax)] = real(Nk2); values_L[f_nki(k + a * Nkxmax)] = imag(Nk2); } @@ -1089,11 +1076,9 @@ void Quantities::CorrelationFunction2( complex Gk2, Dkkk; if (PR->ns == 0) { for (int kx = 0; kx < Nkxmax; - kx++) { //(kx,ky,kz)=(0~Nkmax,0,0); (0~Nkmax,kx,kx) - + kx++) { // (kx,ky,kz)=(0~Nkmax,0,0); (0~Nkmax,kx,kx) for (int kk = 0; kk < Nkkmax; - kk++) { //(k'x,k'y,k'z)=(0,0,0);...(depends on CKK)...; (kx,ky,kz) - + kk++) { // (k'x,k'y,k'z)=(0,0,0);...(depends on CKK)...; (kx,ky,kz) Gk2 = Ck[f_ck(kx, 0)] * Ck[f_ck(kx, 1)] * Ck[f_ck(kk, 0)] * Ck[f_ck(kk, 1)] @@ -1137,7 +1122,7 @@ void Quantities::CorrelationFunction2( Dkkk = Gk2; // vol2; - // for(int kky=0; kky<1; kky++){ //ky=kky= 0 or kx(kkx) + // for(int kky=0; kky<1; kky++){ //ky=kky= 0 or kx(kkx) values_L[f_gk2r(kx, kk)] = real(Dkkk); values_L[f_gk2i(kx, kk)] = imag(Dkkk); // } @@ -1149,14 +1134,13 @@ void Quantities::CorrelationFunction2( int L3 = Lmax[ck2] + Lmax[ck4]; // for nk, gk2 if (PR->nst == 0) { // Sum over t=0 - for (int tag = 1; tag < PR->Ntdiv; tag++) { MPI_Recv(m_val, L3, MPI_DOUBLE, tag + PR->nst0, 0, MPI_COMM_WORLD, &status); for (int i = 0; i < L3; i++) values_L[f_nk(i)] += m_val[i]; } - for (int i = 0; i < L3; i++) values_L[f_nk(i)] /= (double)PR->Ntdiv; + for (int i = 0; i < L3; i++) values_L[f_nk(i)] /= PR->Ntdiv; } else if (PR->ns == 0) { // Ntdiv prosessors for nk, gf2, gk2 MPI_Send(&(values_L[f_nk(0)]), L3, MPI_DOUBLE, PR->nst0, 0, MPI_COMM_WORLD); diff --git a/src/pmwa/sfgene.cc b/src/pmwa/sfgene.cc index a3e884ae..3c907bc1 100644 --- a/src/pmwa/sfgene.cc +++ b/src/pmwa/sfgene.cc @@ -38,15 +38,15 @@ void WriteXML(int D, int L[], int Ntau, int CutoffOfNtau, int KTYPE) { } int KMAX; - if (KTYPE == 0) + if (KTYPE == 0) { KMAX = L[0] / 2 + 1; - else if (KTYPE == 1) + } else if (KTYPE == 1) { KMAX = 4; - else if (KTYPE == 2) + } else if (KTYPE == 2) { KMAX = 3; - else if (KTYPE == 3) + } else if (KTYPE == 3) { KMAX = 3; - else { + } else { cout << " available KTYPE=0: kx/pi = n/L, n=0,2, 4,,,, L"; cout << " available KTYPE=1: k/pi = (1,0),(1,1),(0,1),(1/2,1/2)"; cout << " available KTYPE=2: AFMBZ"; @@ -107,9 +107,9 @@ void WriteXML(int D, int L[], int Ntau, int CutoffOfNtau, int KTYPE) { for (int q = 0; q < KMAX; q++) { int rx = i % L[0]; double phase; - if (KTYPE == 0) - phase = rx * ksite[q] * PI / (double)L[0]; // r_x * q_x - else if (KTYPE == 1) { + if (KTYPE == 0) { + phase = rx * ksite[q] * PI / L[0]; // r_x * q_x + } else if (KTYPE == 1) { int ry = (i / L[0]) % L[1]; double qx; double qy; From 269bfa15fbf4a93870568bac67fc0416cc7e7a7c Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Fri, 5 Feb 2021 10:40:51 +0900 Subject: [PATCH 03/54] change default of nvermax and nsegmax to 100000 from 10000 --- doc/en/dla/users-manual/input_expert.rst | 4 ++-- doc/jp/dla/users-manual/input_expert.rst | 4 ++-- src/dla/parameter.hpp | 4 ++-- tool/dsqss/parameter.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/en/dla/users-manual/input_expert.rst b/doc/en/dla/users-manual/input_expert.rst index 7bec3964..ae84b0e2 100644 --- a/doc/en/dla/users-manual/input_expert.rst +++ b/doc/en/dla/users-manual/input_expert.rst @@ -45,8 +45,8 @@ The list of parameters are the following, nset, int, 10, "The number of Monte Carlo sets." simulationtime, double, 0.0, "Simulation time in second." seed, int, 198212240, "The seed of the random number generator." - nvermax, int, 10000, "The maximum number of vertices." - nsegmax, int, 10000, "The maximum number of world-line segments." + nvermax, int, 100000, "The maximum number of vertices." + nsegmax, int, 100000, "The maximum number of world-line segments." algfile, string, algorithm.xml, "The filename of an algorithm file." latfile, string, lattice.xml, "The filename of a lattice file." ntau, int, 10, "The number of the discretization of the imaginary time for calculating some observables as functions of imaginary time." diff --git a/doc/jp/dla/users-manual/input_expert.rst b/doc/jp/dla/users-manual/input_expert.rst index da4f0fe2..f9cf1238 100644 --- a/doc/jp/dla/users-manual/input_expert.rst +++ b/doc/jp/dla/users-manual/input_expert.rst @@ -49,8 +49,8 @@ DSQSS/DLA のエキスパートモード入力ファイルは, DSQSS/DLA の実 nset, int, 10, "モンテカルロ計算の繰り返し数." simulationtime, int, 0.0, "計算時間(単位は秒)." seed, int, 198212240, "疑似乱数の種." - nvermax, int, 10000, "最大バーテックス数." - nsegmax, int, 10000, "最大セグメント数." + nvermax, int, 100000, "最大バーテックス数." + nsegmax, int, 100000, "最大セグメント数." algfile, int, algorithm.xml, "アルゴリズム定義ファイル名." latfile, string, lattice.xml, "格子定義ファイル名." ntau, int, 10, "虚時間構造因子などの計算で使われる虚時間方向の離散化数." diff --git a/src/dla/parameter.hpp b/src/dla/parameter.hpp index 5ae04b93..231ab827 100644 --- a/src/dla/parameter.hpp +++ b/src/dla/parameter.hpp @@ -208,8 +208,8 @@ void Parameter::init(std::map& dict) { dict["ntherm"] = "1000"; dict["simulationtime"] = "0.0"; dict["seed"] = "198212240"; - dict["nvermax"] = "10000"; - dict["nsegmax"] = "10000"; + dict["nvermax"] = "100000"; + dict["nsegmax"] = "100000"; dict["ntau"] = 10; dict["algfile"] = "algorithm.xml"; dict["latfile"] = "lattice.xml"; diff --git a/tool/dsqss/parameter.py b/tool/dsqss/parameter.py index 772e237e..d9733fd7 100644 --- a/tool/dsqss/parameter.py +++ b/tool/dsqss/parameter.py @@ -34,8 +34,8 @@ def set_default_values(param): ("simulationtime", 0.0), ("ntau", 10), ("seed", 198212240), - ("nvermax", 10000), - ("nsegmax", 10000), + ("nvermax", 100000), + ("nsegmax", 100000), ("algfile", "algorithm.xml"), ("latfile", "lattice.xml"), ("wvfile", ""), From 793c468f14055a31a437ee24a15f20ca87ec4eb5 Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Fri, 5 Feb 2021 17:00:38 +0900 Subject: [PATCH 04/54] Squashed commit of the following: commit 2e0a0fa59f0ee4411e6532b9268e22be1383becd Author: Yuichi Motoyama Date: Fri Feb 5 16:45:11 2021 +0900 fix script for preparing LaTeX env commit 534b7ff00526ab75611884a50ce302174a80fa63 Author: Yuichi Motoyama Date: Fri Feb 5 16:08:56 2021 +0900 rerun commit 257315ed1380ac4a37d6f19a464485aa6235a315 Author: Yuichi Motoyama Date: Fri Feb 5 16:03:01 2021 +0900 make PDF docs commit 86b1759c485993f64562fe505bf0f0e07275726e Author: Yuichi Motoyama Date: Fri Feb 5 12:28:30 2021 +0900 fix path commit 538f28151f54a40beb7a2dc773692ae0c06dee63 Author: Yuichi Motoyama Date: Fri Feb 5 12:17:41 2021 +0900 fix path commit 97b99fbe2f6e0356dd3742c4ada276b95e50115c Author: Yuichi Motoyama Date: Fri Feb 5 12:06:34 2021 +0900 fix a typo commit 901989a9473f34675a0234cad34087b7cc49bc5c Author: Yuichi Motoyama Date: Fri Feb 5 11:39:40 2021 +0900 deploy docs via GHActions commit b52b9e93356ec7750e18a0d4743d40e204b90b8e Author: Yuichi Motoyama Date: Fri Feb 5 11:22:56 2021 +0900 Use GitHubActions --- .github/workflows/deploy_docs.yml | 90 ++++++++++++++++++++++++++++++ .github/workflows/main.yml | 43 ++++++++++++++ .travis.yml | 29 ---------- .travis_scripts/deploy_docs.sh | 39 ------------- .travis_scripts/make_tarball.sh | 11 ---- .travis_scripts/ssh_key.enc | Bin 1872 -> 0 bytes 6 files changed, 133 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/deploy_docs.yml create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml delete mode 100644 .travis_scripts/deploy_docs.sh delete mode 100644 .travis_scripts/make_tarball.sh delete mode 100644 .travis_scripts/ssh_key.enc diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml new file mode 100644 index 00000000..737823f2 --- /dev/null +++ b/.github/workflows/deploy_docs.yml @@ -0,0 +1,90 @@ +name: deploy + +on: + push: + branches: + - master + - develop + - ghactions + - '!gh-pages' + tags: ['*'] + +jobs: + deploy: + runs-on: ubuntu-20.04 + steps: + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v3.x + + - name: Checkout + uses: actions/checkout@v2 + with: + path: main + + - name: Checkout gh-pages + uses: actions/checkout@v2 + with: + ref: gh-pages + path: gh-pages + + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Prepare LaTeX env + run: | + sudo apt install \ + texlive-latex-recommended texlive-latex-extra \ + texlive-lang-japanese texlive-fonts-recommended texlive-fonts-extra latexmk + kanji-config-updmap-sys ipaex + + - name: Install python packages + run: | + python -m pip install --upgrade pip + pip install sphinx + + - name: Build + run: | + cd ${GITHUB_WORKSPACE}/main/ + cmake -E make_directory build + cd build + cmake -DDocument=ON ../ + make doc + + - name: Deploy Configuration + run: | + mkdir ~/.ssh + ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts + echo "${{ secrets.GH_ACTIONS_DEPLOY_KEY }}" > ~/.ssh/id_rsa + chmod 400 ~/.ssh/id_rsa + + - name: Push + env: + GIT_USER: "DSQSS Developers" + GIT_EMAIL: "dsqss-dev@issp.u-tokyo.ac.jp" + TARGET_NAME: ${{ env.GITHUB_REF_SLUG }} + run: | + cd ${GITHUB_WORKSPACE} + is_tag=NO + test "_$(echo ${GITHUB_REF:-'//'} | cut -d/ -f2)" = "_tags" && is_tag=YES + for lang in jp en; do + rm -rf "gh-pages/manual/${TARGET_NAME}/${lang}" + mkdir -p "gh-pages/manual/${TARGET_NAME}" + cp -r "main/build/doc/${lang}/html" "gh-pages/manual/${TARGET_NAME}/${lang}" + if [ $is_tag = "YES" ]; then + cp "main/build/doc/${lang}/pdf/DSQSS.pdf" "gh-pages/manual/${TARGET_NAME}/${lang}/DSQSS.pdf" + fi + done + cd gh-pages + git config --local user.name "${GIT_USER}" + git config --local user.email "${GIT_EMAIL}" + git remote set-url origin git@github.com:${GITHUB_REPOSITORY}.git + git add manual + if git commit -m "Deploy docs to ${TARGET_NAME} by GitHub Actions triggered by ${GITHUB_SHA}" + then + git push origin gh-pages + else + echo "Nothing to deploy" + fi + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..4783d793 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,43 @@ +name: Test + +on: [push] + +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: apt + run: | + sudo apt install \ + gcc gfortran cmake wget liblapack-dev \ + openmpi-bin libopenmpi-dev + + - name: pip install + run: | + python -m pip install -U pip + + - name: make workspace + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: cmake + working-directory: ${{runner.workspace}}/build + shell: bash + run: cmake -DCMAKE_VERBOSE_MAKEFILE=1 $GITHUB_WORKSPACE + + - name: build + working-directory: ${{runner.workspace}}/build + shell: bash + run: cmake --build ./ + + - name: ctest + working-directory: ${{runner.workspace}}/build + shell: bash + run: ctest -V diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7eda4b16..00000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -os: linux -dist: xenial -language: cpp -sudo: enabled - -install: - - export ROOTDIR=`pwd` - - sudo apt-get update - - sudo apt-get install -y gcc gfortran cmake wget liblapack-dev - - sudo apt-get install -y libopenmpi-dev openmpi-bin - - sudo apt-get install -y python-pip - - sudo apt-get install -y enchant - - | - sudo apt-get install -y texlive-latex-recommended texlive-latex-extra \ - texlive-lang-japanese texlive-fonts-recommended texlive-fonts-extra latexmk - - kanji-config-updmap-sys ipaex - - pyenv global 3.7.1 - - pip3 install -U pip -script: - - cd ${ROOTDIR} - - mkdir build - - cd build - - cmake -DDocument=ON ../ - - VERBOSE=1 make - - export OMP_NUM_THREADS=1 - - ctest -VV -after_success: - - cd ${ROOTDIR} - - /bin/bash -x ${ROOTDIR}/.travis_scripts/deploy_docs.sh diff --git a/.travis_scripts/deploy_docs.sh b/.travis_scripts/deploy_docs.sh deleted file mode 100644 index cf86eec5..00000000 --- a/.travis_scripts/deploy_docs.sh +++ /dev/null @@ -1,39 +0,0 @@ -## rewrite TODO sections for your project - -# This is a pull request, finish. -if [ "_$TRAVIS_PULL_REQUEST" != "_false" ] ;then exit 0; fi -# This is neither master nor tag, finish. -if [ "_$TRAVIS_BRANCH" != "_master" ] && [ -z "$TRAVIS_TAG" ] ; then exit 0; fi - -## TODO -git config --global user.email "dsqss-dev@issp.u-tokyo.ac.jp" -git config --global user.name "DSQSS" - -openssl aes-256-cbc -K $encrypted_1f4d0afdd3c2_key -iv $encrypted_1f4d0afdd3c2_iv -in ${ROOTDIR}/.travis_scripts/ssh_key.enc -out ~/.ssh/id_rsa -d - -chmod 600 ~/.ssh/id_rsa -echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config -git remote set-url origin git@github.com:${TRAVIS_REPO_SLUG} -git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" -git fetch --unshallow origin -git checkout gh-pages - - -## TODO -DOCDIR=manual/${TRAVIS_BRANCH} -mkdir -p ${DOCDIR} -rm -rf ${DOCDIR} -mkdir -p ${DOCDIR}/jp/ -mkdir -p ${DOCDIR}/en/ -cp -r build/doc/jp/html/* ${DOCDIR}/jp -cp -r build/doc/en/html/* ${DOCDIR}/en -cp -r build/doc/jp/pdf/DSQSS.pdf ${DOCDIR}/jp/DSQSS-${TRAVIS_BRANCH}.pdf -cp -r build/doc/en/pdf/DSQSS.pdf ${DOCDIR}/en/DSQSS-${TRAVIS_BRANCH}.pdf -git add ${DOCDIR} -git commit -m "Update by TravisCI (${TRAVIS_BUILD_ID})" -ST=$? -if [ $ST == 0 ]; then - git push origin gh-pages:gh-pages --follow-tags > /dev/null 2>&1 -fi - -git checkout master diff --git a/.travis_scripts/make_tarball.sh b/.travis_scripts/make_tarball.sh deleted file mode 100644 index b9b6a461..00000000 --- a/.travis_scripts/make_tarball.sh +++ /dev/null @@ -1,11 +0,0 @@ -# This is not for tag, finish -if [ -z "$TRAVIS_TAG" ]; then exit 0; fi - -DIRNAME=DSQSS-${TRAVIS_TAG} -wget https://github.com/${TRAVIS_REPO_SLUG}/archive/${TRAVIS_TAG}.tar.gz -O tarball.tar.gz -mkdir $DIRNAME -tar -xz -C $DIRNAME --strip-components=1 -f tarball.tar.gz -cp -r build/doc/jp/pdf/DSQSS.pdf ${DIRNAME}/DSQSS-jp-${TRAVIS_TAG}.pdf -cp -r build/doc/en/pdf/DSQSS.pdf ${DIRNAME}/DSQSS-en-${TRAVIS_TAG}.pdf -tar czf ${DIRNAME}.tar.gz ${DIRNAME} -rm tarball.tar.gz diff --git a/.travis_scripts/ssh_key.enc b/.travis_scripts/ssh_key.enc deleted file mode 100644 index b1b3e2ceb398468ce86585b5433b117c1d3d1837..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1872 zcmV-W2e0^o3QV)myKyOm_zI7@=I_18Qsl-K{5-fa>e5pw;`lL*scu<9x@fzcPG>nP z!!b3^Su{89TLFSnKvgpb2Pv!eJi87SBQijRAD_g|#<6HF9+JDY3{ct8wBrAqob5m> zi@+W3;QSWKl5Y`aAtGfyI+pJrj|ucZZF@U{&)y>yWVu3tzk0mW_Itm4_6Brais73c zpu5CHRt6U}!#okEJW2mh%|Zm~X?%-O8(PQO4moH(D4%?GN<3R1&6bEsq?P5rRmfr` z@B^!X+TKI8Z|^u`q%OrMMH}F1%557Z{{KX`yN3Knm;Gm72L2?p4PS9-wKvKb;_r}z z!;Hc4ARu%Bc*^BVyfK^ler0kBD7!2-+-F={0D6>jqDE#5ZmGVikVCc=*ce74sDtVF9)F2ld!>_dgVfk)D<>6va!S}y1$8C_!LZJ@~%}(^4#sJyG zblU+Xrw2qA{A}b{V=7D}vS?pHo2a?^k!aH{voR9eLCmViy}G6sD3R{TSL+9Uek>4u zPx4mcDc$P15RmYL~q)fuP6{8y9%! zqsFxG0~YPCKSh%|Cvnf)Km(nQu5@ggUM|x>k;;DHQ=J<{B1q6 z<Hm;$D6b}9N7MG&+}J4 zoA=tF-;x#eBIcMborUU4!JN|Ah>zQUq9?ysQT+Pe4hw|fc$d=$Dv?>81RreR*-pJ1 zMUAkXn?-&@;_2WY%4obGaBu4jCsI|870&huPdPx;>ul1=B{YIVuaY=UQ%Y?(e1DEF zD$)!xKA=SgLYxe4SYSw&@Hn?I7$G&h=UiDsq-cOud!?#cD~OA3AU1gM@k<19yrI~I zEBPFOd243AAUoj(g>5bC)afH72#8Qz(_faowlxh==ePs6+Os=%{T>0tOIv%!)gMs7 zytiNS>($ue{1CiuKodA__;I~mXawPoGyB;v^XeIrTOHmAcj29Rq4=Q%}-jV+_YxZ zC@0fXC-TJ%;^Zb8CLd?-cQLWH;cFWP^4)Yy#gdpYrf!Et2=LPW34+LXjARA?mkv zkk9e-TO1@Ij{t%i{r8|Z;C6zqsinv^L+?VpphghE7)%0OK>60OFnuI%NL+2|&~XB# zt(z1+2n*_dFhThZ039&Gk|pg>5x|{B#{%bH@lCTj2P59kHgIkc>7gNOu*zkdzndDW zbvx1)SFilk})sBl4ao`x5l}MLZiO^ts*@i6IEIuN)Pj)%U8COcFda%_?7Uzf=kP#Q^mz Date: Sat, 6 Feb 2021 17:19:10 +0900 Subject: [PATCH 05/54] Enable to calculate limited displacement pairs (#30) --- src/dla/cf.hpp | 8 +- src/dla/displacement.hpp | 21 +- .../boost/container/allocator_traits.hpp | 477 ++ .../boost/container/detail/config_begin.hpp | 53 + .../boost/container/detail/config_end.hpp | 13 + .../boost/boost/container/detail/mpl.hpp | 86 + .../boost/container/detail/placement_new.hpp | 30 + .../boost/container/detail/type_traits.hpp | 70 + .../boost/container/detail/workaround.hpp | 111 + .../container_hash/detail/float_functions.hpp | 336 ++ .../container_hash/detail/hash_float.hpp | 271 + .../boost/container_hash/detail/limits.hpp | 62 + .../boost/boost/container_hash/extensions.hpp | 414 ++ .../boost/boost/container_hash/hash.hpp | 761 +++ .../boost/boost/container_hash/hash_fwd.hpp | 36 + .../boost/boost/core/pointer_traits.hpp | 233 + .../boost/boost/detail/container_fwd.hpp | 157 + .../boost/boost/detail/select_type.hpp | 36 + .../boost/boost/functional/hash.hpp | 6 + .../boost/boost/functional/hash_fwd.hpp | 6 + .../boost/boost/integer/static_log2.hpp | 127 + .../boost/intrusive/detail/config_begin.hpp | 43 + .../boost/intrusive/detail/config_end.hpp | 15 + .../has_member_function_callable_with.hpp | 366 ++ .../boost/boost/intrusive/detail/mpl.hpp | 216 + .../boost/intrusive/detail/workaround.hpp | 53 + .../boost/boost/intrusive/pointer_rebind.hpp | 188 + .../boost/boost/intrusive/pointer_traits.hpp | 318 ++ .../boost/boost/move/algo/move.hpp | 156 + .../boost/boost/move/algorithm.hpp | 167 + .../boost/boost/move/detail/fwd_macros.hpp | 881 +++ .../move/detail/iterator_to_raw_pointer.hpp | 59 + .../boost/move/detail/iterator_traits.hpp | 77 + .../boost/move/detail/pointer_element.hpp | 168 + .../boost/move/detail/to_raw_pointer.hpp | 45 + src/third-party/boost/boost/move/iterator.hpp | 311 ++ src/third-party/boost/boost/move/move.hpp | 35 + .../boost/boost/pointer_to_other.hpp | 55 + .../boost/boost/tuple/detail/tuple_basic.hpp | 987 ++++ src/third-party/boost/boost/tuple/tuple.hpp | 67 + .../boost/boost/type_traits/add_cv.hpp | 47 + .../boost/boost/type_traits/cv_traits.hpp | 24 + .../type_traits/is_nothrow_swappable.hpp | 67 + .../boost/type_traits/remove_volatile.hpp | 39 + .../boost/boost/unordered/detail/fwd.hpp | 63 + .../boost/unordered/detail/implementation.hpp | 4952 +++++++++++++++++ .../boost/boost/unordered/detail/map.hpp | 67 + .../boost/boost/unordered/unordered_map.hpp | 2589 +++++++++ .../boost/unordered/unordered_map_fwd.hpp | 64 + src/third-party/boost/boost/unordered_map.hpp | 19 + src/third-party/boost/boost/utility/swap.hpp | 17 + 51 files changed, 15461 insertions(+), 8 deletions(-) create mode 100644 src/third-party/boost/boost/container/allocator_traits.hpp create mode 100644 src/third-party/boost/boost/container/detail/config_begin.hpp create mode 100644 src/third-party/boost/boost/container/detail/config_end.hpp create mode 100644 src/third-party/boost/boost/container/detail/mpl.hpp create mode 100644 src/third-party/boost/boost/container/detail/placement_new.hpp create mode 100644 src/third-party/boost/boost/container/detail/type_traits.hpp create mode 100644 src/third-party/boost/boost/container/detail/workaround.hpp create mode 100644 src/third-party/boost/boost/container_hash/detail/float_functions.hpp create mode 100644 src/third-party/boost/boost/container_hash/detail/hash_float.hpp create mode 100644 src/third-party/boost/boost/container_hash/detail/limits.hpp create mode 100644 src/third-party/boost/boost/container_hash/extensions.hpp create mode 100644 src/third-party/boost/boost/container_hash/hash.hpp create mode 100644 src/third-party/boost/boost/container_hash/hash_fwd.hpp create mode 100644 src/third-party/boost/boost/core/pointer_traits.hpp create mode 100644 src/third-party/boost/boost/detail/container_fwd.hpp create mode 100644 src/third-party/boost/boost/detail/select_type.hpp create mode 100644 src/third-party/boost/boost/functional/hash.hpp create mode 100644 src/third-party/boost/boost/functional/hash_fwd.hpp create mode 100644 src/third-party/boost/boost/integer/static_log2.hpp create mode 100644 src/third-party/boost/boost/intrusive/detail/config_begin.hpp create mode 100644 src/third-party/boost/boost/intrusive/detail/config_end.hpp create mode 100644 src/third-party/boost/boost/intrusive/detail/has_member_function_callable_with.hpp create mode 100644 src/third-party/boost/boost/intrusive/detail/mpl.hpp create mode 100644 src/third-party/boost/boost/intrusive/detail/workaround.hpp create mode 100644 src/third-party/boost/boost/intrusive/pointer_rebind.hpp create mode 100644 src/third-party/boost/boost/intrusive/pointer_traits.hpp create mode 100644 src/third-party/boost/boost/move/algo/move.hpp create mode 100644 src/third-party/boost/boost/move/algorithm.hpp create mode 100644 src/third-party/boost/boost/move/detail/fwd_macros.hpp create mode 100644 src/third-party/boost/boost/move/detail/iterator_to_raw_pointer.hpp create mode 100644 src/third-party/boost/boost/move/detail/iterator_traits.hpp create mode 100644 src/third-party/boost/boost/move/detail/pointer_element.hpp create mode 100644 src/third-party/boost/boost/move/detail/to_raw_pointer.hpp create mode 100644 src/third-party/boost/boost/move/iterator.hpp create mode 100644 src/third-party/boost/boost/move/move.hpp create mode 100644 src/third-party/boost/boost/pointer_to_other.hpp create mode 100644 src/third-party/boost/boost/tuple/detail/tuple_basic.hpp create mode 100644 src/third-party/boost/boost/tuple/tuple.hpp create mode 100644 src/third-party/boost/boost/type_traits/add_cv.hpp create mode 100644 src/third-party/boost/boost/type_traits/cv_traits.hpp create mode 100644 src/third-party/boost/boost/type_traits/is_nothrow_swappable.hpp create mode 100644 src/third-party/boost/boost/type_traits/remove_volatile.hpp create mode 100644 src/third-party/boost/boost/unordered/detail/fwd.hpp create mode 100644 src/third-party/boost/boost/unordered/detail/implementation.hpp create mode 100644 src/third-party/boost/boost/unordered/detail/map.hpp create mode 100644 src/third-party/boost/boost/unordered/unordered_map.hpp create mode 100644 src/third-party/boost/boost/unordered/unordered_map_fwd.hpp create mode 100644 src/third-party/boost/boost/unordered_map.hpp create mode 100644 src/third-party/boost/boost/utility/swap.hpp diff --git a/src/dla/cf.hpp b/src/dla/cf.hpp index 558b64d7..b6c06c85 100644 --- a/src/dla/cf.hpp +++ b/src/dla/cf.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "accumulator.hpp" #include "algorithm.hpp" @@ -147,7 +148,12 @@ void CF::count(double tT, double bT, int head_site, int tail_site, } AutoDebugDump("CF::count"); - int icf = DISP.IR[tail_site][head_site]; + std::pair key = std::make_pair(tail_site, head_site); + Displacement::IR_iterator iter = DISP.IR.find(key); + if (iter == DISP.IR.end()) { + return; + } + int icf = DISP.IR[key]; double bTr = tail_tau - tT; double tTr = tail_tau - bT; diff --git a/src/dla/displacement.hpp b/src/dla/displacement.hpp index 1c474dec..b4f1a355 100644 --- a/src/dla/displacement.hpp +++ b/src/dla/displacement.hpp @@ -22,6 +22,10 @@ #include #include #include +#include + +#include +#include #include "accumulator.hpp" #include "debug.hpp" @@ -33,8 +37,15 @@ struct Displacement { int NSITES; int nkinds; - std::vector NR; // the number of pairs with the same dR - std::vector > IR; // IR[isite][jsite] == disp_index + std::vector NR; // the number of pairs with the same dR + // std::vector > IR; // IR[isite][jsite] == disp_index + + // IR[std::make_pair(isite,jsite)] == disp_index + typedef boost::unordered_map, int, + boost::hash > > + IR_type; + typedef IR_type::iterator IR_iterator; + IR_type IR; explicit Displacement(Parameter const& param); void read(XML::Block const& X); @@ -52,17 +63,13 @@ Displacement::Displacement(Parameter const& param) NR.resize(nkinds, 0); - for (int i = 0; i < NSITES; i++) { - IR.push_back(std::vector(NSITES, nkinds)); - } - for (int i = 0; i < X.NumberOfBlocks(); i++) { XML::Block& B = X[i]; if (B.getName() == "R") { int kind = B.getInteger(0); int isite = B.getInteger(1); int jsite = B.getInteger(2); - IR[isite][jsite] = kind; + IR[std::make_pair(isite, jsite)] = kind; NR[kind]++; } } diff --git a/src/third-party/boost/boost/container/allocator_traits.hpp b/src/third-party/boost/boost/container/allocator_traits.hpp new file mode 100644 index 00000000..af32f182 --- /dev/null +++ b/src/third-party/boost/boost/container/allocator_traits.hpp @@ -0,0 +1,477 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Pablo Halpern 2009. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP +#define BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include +#include + +// container +#include +#include +#include //is_empty +#include +#ifndef BOOST_CONTAINER_DETAIL_STD_FWD_HPP +#include +#endif +// intrusive +#include +#include +// move +#include +// move/detail +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif +// other boost +#include + +#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME allocate +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace dtl { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 2 +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 2 +#include + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME destroy +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace dtl { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1 +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 1 +#include + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME construct +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace dtl { +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1 +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 9 +#include + +#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + +namespace boost { +namespace container { + +#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + +template +class small_vector_allocator; + +namespace allocator_traits_detail { + +BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_max_size, max_size) +BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_select_on_container_copy_construction, select_on_container_copy_construction) + +} //namespace allocator_traits_detail { + +namespace dtl { + +//workaround needed for C++03 compilers with no construct() +//supporting rvalue references +template +struct is_std_allocator +{ static const bool value = false; }; + +template +struct is_std_allocator< std::allocator > +{ static const bool value = true; }; + +template +struct is_std_allocator< small_vector_allocator< std::allocator > > +{ static const bool value = true; }; + +template +struct is_not_std_allocator +{ static const bool value = !is_std_allocator::value; }; + +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer) +BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference) +BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(void_pointer) +BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_void_pointer) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(is_always_equal) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(is_partially_propagable) + +} //namespace dtl { + +#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED + +//! The class template allocator_traits supplies a uniform interface to all allocator types. +//! This class is a C++03-compatible implementation of std::allocator_traits +template +struct allocator_traits +{ + //allocator_type + typedef Allocator allocator_type; + //value_type + typedef typename allocator_type::value_type value_type; + + #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! Allocator::pointer if such a type exists; otherwise, value_type* + //! + typedef unspecified pointer; + //! Allocator::const_pointer if such a type exists ; otherwise, pointer_traits::rebind::rebind. + //! + typedef see_documentation void_pointer; + //! Allocator::const_void_pointer if such a type exists ; otherwis e, pointer_traits::rebind::difference_type. + //! + typedef see_documentation difference_type; + //! Allocator::size_type if such a type exists ; otherwise, make_unsigned::type + //! + typedef see_documentation size_type; + //! Allocator::propagate_on_container_copy_assignment if such a type exists, otherwise a type + //! with an internal constant static boolean member value == false. + typedef see_documentation propagate_on_container_copy_assignment; + //! Allocator::propagate_on_container_move_assignment if such a type exists, otherwise a type + //! with an internal constant static boolean member value == false. + typedef see_documentation propagate_on_container_move_assignment; + //! Allocator::propagate_on_container_swap if such a type exists, otherwise a type + //! with an internal constant static boolean member value == false. + typedef see_documentation propagate_on_container_swap; + //! Allocator::is_always_equal if such a type exists, otherwise a type + //! with an internal constant static boolean member value == is_empty::value + typedef see_documentation is_always_equal; + //! Allocator::is_partially_propagable if such a type exists, otherwise a type + //! with an internal constant static boolean member value == false + //! Note: Non-standard extension used to implement `small_vector_allocator`. + typedef see_documentation is_partially_propagable; + //! Defines an allocator: Allocator::rebind::other if such a type exists; otherwise, Allocator + //! if Allocator is a class template instantiation of the form Allocator, where Args is zero or + //! more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed. + //! + //! In C++03 compilers rebind_alloc is a struct derived from an allocator + //! deduced by previously detailed rules. + template using rebind_alloc = see_documentation; + + //! In C++03 compilers rebind_traits is a struct derived from + //! allocator_traits, where OtherAlloc is + //! the allocator deduced by rules explained in rebind_alloc. + template using rebind_traits = allocator_traits >; + + //! Non-standard extension: Portable allocator rebind for C++03 and C++11 compilers. + //! type is an allocator related to Allocator deduced deduced by rules explained in rebind_alloc. + template + struct portable_rebind_alloc + { typedef see_documentation type; }; + #else + //pointer + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, Allocator, + pointer, value_type*) + pointer; + //const_pointer + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::dtl::, Allocator, + const_pointer, typename boost::intrusive::pointer_traits::template + rebind_pointer) + const_pointer; + //reference + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, Allocator, + reference, typename dtl::unvoid_ref::type) + reference; + //const_reference + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, Allocator, + const_reference, typename dtl::unvoid_ref::type) + const_reference; + //void_pointer + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::dtl::, Allocator, + void_pointer, typename boost::intrusive::pointer_traits::template + rebind_pointer) + void_pointer; + //const_void_pointer + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::dtl::, Allocator, + const_void_pointer, typename boost::intrusive::pointer_traits::template + rebind_pointer) + const_void_pointer; + //difference_type + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, Allocator, + difference_type, std::ptrdiff_t) + difference_type; + //size_type + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, Allocator, + size_type, std::size_t) + size_type; + //propagate_on_container_copy_assignment + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, Allocator, + propagate_on_container_copy_assignment, dtl::false_type) + propagate_on_container_copy_assignment; + //propagate_on_container_move_assignment + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, Allocator, + propagate_on_container_move_assignment, dtl::false_type) + propagate_on_container_move_assignment; + //propagate_on_container_swap + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, Allocator, + propagate_on_container_swap, dtl::false_type) + propagate_on_container_swap; + //is_always_equal + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, Allocator, + is_always_equal, dtl::is_empty) + is_always_equal; + //is_partially_propagable + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::dtl::, Allocator, + is_partially_propagable, dtl::false_type) + is_partially_propagable; + + //rebind_alloc & rebind_traits + #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + //C++11 + template using rebind_alloc = typename boost::intrusive::pointer_rebind::type; + template using rebind_traits = allocator_traits< rebind_alloc >; + #else // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + //Some workaround for C++03 or C++11 compilers with no template aliases + template + struct rebind_alloc : boost::intrusive::pointer_rebind::type + { + typedef typename boost::intrusive::pointer_rebind::type Base; + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + template + rebind_alloc(BOOST_FWD_REF(Args)... args) : Base(boost::forward(args)...) {} + #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + #define BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC(N) \ + BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\ + explicit rebind_alloc(BOOST_MOVE_UREF##N) : Base(BOOST_MOVE_FWD##N){}\ + // + BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC) + #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC + #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + }; + + template + struct rebind_traits + : allocator_traits::type> + {}; + #endif // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + + //portable_rebind_alloc + template + struct portable_rebind_alloc + { typedef typename boost::intrusive::pointer_rebind::type type; }; + #endif //BOOST_CONTAINER_DOXYGEN_INVOKED + + //! Returns: a.allocate(n) + //! + BOOST_CONTAINER_FORCEINLINE static pointer allocate(Allocator &a, size_type n) + { return a.allocate(n); } + + //! Returns: a.deallocate(p, n) + //! + //! Throws: Nothing + BOOST_CONTAINER_FORCEINLINE static void deallocate(Allocator &a, pointer p, size_type n) + { a.deallocate(p, n); } + + //! Effects: calls a.allocate(n, p) if that call is well-formed; + //! otherwise, invokes a.allocate(n) + BOOST_CONTAINER_FORCEINLINE static pointer allocate(Allocator &a, size_type n, const_void_pointer p) + { + const bool value = boost::container::dtl:: + has_member_function_callable_with_allocate + ::value; + dtl::bool_ flag; + return allocator_traits::priv_allocate(flag, a, n, p); + } + + //! Effects: calls a.destroy(p) if that call is well-formed; + //! otherwise, invokes p->~T(). + template + BOOST_CONTAINER_FORCEINLINE static void destroy(Allocator &a, T*p) BOOST_NOEXCEPT_OR_NOTHROW + { + typedef T* destroy_pointer; + const bool value = boost::container::dtl:: + has_member_function_callable_with_destroy + ::value; + dtl::bool_ flag; + allocator_traits::priv_destroy(flag, a, p); + } + + //! Returns: a.max_size() if that expression is well-formed; otherwise, + //! numeric_limits::max(). + BOOST_CONTAINER_FORCEINLINE static size_type max_size(const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW + { + const bool value = allocator_traits_detail::has_max_size::value; + dtl::bool_ flag; + return allocator_traits::priv_max_size(flag, a); + } + + //! Returns: a.select_on_container_copy_construction() if that expression is well-formed; + //! otherwise, a. + BOOST_CONTAINER_FORCEINLINE static BOOST_CONTAINER_DOC1ST(Allocator, + typename dtl::if_c + < allocator_traits_detail::has_select_on_container_copy_construction::value + BOOST_MOVE_I Allocator BOOST_MOVE_I const Allocator & >::type) + select_on_container_copy_construction(const Allocator &a) + { + const bool value = allocator_traits_detail::has_select_on_container_copy_construction + ::value; + dtl::bool_ flag; + return allocator_traits::priv_select_on_container_copy_construction(flag, a); + } + + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + //! Effects: calls a.construct(p, std::forward(args)...) if that call is well-formed; + //! otherwise, invokes `placement new` (static_cast(p)) T(std::forward(args)...) + template + BOOST_CONTAINER_FORCEINLINE static void construct(Allocator & a, T* p, BOOST_FWD_REF(Args)... args) + { + static const bool value = ::boost::move_detail::and_ + < dtl::is_not_std_allocator + , boost::container::dtl::has_member_function_callable_with_construct + < Allocator, T*, Args... > + >::value; + dtl::bool_ flag; + allocator_traits::priv_construct(flag, a, p, ::boost::forward(args)...); + } + #endif + + //! Returns: a.storage_is_unpropagable(p) if is_partially_propagable::value is true; otherwise, + //! false. + BOOST_CONTAINER_FORCEINLINE static bool storage_is_unpropagable(const Allocator &a, pointer p) BOOST_NOEXCEPT_OR_NOTHROW + { + dtl::bool_ flag; + return allocator_traits::priv_storage_is_unpropagable(flag, a, p); + } + + //! Returns: true if is_always_equal::value == true, otherwise, + //! a == b. + BOOST_CONTAINER_FORCEINLINE static bool equal(const Allocator &a, const Allocator &b) BOOST_NOEXCEPT_OR_NOTHROW + { + dtl::bool_ flag; + return allocator_traits::priv_equal(flag, a, b); + } + + #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) + private: + BOOST_CONTAINER_FORCEINLINE static pointer priv_allocate(dtl::true_type, Allocator &a, size_type n, const_void_pointer p) + { return a.allocate(n, p); } + + BOOST_CONTAINER_FORCEINLINE static pointer priv_allocate(dtl::false_type, Allocator &a, size_type n, const_void_pointer) + { return a.allocate(n); } + + template + BOOST_CONTAINER_FORCEINLINE static void priv_destroy(dtl::true_type, Allocator &a, T* p) BOOST_NOEXCEPT_OR_NOTHROW + { a.destroy(p); } + + template + BOOST_CONTAINER_FORCEINLINE static void priv_destroy(dtl::false_type, Allocator &, T* p) BOOST_NOEXCEPT_OR_NOTHROW + { p->~T(); (void)p; } + + BOOST_CONTAINER_FORCEINLINE static size_type priv_max_size(dtl::true_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW + { return a.max_size(); } + + BOOST_CONTAINER_FORCEINLINE static size_type priv_max_size(dtl::false_type, const Allocator &) BOOST_NOEXCEPT_OR_NOTHROW + { return size_type(-1)/sizeof(value_type); } + + BOOST_CONTAINER_FORCEINLINE static Allocator priv_select_on_container_copy_construction(dtl::true_type, const Allocator &a) + { return a.select_on_container_copy_construction(); } + + BOOST_CONTAINER_FORCEINLINE static const Allocator &priv_select_on_container_copy_construction(dtl::false_type, const Allocator &a) BOOST_NOEXCEPT_OR_NOTHROW + { return a; } + + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + template + BOOST_CONTAINER_FORCEINLINE static void priv_construct(dtl::true_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args) + { a.construct( p, ::boost::forward(args)...); } + + template + BOOST_CONTAINER_FORCEINLINE static void priv_construct(dtl::false_type, Allocator &, T *p, BOOST_FWD_REF(Args) ...args) + { ::new((void*)p, boost_container_new_t()) T(::boost::forward(args)...); } + #else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + public: + + #define BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL(N) \ + template\ + BOOST_CONTAINER_FORCEINLINE static void construct(Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + {\ + static const bool value = ::boost::move_detail::and_ \ + < dtl::is_not_std_allocator \ + , boost::container::dtl::has_member_function_callable_with_construct \ + < Allocator, T* BOOST_MOVE_I##N BOOST_MOVE_FWD_T##N > \ + >::value; \ + dtl::bool_ flag;\ + (priv_construct)(flag, a, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ + }\ + // + BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL) + #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL + + private: + ///////////////////////////////// + // priv_construct + ///////////////////////////////// + #define BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL(N) \ + template\ + BOOST_CONTAINER_FORCEINLINE static void priv_construct(dtl::true_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + { a.construct( p BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); }\ + \ + template\ + BOOST_CONTAINER_FORCEINLINE static void priv_construct(dtl::false_type, Allocator &, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ + { ::new((void*)p, boost_container_new_t()) T(BOOST_MOVE_FWD##N); }\ + // + BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL) + #undef BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL + + #endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + template + BOOST_CONTAINER_FORCEINLINE static void priv_construct(dtl::false_type, Allocator &, T *p, const ::boost::container::default_init_t&) + { ::new((void*)p, boost_container_new_t()) T; } + + BOOST_CONTAINER_FORCEINLINE static bool priv_storage_is_unpropagable(dtl::true_type, const Allocator &a, pointer p) + { return a.storage_is_unpropagable(p); } + + BOOST_CONTAINER_FORCEINLINE static bool priv_storage_is_unpropagable(dtl::false_type, const Allocator &, pointer) + { return false; } + + BOOST_CONTAINER_FORCEINLINE static bool priv_equal(dtl::true_type, const Allocator &, const Allocator &) + { return true; } + + BOOST_CONTAINER_FORCEINLINE static bool priv_equal(dtl::false_type, const Allocator &a, const Allocator &b) + { return a == b; } + + #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED) +}; + +} //namespace container { +} //namespace boost { + +#include + +#endif // ! defined(BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP) diff --git a/src/third-party/boost/boost/container/detail/config_begin.hpp b/src/third-party/boost/boost/container/detail/config_begin.hpp new file mode 100644 index 00000000..4df9e35d --- /dev/null +++ b/src/third-party/boost/boost/container/detail/config_begin.hpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_CONFIG_INCLUDED +#define BOOST_CONTAINER_CONTAINER_DETAIL_CONFIG_INCLUDED +#ifndef BOOST_CONFIG_HPP +#include +#endif + +#endif //BOOST_CONTAINER_CONTAINER_DETAIL_CONFIG_INCLUDED + +#ifdef BOOST_MSVC + #pragma warning (push) + #pragma warning (disable : 4127) // conditional expression is constant + #pragma warning (disable : 4146) // unary minus operator applied to unsigned type, result still unsigned + #pragma warning (disable : 4197) // top-level volatile in cast is ignored + #pragma warning (disable : 4244) // possible loss of data + #pragma warning (disable : 4251) // "identifier" : class "type" needs to have dll-interface to be used by clients of class "type2" + #pragma warning (disable : 4267) // conversion from "X" to "Y", possible loss of data + #pragma warning (disable : 4275) // non DLL-interface classkey "identifier" used as base for DLL-interface classkey "identifier" + #pragma warning (disable : 4284) // odd return type for operator-> + #pragma warning (disable : 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) + #pragma warning (disable : 4324) // structure was padded due to __declspec(align( + #pragma warning (disable : 4345) // behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized + #pragma warning (disable : 4355) // "this" : used in base member initializer list + #pragma warning (disable : 4503) // "identifier" : decorated name length exceeded, name was truncated + #pragma warning (disable : 4510) // default constructor could not be generated + #pragma warning (disable : 4511) // copy constructor could not be generated + #pragma warning (disable : 4512) // assignment operator could not be generated + #pragma warning (disable : 4514) // unreferenced inline removed + #pragma warning (disable : 4521) // Disable "multiple copy constructors specified" + #pragma warning (disable : 4522) // "class" : multiple assignment operators specified + #pragma warning (disable : 4541) // 'typeid' used on polymorphic type '' with /GR-; unpredictable behavior may result + #pragma warning (disable : 4584) // X is already a base-class of Y + #pragma warning (disable : 4610) // struct can never be instantiated - user defined constructor required + #pragma warning (disable : 4671) // the copy constructor is inaccessible + #pragma warning (disable : 4673) // throwing '' the following types will not be considered at the catch site + #pragma warning (disable : 4675) // "method" should be declared "static" and have exactly one parameter + #pragma warning (disable : 4702) // unreachable code + #pragma warning (disable : 4706) // assignment within conditional expression + #pragma warning (disable : 4710) // function not inlined + #pragma warning (disable : 4714) // "function": marked as __forceinline not inlined + #pragma warning (disable : 4711) // function selected for automatic inline expansion + #pragma warning (disable : 4786) // identifier truncated in debug info + #pragma warning (disable : 4996) // "function": was declared deprecated + +#endif //BOOST_MSVC diff --git a/src/third-party/boost/boost/container/detail/config_end.hpp b/src/third-party/boost/boost/container/detail/config_end.hpp new file mode 100644 index 00000000..f93c8f6f --- /dev/null +++ b/src/third-party/boost/boost/container/detail/config_end.hpp @@ -0,0 +1,13 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// +#if defined BOOST_MSVC + #pragma warning (pop) +#endif + diff --git a/src/third-party/boost/boost/container/detail/mpl.hpp b/src/third-party/boost/boost/container/detail/mpl.hpp new file mode 100644 index 00000000..4bb3cc7d --- /dev/null +++ b/src/third-party/boost/boost/container/detail/mpl.hpp @@ -0,0 +1,86 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-2013. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP +#define BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include +#include +#include +#include + +#include + +namespace boost { +namespace container { +namespace dtl { + +using boost::move_detail::integral_constant; +using boost::move_detail::true_type; +using boost::move_detail::false_type; +using boost::move_detail::enable_if_c; +using boost::move_detail::enable_if; +using boost::move_detail::enable_if_convertible; +using boost::move_detail::disable_if_c; +using boost::move_detail::disable_if; +using boost::move_detail::disable_if_convertible; +using boost::move_detail::is_convertible; +using boost::move_detail::if_c; +using boost::move_detail::if_; +using boost::move_detail::identity; +using boost::move_detail::bool_; +using boost::move_detail::true_; +using boost::move_detail::false_; +using boost::move_detail::yes_type; +using boost::move_detail::no_type; +using boost::move_detail::bool_; +using boost::move_detail::true_; +using boost::move_detail::false_; +using boost::move_detail::unvoid_ref; +using boost::move_detail::and_; +using boost::move_detail::or_; +using boost::move_detail::not_; +using boost::move_detail::enable_if_and; +using boost::move_detail::disable_if_and; +using boost::move_detail::enable_if_or; +using boost::move_detail::disable_if_or; + +template +struct select1st +{ + typedef FirstType type; + + template + const type& operator()(const T& x) const + { return x.first; } + + template + type& operator()(T& x) + { return const_cast(x.first); } +}; + +} //namespace dtl { +} //namespace container { +} //namespace boost { + +#include + +#endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP + diff --git a/src/third-party/boost/boost/container/detail/placement_new.hpp b/src/third-party/boost/boost/container/detail/placement_new.hpp new file mode 100644 index 00000000..c50981f6 --- /dev/null +++ b/src/third-party/boost/boost/container/detail/placement_new.hpp @@ -0,0 +1,30 @@ +#ifndef BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP +#define BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP +/////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2015. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +struct boost_container_new_t{}; + +//avoid including +inline void *operator new(std::size_t, void *p, boost_container_new_t) +{ return p; } + +inline void operator delete(void *, void *, boost_container_new_t) +{} + +#endif //BOOST_CONTAINER_DETAIL_PLACEMENT_NEW_HPP diff --git a/src/third-party/boost/boost/container/detail/type_traits.hpp b/src/third-party/boost/boost/container/detail/type_traits.hpp new file mode 100644 index 00000000..686cc409 --- /dev/null +++ b/src/third-party/boost/boost/container/detail/type_traits.hpp @@ -0,0 +1,70 @@ +////////////////////////////////////////////////////////////////////////////// +// (C) Copyright John Maddock 2000. +// (C) Copyright Ion Gaztanaga 2005-2015. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +// The alignment and Type traits implementation comes from +// John Maddock's TypeTraits library. +// +// Some other tricks come from Howard Hinnant's papers and StackOverflow replies +////////////////////////////////////////////////////////////////////////////// +#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP +#define BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include + +namespace boost { +namespace container { +namespace dtl { + +using ::boost::move_detail::enable_if; +using ::boost::move_detail::enable_if_and; +using ::boost::move_detail::is_same; +using ::boost::move_detail::is_different; +using ::boost::move_detail::is_pointer; +using ::boost::move_detail::add_reference; +using ::boost::move_detail::add_const; +using ::boost::move_detail::add_const_reference; +using ::boost::move_detail::remove_const; +using ::boost::move_detail::remove_reference; +using ::boost::move_detail::make_unsigned; +using ::boost::move_detail::is_floating_point; +using ::boost::move_detail::is_integral; +using ::boost::move_detail::is_enum; +using ::boost::move_detail::is_pod; +using ::boost::move_detail::is_empty; +using ::boost::move_detail::is_trivially_destructible; +using ::boost::move_detail::is_trivially_default_constructible; +using ::boost::move_detail::is_trivially_copy_constructible; +using ::boost::move_detail::is_trivially_move_constructible; +using ::boost::move_detail::is_trivially_copy_assignable; +using ::boost::move_detail::is_trivially_move_assignable; +using ::boost::move_detail::is_nothrow_default_constructible; +using ::boost::move_detail::is_nothrow_copy_constructible; +using ::boost::move_detail::is_nothrow_move_constructible; +using ::boost::move_detail::is_nothrow_copy_assignable; +using ::boost::move_detail::is_nothrow_move_assignable; +using ::boost::move_detail::is_nothrow_swappable; +using ::boost::move_detail::alignment_of; +using ::boost::move_detail::aligned_storage; +using ::boost::move_detail::nat; +using ::boost::move_detail::max_align_t; + +} //namespace dtl { +} //namespace container { +} //namespace boost { + +#endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_TYPE_TRAITS_HPP diff --git a/src/third-party/boost/boost/container/detail/workaround.hpp b/src/third-party/boost/boost/container/detail/workaround.hpp new file mode 100644 index 00000000..736326b7 --- /dev/null +++ b/src/third-party/boost/boost/container/detail/workaround.hpp @@ -0,0 +1,111 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP +#define BOOST_CONTAINER_DETAIL_WORKAROUND_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)\ + && !defined(BOOST_INTERPROCESS_DISABLE_VARIADIC_TMPL) + #define BOOST_CONTAINER_PERFECT_FORWARDING +#endif + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && defined(__GXX_EXPERIMENTAL_CXX0X__)\ + && (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__ < 40700) + #define BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST +#endif + +#if defined(BOOST_GCC_VERSION) +# if (BOOST_GCC_VERSION < 40700) || !defined(BOOST_GCC_CXX11) +# define BOOST_CONTAINER_NO_CXX11_DELEGATING_CONSTRUCTORS +# endif +#elif defined(BOOST_MSVC) +# if _MSC_FULL_VER < 180020827 +# define BOOST_CONTAINER_NO_CXX11_DELEGATING_CONSTRUCTORS +# endif +#elif defined(BOOST_CLANG) +# if !__has_feature(cxx_delegating_constructors) +# define BOOST_CONTAINER_NO_CXX11_DELEGATING_CONSTRUCTORS +# endif +#endif + +#if defined(BOOST_MSVC) && (_MSC_VER < 1400) + #define BOOST_CONTAINER_TEMPLATED_CONVERSION_OPERATOR_BROKEN +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) || (defined(BOOST_MSVC) && (BOOST_MSVC == 1700 || BOOST_MSVC == 1600)) +#define BOOST_CONTAINER_PAIR_TEST_HAS_HEADER_TUPLE +#endif + +//Macros for documentation purposes. For code, expands to the argument +#define BOOST_CONTAINER_IMPDEF(TYPE) TYPE +#define BOOST_CONTAINER_SEEDOC(TYPE) TYPE + +//Macros for memset optimization. In most platforms +//memsetting pointers and floatings is safe and faster. +// +//If your platform does not offer these guarantees +//define these to value zero. +#ifndef BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_NOT_ZERO +#define BOOST_CONTAINER_MEMZEROED_FLOATING_POINT_IS_ZERO 1 +#endif + +#ifndef BOOST_CONTAINER_MEMZEROED_POINTER_IS_NOT_NULL +#define BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL +#endif + +#define BOOST_CONTAINER_DOC1ST(TYPE1, TYPE2) TYPE2 +#define BOOST_CONTAINER_I , +#define BOOST_CONTAINER_DOCIGN(T) T +#define BOOST_CONTAINER_DOCONLY(T) + +/* + we need to import/export our code only if the user has specifically + asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost + libraries to be dynamically linked, or BOOST_CONTAINER_DYN_LINK + if they want just this one to be dynamically liked: +*/ +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTAINER_DYN_LINK) + + /* export if this is our own source, otherwise import: */ + #ifdef BOOST_CONTAINER_SOURCE + # define BOOST_CONTAINER_DECL BOOST_SYMBOL_EXPORT + #else + # define BOOST_CONTAINER_DECL BOOST_SYMBOL_IMPORT + + #endif /* BOOST_CONTAINER_SOURCE */ +#else + #define BOOST_CONTAINER_DECL +#endif /* DYN_LINK */ + +//#define BOOST_CONTAINER_DISABLE_FORCEINLINE + +#if defined(BOOST_CONTAINER_DISABLE_FORCEINLINE) + #define BOOST_CONTAINER_FORCEINLINE inline +#elif defined(BOOST_CONTAINER_FORCEINLINE_IS_BOOST_FORCELINE) + #define BOOST_CONTAINER_FORCEINLINE BOOST_FORCEINLINE +#elif defined(BOOST_MSVC) && defined(_DEBUG) + //"__forceinline" and MSVC seems to have some bugs in debug mode + #define BOOST_CONTAINER_FORCEINLINE inline +#elif defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ < 5))) + //Older GCCs have problems with forceinline + #define BOOST_CONTAINER_FORCEINLINE inline +#else + #define BOOST_CONTAINER_FORCEINLINE BOOST_FORCEINLINE +#endif + +#endif //#ifndef BOOST_CONTAINER_DETAIL_WORKAROUND_HPP diff --git a/src/third-party/boost/boost/container_hash/detail/float_functions.hpp b/src/third-party/boost/boost/container_hash/detail/float_functions.hpp new file mode 100644 index 00000000..f3db52f9 --- /dev/null +++ b/src/third-party/boost/boost/container_hash/detail/float_functions.hpp @@ -0,0 +1,336 @@ + +// Copyright 2005-2009 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_FLOAT_FUNCTIONS_HPP) +#define BOOST_FUNCTIONAL_HASH_DETAIL_FLOAT_FUNCTIONS_HPP + +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + +#include + +// Set BOOST_HASH_CONFORMANT_FLOATS to 1 for libraries known to have +// sufficiently good floating point support to not require any +// workarounds. +// +// When set to 0, the library tries to automatically +// use the best available implementation. This normally works well, but +// breaks when ambiguities are created by odd namespacing of the functions. +// +// Note that if this is set to 0, the library should still take full +// advantage of the platform's floating point support. + +#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif defined(__LIBCOMO__) +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) +// Rogue Wave library: +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif defined(_LIBCPP_VERSION) +// libc++ +# define BOOST_HASH_CONFORMANT_FLOATS 1 +#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) +// GNU libstdc++ 3 +# if defined(__GNUC__) && __GNUC__ >= 4 +# define BOOST_HASH_CONFORMANT_FLOATS 1 +# else +# define BOOST_HASH_CONFORMANT_FLOATS 0 +# endif +#elif defined(__STL_CONFIG_H) +// generic SGI STL +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif defined(__MSL_CPP__) +// MSL standard lib: +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif defined(__IBMCPP__) +// VACPP std lib (probably conformant for much earlier version). +# if __IBMCPP__ >= 1210 +# define BOOST_HASH_CONFORMANT_FLOATS 1 +# else +# define BOOST_HASH_CONFORMANT_FLOATS 0 +# endif +#elif defined(MSIPL_COMPILE_H) +// Modena C++ standard library +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) +// Dinkumware Library (this has to appear after any possible replacement libraries): +# if _CPPLIB_VER >= 405 +# define BOOST_HASH_CONFORMANT_FLOATS 1 +# else +# define BOOST_HASH_CONFORMANT_FLOATS 0 +# endif +#else +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#endif + +#if BOOST_HASH_CONFORMANT_FLOATS + +// The standard library is known to be compliant, so don't use the +// configuration mechanism. + +namespace boost { + namespace hash_detail { + template + struct call_ldexp { + typedef Float float_type; + inline Float operator()(Float x, int y) const { + return std::ldexp(x, y); + } + }; + + template + struct call_frexp { + typedef Float float_type; + inline Float operator()(Float x, int* y) const { + return std::frexp(x, y); + } + }; + + template + struct select_hash_type + { + typedef Float type; + }; + } +} + +#else // BOOST_HASH_CONFORMANT_FLOATS == 0 + +// The C++ standard requires that the C float functions are overloarded +// for float, double and long double in the std namespace, but some of the older +// library implementations don't support this. On some that don't, the C99 +// float functions (frexpf, frexpl, etc.) are available. +// +// The following tries to automatically detect which are available. + +namespace boost { + namespace hash_detail { + + // Returned by dummy versions of the float functions. + + struct not_found { + // Implicitly convertible to float and long double in order to avoid + // a compile error when the dummy float functions are used. + + inline operator float() const { return 0; } + inline operator long double() const { return 0; } + }; + + // A type for detecting the return type of functions. + + template struct is; + template <> struct is { char x[10]; }; + template <> struct is { char x[20]; }; + template <> struct is { char x[30]; }; + template <> struct is { char x[40]; }; + + // Used to convert the return type of a function to a type for sizeof. + + template is float_type(T); + + // call_ldexp + // + // This will get specialized for float and long double + + template struct call_ldexp + { + typedef double float_type; + + inline double operator()(double a, int b) const + { + using namespace std; + return ldexp(a, b); + } + }; + + // call_frexp + // + // This will get specialized for float and long double + + template struct call_frexp + { + typedef double float_type; + + inline double operator()(double a, int* b) const + { + using namespace std; + return frexp(a, b); + } + }; + } +} + +// A namespace for dummy functions to detect when the actual function we want +// isn't available. ldexpl, ldexpf etc. might be added tby the macros below. +// +// AFAICT these have to be outside of the boost namespace, as if they're in +// the boost namespace they'll always be preferable to any other function +// (since the arguments are built in types, ADL can't be used). + +namespace boost_hash_detect_float_functions { + template boost::hash_detail::not_found ldexp(Float, int); + template boost::hash_detail::not_found frexp(Float, int*); +} + +// Macros for generating specializations of call_ldexp and call_frexp. +// +// check_cpp and check_c99 check if the C++ or C99 functions are available. +// +// Then the call_* functions select an appropriate implementation. +// +// I used c99_func in a few places just to get a unique name. +// +// Important: when using 'using namespace' at namespace level, include as +// little as possible in that namespace, as Visual C++ has an odd bug which +// can cause the namespace to be imported at the global level. This seems to +// happen mainly when there's a template in the same namesapce. + +#define BOOST_HASH_CALL_FLOAT_FUNC(cpp_func, c99_func, type1, type2) \ +namespace boost_hash_detect_float_functions { \ + template \ + boost::hash_detail::not_found c99_func(Float, type2); \ +} \ + \ +namespace boost { \ + namespace hash_detail { \ + namespace c99_func##_detect { \ + using namespace std; \ + using namespace boost_hash_detect_float_functions; \ + \ + struct check { \ + static type1 x; \ + static type2 y; \ + BOOST_STATIC_CONSTANT(bool, cpp = \ + sizeof(float_type(cpp_func(x,y))) \ + == sizeof(is)); \ + BOOST_STATIC_CONSTANT(bool, c99 = \ + sizeof(float_type(c99_func(x,y))) \ + == sizeof(is)); \ + }; \ + } \ + \ + template \ + struct call_c99_##c99_func : \ + boost::hash_detail::call_##cpp_func {}; \ + \ + template <> \ + struct call_c99_##c99_func { \ + typedef type1 float_type; \ + \ + template \ + inline type1 operator()(type1 a, T b) const \ + { \ + using namespace std; \ + return c99_func(a, b); \ + } \ + }; \ + \ + template \ + struct call_cpp_##c99_func : \ + call_c99_##c99_func< \ + ::boost::hash_detail::c99_func##_detect::check::c99 \ + > {}; \ + \ + template <> \ + struct call_cpp_##c99_func { \ + typedef type1 float_type; \ + \ + template \ + inline type1 operator()(type1 a, T b) const \ + { \ + using namespace std; \ + return cpp_func(a, b); \ + } \ + }; \ + \ + template <> \ + struct call_##cpp_func : \ + call_cpp_##c99_func< \ + ::boost::hash_detail::c99_func##_detect::check::cpp \ + > {}; \ + } \ +} + +#define BOOST_HASH_CALL_FLOAT_MACRO(cpp_func, c99_func, type1, type2) \ +namespace boost { \ + namespace hash_detail { \ + \ + template <> \ + struct call_##cpp_func { \ + typedef type1 float_type; \ + inline type1 operator()(type1 x, type2 y) const { \ + return c99_func(x, y); \ + } \ + }; \ + } \ +} + +#if defined(ldexpf) +BOOST_HASH_CALL_FLOAT_MACRO(ldexp, ldexpf, float, int) +#else +BOOST_HASH_CALL_FLOAT_FUNC(ldexp, ldexpf, float, int) +#endif + +#if defined(ldexpl) +BOOST_HASH_CALL_FLOAT_MACRO(ldexp, ldexpl, long double, int) +#else +BOOST_HASH_CALL_FLOAT_FUNC(ldexp, ldexpl, long double, int) +#endif + +#if defined(frexpf) +BOOST_HASH_CALL_FLOAT_MACRO(frexp, frexpf, float, int*) +#else +BOOST_HASH_CALL_FLOAT_FUNC(frexp, frexpf, float, int*) +#endif + +#if defined(frexpl) +BOOST_HASH_CALL_FLOAT_MACRO(frexp, frexpl, long double, int*) +#else +BOOST_HASH_CALL_FLOAT_FUNC(frexp, frexpl, long double, int*) +#endif + +#undef BOOST_HASH_CALL_FLOAT_MACRO +#undef BOOST_HASH_CALL_FLOAT_FUNC + + +namespace boost +{ + namespace hash_detail + { + template + struct select_hash_type_impl { + typedef double type; + }; + + template <> + struct select_hash_type_impl { + typedef float type; + }; + + template <> + struct select_hash_type_impl { + typedef long double type; + }; + + + // select_hash_type + // + // If there is support for a particular floating point type, use that + // otherwise use double (there's always support for double). + + template + struct select_hash_type : select_hash_type_impl< + BOOST_DEDUCED_TYPENAME call_ldexp::float_type, + BOOST_DEDUCED_TYPENAME call_frexp::float_type + > {}; + } +} + +#endif // BOOST_HASH_CONFORMANT_FLOATS + +#endif diff --git a/src/third-party/boost/boost/container_hash/detail/hash_float.hpp b/src/third-party/boost/boost/container_hash/detail/hash_float.hpp new file mode 100644 index 00000000..f7634285 --- /dev/null +++ b/src/third-party/boost/boost/container_hash/detail/hash_float.hpp @@ -0,0 +1,271 @@ + +// Copyright 2005-2012 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER) +#define BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER + +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(BOOST_MSVC) +#pragma warning(push) +#if BOOST_MSVC >= 1400 +#pragma warning(disable:6294) // Ill-defined for-loop: initial condition does + // not satisfy test. Loop body not executed +#endif +#endif + +// Can we use fpclassify? + +// STLport +#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) +#define BOOST_HASH_USE_FPCLASSIFY 0 + +// GNU libstdc++ 3 +#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) +# if (defined(__USE_ISOC99) || defined(_GLIBCXX_USE_C99_MATH)) && \ + !(defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) +# define BOOST_HASH_USE_FPCLASSIFY 1 +# else +# define BOOST_HASH_USE_FPCLASSIFY 0 +# endif + +// Everything else +#else +# define BOOST_HASH_USE_FPCLASSIFY 0 +#endif + +namespace boost +{ + namespace hash_detail + { + inline void hash_float_combine(std::size_t& seed, std::size_t value) + { + seed ^= value + (seed<<6) + (seed>>2); + } + + //////////////////////////////////////////////////////////////////////// + // Binary hash function + // + // Only used for floats with known iec559 floats, and certain values in + // numeric_limits + + inline std::size_t hash_binary(char* ptr, std::size_t length) + { + std::size_t seed = 0; + + if (length >= sizeof(std::size_t)) { + std::memcpy(&seed, ptr, sizeof(std::size_t)); + length -= sizeof(std::size_t); + ptr += sizeof(std::size_t); + + while(length >= sizeof(std::size_t)) { + std::size_t buffer = 0; + std::memcpy(&buffer, ptr, sizeof(std::size_t)); + hash_float_combine(seed, buffer); + length -= sizeof(std::size_t); + ptr += sizeof(std::size_t); + } + } + + if (length > 0) { + std::size_t buffer = 0; + std::memcpy(&buffer, ptr, length); + hash_float_combine(seed, buffer); + } + + return seed; + } + + template + struct enable_binary_hash + { + BOOST_STATIC_CONSTANT(bool, value = + std::numeric_limits::is_iec559 && + std::numeric_limits::digits == digits && + std::numeric_limits::radix == 2 && + std::numeric_limits::max_exponent == max_exponent); + }; + + template + inline std::size_t float_hash_impl(Float v, + BOOST_DEDUCED_TYPENAME boost::enable_if_c< + enable_binary_hash::value, + std::size_t>::type) + { + return hash_binary((char*) &v, 4); + } + + + template + inline std::size_t float_hash_impl(Float v, + BOOST_DEDUCED_TYPENAME boost::enable_if_c< + enable_binary_hash::value, + std::size_t>::type) + { + return hash_binary((char*) &v, 8); + } + + template + inline std::size_t float_hash_impl(Float v, + BOOST_DEDUCED_TYPENAME boost::enable_if_c< + enable_binary_hash::value, + std::size_t>::type) + { + return hash_binary((char*) &v, 10); + } + + template + inline std::size_t float_hash_impl(Float v, + BOOST_DEDUCED_TYPENAME boost::enable_if_c< + enable_binary_hash::value, + std::size_t>::type) + { + return hash_binary((char*) &v, 16); + } + + //////////////////////////////////////////////////////////////////////// + // Portable hash function + // + // Used as a fallback when the binary hash function isn't supported. + + template + inline std::size_t float_hash_impl2(T v) + { + boost::hash_detail::call_frexp frexp; + boost::hash_detail::call_ldexp ldexp; + + int exp = 0; + + v = frexp(v, &exp); + + // A postive value is easier to hash, so combine the + // sign with the exponent and use the absolute value. + if(v < 0) { + v = -v; + exp += limits::max_exponent - + limits::min_exponent; + } + + v = ldexp(v, limits::digits); + std::size_t seed = static_cast(v); + v -= static_cast(seed); + + // ceiling(digits(T) * log2(radix(T))/ digits(size_t)) - 1; + std::size_t const length + = (limits::digits * + boost::static_log2::radix>::value + + limits::digits - 1) + / limits::digits; + + for(std::size_t i = 0; i != length; ++i) + { + v = ldexp(v, limits::digits); + std::size_t part = static_cast(v); + v -= static_cast(part); + hash_float_combine(seed, part); + } + + hash_float_combine(seed, static_cast(exp)); + + return seed; + } + +#if !defined(BOOST_HASH_DETAIL_TEST_WITHOUT_GENERIC) + template + inline std::size_t float_hash_impl(T v, ...) + { + typedef BOOST_DEDUCED_TYPENAME select_hash_type::type type; + return float_hash_impl2(static_cast(v)); + } +#endif + } +} + +#if BOOST_HASH_USE_FPCLASSIFY + +#include + +namespace boost +{ + namespace hash_detail + { + template + inline std::size_t float_hash_value(T v) + { +#if defined(fpclassify) + switch (fpclassify(v)) +#elif BOOST_HASH_CONFORMANT_FLOATS + switch (std::fpclassify(v)) +#else + using namespace std; + switch (fpclassify(v)) +#endif + { + case FP_ZERO: + return 0; + case FP_INFINITE: + return (std::size_t)(v > 0 ? -1 : -2); + case FP_NAN: + return (std::size_t)(-3); + case FP_NORMAL: + case FP_SUBNORMAL: + return float_hash_impl(v, 0); + default: + BOOST_ASSERT(0); + return 0; + } + } + } +} + +#else // !BOOST_HASH_USE_FPCLASSIFY + +namespace boost +{ + namespace hash_detail + { + template + inline bool is_zero(T v) + { +#if !defined(__GNUC__) && !defined(__clang__) + return v == 0; +#else + // GCC's '-Wfloat-equal' will complain about comparing + // v to 0, but because it disables warnings for system + // headers it won't complain if you use std::equal_to to + // compare with 0. Resulting in this silliness: + return std::equal_to()(v, 0); +#endif + } + + template + inline std::size_t float_hash_value(T v) + { + return boost::hash_detail::is_zero(v) ? 0 : float_hash_impl(v, 0); + } + } +} + +#endif // BOOST_HASH_USE_FPCLASSIFY + +#undef BOOST_HASH_USE_FPCLASSIFY + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + +#endif diff --git a/src/third-party/boost/boost/container_hash/detail/limits.hpp b/src/third-party/boost/boost/container_hash/detail/limits.hpp new file mode 100644 index 00000000..4a971a6a --- /dev/null +++ b/src/third-party/boost/boost/container_hash/detail/limits.hpp @@ -0,0 +1,62 @@ + +// Copyright 2005-2009 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// On some platforms std::limits gives incorrect values for long double. +// This tries to work around them. + +#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER) +#define BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER + +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + +#include + +// On OpenBSD, numeric_limits is not reliable for long doubles, but +// the macros defined in are and support long double when STLport +// doesn't. + +#if defined(__OpenBSD__) || defined(_STLP_NO_LONG_DOUBLE) +#include +#endif + +namespace boost +{ + namespace hash_detail + { + template + struct limits : std::numeric_limits {}; + +#if defined(__OpenBSD__) || defined(_STLP_NO_LONG_DOUBLE) + template <> + struct limits + : std::numeric_limits + { + static long double epsilon() { + return LDBL_EPSILON; + } + + static long double (max)() { + return LDBL_MAX; + } + + static long double (min)() { + return LDBL_MIN; + } + + BOOST_STATIC_CONSTANT(int, digits = LDBL_MANT_DIG); + BOOST_STATIC_CONSTANT(int, max_exponent = LDBL_MAX_EXP); + BOOST_STATIC_CONSTANT(int, min_exponent = LDBL_MIN_EXP); +#if defined(_STLP_NO_LONG_DOUBLE) + BOOST_STATIC_CONSTANT(int, radix = FLT_RADIX); +#endif + }; +#endif // __OpenBSD__ + } +} + +#endif diff --git a/src/third-party/boost/boost/container_hash/extensions.hpp b/src/third-party/boost/boost/container_hash/extensions.hpp new file mode 100644 index 00000000..4eebb4bc --- /dev/null +++ b/src/third-party/boost/boost/container_hash/extensions.hpp @@ -0,0 +1,414 @@ + +// Copyright 2005-2009 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Based on Peter Dimov's proposal +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf +// issue 6.18. + +// This implements the extensions to the standard. +// It's undocumented, so you shouldn't use it.... + +#if !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP) +#define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP + +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + +#include +#include +#include +#include +#include + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) +# include +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) +# include +#endif + +#if !defined(BOOST_NO_CXX11_HDR_MEMORY) +# include +#endif + +#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +#include +#endif + +namespace boost +{ + template + std::size_t hash_value(std::pair const&); + template + std::size_t hash_value(std::vector const&); + template + std::size_t hash_value(std::list const& v); + template + std::size_t hash_value(std::deque const& v); + template + std::size_t hash_value(std::set const& v); + template + std::size_t hash_value(std::multiset const& v); + template + std::size_t hash_value(std::map const& v); + template + std::size_t hash_value(std::multimap const& v); + + template + std::size_t hash_value(std::complex const&); + + template + std::size_t hash_value(std::pair const& v) + { + std::size_t seed = 0; + boost::hash_combine(seed, v.first); + boost::hash_combine(seed, v.second); + return seed; + } + + inline std::size_t hash_range( + std::vector::iterator first, + std::vector::iterator last) + { + std::size_t seed = 0; + + for(; first != last; ++first) + { + hash_combine(seed, *first); + } + + return seed; + } + + inline std::size_t hash_range( + std::vector::const_iterator first, + std::vector::const_iterator last) + { + std::size_t seed = 0; + + for(; first != last; ++first) + { + hash_combine(seed, *first); + } + + return seed; + } + + inline void hash_range( + std::size_t& seed, + std::vector::iterator first, + std::vector::iterator last) + { + for(; first != last; ++first) + { + hash_combine(seed, *first); + } + } + + inline void hash_range( + std::size_t& seed, + std::vector::const_iterator first, + std::vector::const_iterator last) + { + for(; first != last; ++first) + { + hash_combine(seed, *first); + } + } + + template + std::size_t hash_value(std::vector const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::list const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::deque const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::set const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::multiset const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::map const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::multimap const& v) + { + return boost::hash_range(v.begin(), v.end()); + } + + template + std::size_t hash_value(std::complex const& v) + { + boost::hash hasher; + std::size_t seed = hasher(v.imag()); + seed ^= hasher(v.real()) + (seed<<6) + (seed>>2); + return seed; + } + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) + template + std::size_t hash_value(std::array const& v) + { + return boost::hash_range(v.begin(), v.end()); + } +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) + namespace hash_detail { + template + inline typename boost::enable_if_c<(I == std::tuple_size::value), + void>::type + hash_combine_tuple(std::size_t&, T const&) + { + } + + template + inline typename boost::enable_if_c<(I < std::tuple_size::value), + void>::type + hash_combine_tuple(std::size_t& seed, T const& v) + { + boost::hash_combine(seed, std::get(v)); + boost::hash_detail::hash_combine_tuple(seed, v); + } + + template + inline std::size_t hash_tuple(T const& v) + { + std::size_t seed = 0; + boost::hash_detail::hash_combine_tuple<0>(seed, v); + return seed; + } + } + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } +#else + + inline std::size_t hash_value(std::tuple<> const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + +#endif + +#endif + +#if !defined(BOOST_NO_CXX11_SMART_PTR) + template + inline std::size_t hash_value(std::shared_ptr const& x) { + return boost::hash_value(x.get()); + } + + template + inline std::size_t hash_value(std::unique_ptr const& x) { + return boost::hash_value(x.get()); + } +#endif + + // + // call_hash_impl + // + + // On compilers without function template ordering, this deals with arrays. + +#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + namespace hash_detail + { + template + struct call_hash_impl + { + template + struct inner + { + static std::size_t call(T const& v) + { + using namespace boost; + return hash_value(v); + } + }; + }; + + template <> + struct call_hash_impl + { + template + struct inner + { + static std::size_t call(Array const& v) + { + const int size = sizeof(v) / sizeof(*v); + return boost::hash_range(v, v + size); + } + }; + }; + + template + struct call_hash + : public call_hash_impl::value> + ::BOOST_NESTED_TEMPLATE inner + { + }; + } +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + + // + // boost::hash + // + + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + + template struct hash + : boost::hash_detail::hash_base + { +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + std::size_t operator()(T const& val) const + { + return hash_value(val); + } +#else + std::size_t operator()(T const& val) const + { + return hash_detail::call_hash::call(val); + } +#endif + }; + +#if BOOST_WORKAROUND(__DMC__, <= 0x848) + template struct hash + : boost::hash_detail::hash_base + { + std::size_t operator()(const T* val) const + { + return boost::hash_range(val, val+n); + } + }; +#endif + +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // On compilers without partial specialization, boost::hash + // has already been declared to deal with pointers, so just + // need to supply the non-pointer version of hash_impl. + + namespace hash_detail + { + template + struct hash_impl; + + template <> + struct hash_impl + { + template + struct inner + : boost::hash_detail::hash_base + { +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + std::size_t operator()(T const& val) const + { + return hash_value(val); + } +#else + std::size_t operator()(T const& val) const + { + return hash_detail::call_hash::call(val); + } +#endif + }; + }; + } +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +} + +#endif diff --git a/src/third-party/boost/boost/container_hash/hash.hpp b/src/third-party/boost/boost/container_hash/hash.hpp new file mode 100644 index 00000000..76de7939 --- /dev/null +++ b/src/third-party/boost/boost/container_hash/hash.hpp @@ -0,0 +1,761 @@ + +// Copyright 2005-2014 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Based on Peter Dimov's proposal +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf +// issue 6.18. +// +// This also contains public domain code from MurmurHash. From the +// MurmurHash header: + +// MurmurHash3 was written by Austin Appleby, and is placed in the public +// domain. The author hereby disclaims copyright to this source code. + +#if !defined(BOOST_FUNCTIONAL_HASH_HASH_HPP) +#define BOOST_FUNCTIONAL_HASH_HASH_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +#include +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) +#include +#endif + +#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) +#include +#endif + +#if defined(BOOST_MSVC) +#pragma warning(push) + +#if BOOST_MSVC >= 1400 +#pragma warning(disable:6295) // Ill-defined for-loop : 'unsigned int' values + // are always of range '0' to '4294967295'. + // Loop executes infinitely. +#endif + +#endif + +#if BOOST_WORKAROUND(__GNUC__, < 3) \ + && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) +#define BOOST_HASH_CHAR_TRAITS string_char_traits +#else +#define BOOST_HASH_CHAR_TRAITS char_traits +#endif + +#if defined(_MSC_VER) +# define BOOST_FUNCTIONAL_HASH_ROTL32(x, r) _rotl(x,r) +#else +# define BOOST_FUNCTIONAL_HASH_ROTL32(x, r) (x << r) | (x >> (32 - r)) +#endif + +// Detect whether standard library has C++17 headers + +#if !defined(BOOST_HASH_CXX17) +# if defined(BOOST_MSVC) +# if defined(_HAS_CXX17) && _HAS_CXX17 +# define BOOST_HASH_CXX17 1 +# endif +# elif defined(__cplusplus) && __cplusplus >= 201703 +# define BOOST_HASH_CXX17 1 +# endif +#endif + +#if !defined(BOOST_HASH_CXX17) +# define BOOST_HASH_CXX17 0 +#endif + +#if BOOST_HASH_CXX17 && defined(__has_include) +# if !defined(BOOST_HASH_HAS_STRING_VIEW) && __has_include() +# define BOOST_HASH_HAS_STRING_VIEW 1 +# endif +# if !defined(BOOST_HASH_HAS_OPTIONAL) && __has_include() +# define BOOST_HASH_HAS_OPTIONAL 1 +# endif +# if !defined(BOOST_HASH_HAS_VARIANT) && __has_include() +# define BOOST_HASH_HAS_VARIANT 1 +# endif +#endif + +#if !defined(BOOST_HASH_HAS_STRING_VIEW) +# define BOOST_HASH_HAS_STRING_VIEW 0 +#endif + +#if !defined(BOOST_HASH_HAS_OPTIONAL) +# define BOOST_HASH_HAS_OPTIONAL 0 +#endif + +#if !defined(BOOST_HASH_HAS_VARIANT) +# define BOOST_HASH_HAS_VARIANT 0 +#endif + +#if BOOST_HASH_HAS_STRING_VIEW +# include +#endif + +#if BOOST_HASH_HAS_OPTIONAL +# include +#endif + +#if BOOST_HASH_HAS_VARIANT +# include +#endif + +namespace boost +{ + namespace hash_detail + { +#if defined(_HAS_AUTO_PTR_ETC) && !_HAS_AUTO_PTR_ETC + template + struct hash_base + { + typedef T argument_type; + typedef std::size_t result_type; + }; +#else + template + struct hash_base : std::unary_function {}; +#endif + + struct enable_hash_value { typedef std::size_t type; }; + + template struct basic_numbers {}; + template struct long_numbers; + template struct ulong_numbers; + template struct float_numbers {}; + + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; + +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; +#endif + +#if !defined(BOOST_NO_CXX11_CHAR16_T) + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; +#endif + +#if !defined(BOOST_NO_CXX11_CHAR32_T) + template <> struct basic_numbers : + boost::hash_detail::enable_hash_value {}; +#endif + + // long_numbers is defined like this to allow for separate + // specialization for long_long and int128_type, in case + // they conflict. + template struct long_numbers2 {}; + template struct ulong_numbers2 {}; + template struct long_numbers : long_numbers2 {}; + template struct ulong_numbers : ulong_numbers2 {}; + +#if !defined(BOOST_NO_LONG_LONG) + template <> struct long_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct ulong_numbers : + boost::hash_detail::enable_hash_value {}; +#endif + +#if defined(BOOST_HAS_INT128) + template <> struct long_numbers2 : + boost::hash_detail::enable_hash_value {}; + template <> struct ulong_numbers2 : + boost::hash_detail::enable_hash_value {}; +#endif + + template <> struct float_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct float_numbers : + boost::hash_detail::enable_hash_value {}; + template <> struct float_numbers : + boost::hash_detail::enable_hash_value {}; + } + + template + typename boost::hash_detail::basic_numbers::type hash_value(T); + template + typename boost::hash_detail::long_numbers::type hash_value(T); + template + typename boost::hash_detail::ulong_numbers::type hash_value(T); + + template + typename boost::enable_if, std::size_t>::type + hash_value(T); + +#if !BOOST_WORKAROUND(__DMC__, <= 0x848) + template std::size_t hash_value(T* const&); +#else + template std::size_t hash_value(T*); +#endif + +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + template< class T, unsigned N > + std::size_t hash_value(const T (&x)[N]); + + template< class T, unsigned N > + std::size_t hash_value(T (&x)[N]); +#endif + + template + std::size_t hash_value( + std::basic_string, A> const&); + +#if BOOST_HASH_HAS_STRING_VIEW + template + std::size_t hash_value( + std::basic_string_view > const&); +#endif + + template + typename boost::hash_detail::float_numbers::type hash_value(T); + +#if BOOST_HASH_HAS_OPTIONAL + template + std::size_t hash_value(std::optional const&); +#endif + +#if BOOST_HASH_HAS_VARIANT + std::size_t hash_value(std::monostate); + template + std::size_t hash_value(std::variant const&); +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) + std::size_t hash_value(std::type_index); +#endif + +#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) + std::size_t hash_value(std::error_code const&); + std::size_t hash_value(std::error_condition const&); +#endif + + // Implementation + + namespace hash_detail + { + template + inline std::size_t hash_value_signed(T val) + { + const unsigned int size_t_bits = std::numeric_limits::digits; + // ceiling(std::numeric_limits::digits / size_t_bits) - 1 + const int length = (std::numeric_limits::digits - 1) + / static_cast(size_t_bits); + + std::size_t seed = 0; + T positive = val < 0 ? -1 - val : val; + + // Hopefully, this loop can be unrolled. + for(unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits) + { + seed ^= (std::size_t) (positive >> i) + (seed<<6) + (seed>>2); + } + seed ^= (std::size_t) val + (seed<<6) + (seed>>2); + + return seed; + } + + template + inline std::size_t hash_value_unsigned(T val) + { + const unsigned int size_t_bits = std::numeric_limits::digits; + // ceiling(std::numeric_limits::digits / size_t_bits) - 1 + const int length = (std::numeric_limits::digits - 1) + / static_cast(size_t_bits); + + std::size_t seed = 0; + + // Hopefully, this loop can be unrolled. + for(unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits) + { + seed ^= (std::size_t) (val >> i) + (seed<<6) + (seed>>2); + } + seed ^= (std::size_t) val + (seed<<6) + (seed>>2); + + return seed; + } + + template + inline void hash_combine_impl(SizeT& seed, SizeT value) + { + seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + + inline void hash_combine_impl(boost::uint32_t& h1, + boost::uint32_t k1) + { + const uint32_t c1 = 0xcc9e2d51; + const uint32_t c2 = 0x1b873593; + + k1 *= c1; + k1 = BOOST_FUNCTIONAL_HASH_ROTL32(k1,15); + k1 *= c2; + + h1 ^= k1; + h1 = BOOST_FUNCTIONAL_HASH_ROTL32(h1,13); + h1 = h1*5+0xe6546b64; + } + + +// Don't define 64-bit hash combine on platforms without 64 bit integers, +// and also not for 32-bit gcc as it warns about the 64-bit constant. +#if !defined(BOOST_NO_INT64_T) && \ + !(defined(__GNUC__) && ULONG_MAX == 0xffffffff) + + inline void hash_combine_impl(boost::uint64_t& h, + boost::uint64_t k) + { + const boost::uint64_t m = UINT64_C(0xc6a4a7935bd1e995); + const int r = 47; + + k *= m; + k ^= k >> r; + k *= m; + + h ^= k; + h *= m; + + // Completely arbitrary number, to prevent 0's + // from hashing to 0. + h += 0xe6546b64; + } + +#endif // BOOST_NO_INT64_T + } + + template + typename boost::hash_detail::basic_numbers::type hash_value(T v) + { + return static_cast(v); + } + + template + typename boost::hash_detail::long_numbers::type hash_value(T v) + { + return hash_detail::hash_value_signed(v); + } + + template + typename boost::hash_detail::ulong_numbers::type hash_value(T v) + { + return hash_detail::hash_value_unsigned(v); + } + + template + typename boost::enable_if, std::size_t>::type + hash_value(T v) + { + return static_cast(v); + } + + // Implementation by Alberto Barbati and Dave Harris. +#if !BOOST_WORKAROUND(__DMC__, <= 0x848) + template std::size_t hash_value(T* const& v) +#else + template std::size_t hash_value(T* v) +#endif + { +#if defined(__VMS) && __INITIAL_POINTER_SIZE == 64 + // for some reason ptrdiff_t on OpenVMS compiler with + // 64 bit is not 64 bit !!! + std::size_t x = static_cast( + reinterpret_cast(v)); +#else + std::size_t x = static_cast( + reinterpret_cast(v)); +#endif + return x + (x >> 3); + } + +#if defined(BOOST_MSVC) +#pragma warning(push) +#if BOOST_MSVC <= 1400 +#pragma warning(disable:4267) // 'argument' : conversion from 'size_t' to + // 'unsigned int', possible loss of data + // A misguided attempt to detect 64-bit + // incompatability. +#endif +#endif + + template + inline void hash_combine(std::size_t& seed, T const& v) + { + boost::hash hasher; + return boost::hash_detail::hash_combine_impl(seed, hasher(v)); + } + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + + template + inline std::size_t hash_range(It first, It last) + { + std::size_t seed = 0; + + for(; first != last; ++first) + { + hash_combine(seed, *first); + } + + return seed; + } + + template + inline void hash_range(std::size_t& seed, It first, It last) + { + for(; first != last; ++first) + { + hash_combine(seed, *first); + } + } + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template + inline std::size_t hash_range(T* first, T* last) + { + std::size_t seed = 0; + + for(; first != last; ++first) + { + boost::hash hasher; + seed ^= hasher(*first) + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + + return seed; + } + + template + inline void hash_range(std::size_t& seed, T* first, T* last) + { + for(; first != last; ++first) + { + boost::hash hasher; + seed ^= hasher(*first) + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + } +#endif + +#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) + template< class T, unsigned N > + inline std::size_t hash_value(const T (&x)[N]) + { + return hash_range(x, x + N); + } + + template< class T, unsigned N > + inline std::size_t hash_value(T (&x)[N]) + { + return hash_range(x, x + N); + } +#endif + + template + inline std::size_t hash_value( + std::basic_string, A> const& v) + { + return hash_range(v.begin(), v.end()); + } + +#if BOOST_HASH_HAS_STRING_VIEW + template + inline std::size_t hash_value( + std::basic_string_view > const& v) + { + return hash_range(v.begin(), v.end()); + } +#endif + + template + typename boost::hash_detail::float_numbers::type hash_value(T v) + { + return boost::hash_detail::float_hash_value(v); + } + +#if BOOST_HASH_HAS_OPTIONAL + template + inline std::size_t hash_value(std::optional const& v) { + if (!v) { + // Arbitray value for empty optional. + return 0x12345678; + } else { + boost::hash hf; + return hf(*v); + } + } +#endif + +#if BOOST_HASH_HAS_VARIANT + inline std::size_t hash_value(std::monostate) { + return 0x87654321; + } + + template + inline std::size_t hash_value(std::variant const& v) { + std::size_t seed = 0; + hash_combine(seed, v.index()); + std::visit([&seed](auto&& x) { hash_combine(seed, x); }, v); + return seed; + } +#endif + + +#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) + inline std::size_t hash_value(std::type_index v) + { + return v.hash_code(); + } +#endif + +#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) + inline std::size_t hash_value(std::error_code const& v) { + std::size_t seed = 0; + hash_combine(seed, v.value()); + hash_combine(seed, &v.category()); + return seed; + } + + inline std::size_t hash_value(std::error_condition const& v) { + std::size_t seed = 0; + hash_combine(seed, v.value()); + hash_combine(seed, &v.category()); + return seed; + } +#endif + + // + // boost::hash + // + + // Define the specializations required by the standard. The general purpose + // boost::hash is defined later in extensions.hpp if + // BOOST_HASH_NO_EXTENSIONS is not defined. + + // BOOST_HASH_SPECIALIZE - define a specialization for a type which is + // passed by copy. + // + // BOOST_HASH_SPECIALIZE_REF - define a specialization for a type which is + // passed by const reference. + // + // These are undefined later. + +#define BOOST_HASH_SPECIALIZE(type) \ + template <> struct hash \ + : public boost::hash_detail::hash_base \ + { \ + std::size_t operator()(type v) const \ + { \ + return boost::hash_value(v); \ + } \ + }; + +#define BOOST_HASH_SPECIALIZE_REF(type) \ + template <> struct hash \ + : public boost::hash_detail::hash_base \ + { \ + std::size_t operator()(type const& v) const \ + { \ + return boost::hash_value(v); \ + } \ + }; + +#define BOOST_HASH_SPECIALIZE_TEMPLATE_REF(type) \ + struct hash \ + : public boost::hash_detail::hash_base \ + { \ + std::size_t operator()(type const& v) const \ + { \ + return boost::hash_value(v); \ + } \ + }; + + BOOST_HASH_SPECIALIZE(bool) + BOOST_HASH_SPECIALIZE(char) + BOOST_HASH_SPECIALIZE(signed char) + BOOST_HASH_SPECIALIZE(unsigned char) +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) + BOOST_HASH_SPECIALIZE(wchar_t) +#endif +#if !defined(BOOST_NO_CXX11_CHAR16_T) + BOOST_HASH_SPECIALIZE(char16_t) +#endif +#if !defined(BOOST_NO_CXX11_CHAR32_T) + BOOST_HASH_SPECIALIZE(char32_t) +#endif + BOOST_HASH_SPECIALIZE(short) + BOOST_HASH_SPECIALIZE(unsigned short) + BOOST_HASH_SPECIALIZE(int) + BOOST_HASH_SPECIALIZE(unsigned int) + BOOST_HASH_SPECIALIZE(long) + BOOST_HASH_SPECIALIZE(unsigned long) + + BOOST_HASH_SPECIALIZE(float) + BOOST_HASH_SPECIALIZE(double) + BOOST_HASH_SPECIALIZE(long double) + + BOOST_HASH_SPECIALIZE_REF(std::string) +#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + BOOST_HASH_SPECIALIZE_REF(std::wstring) +#endif +#if !defined(BOOST_NO_CXX11_CHAR16_T) + BOOST_HASH_SPECIALIZE_REF(std::basic_string) +#endif +#if !defined(BOOST_NO_CXX11_CHAR32_T) + BOOST_HASH_SPECIALIZE_REF(std::basic_string) +#endif + +#if BOOST_HASH_HAS_STRING_VIEW + BOOST_HASH_SPECIALIZE_REF(std::string_view) +# if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + BOOST_HASH_SPECIALIZE_REF(std::wstring_view) +# endif +# if !defined(BOOST_NO_CXX11_CHAR16_T) + BOOST_HASH_SPECIALIZE_REF(std::basic_string_view) +# endif +# if !defined(BOOST_NO_CXX11_CHAR32_T) + BOOST_HASH_SPECIALIZE_REF(std::basic_string_view) +# endif +#endif + +#if !defined(BOOST_NO_LONG_LONG) + BOOST_HASH_SPECIALIZE(boost::long_long_type) + BOOST_HASH_SPECIALIZE(boost::ulong_long_type) +#endif + +#if defined(BOOST_HAS_INT128) + BOOST_HASH_SPECIALIZE(boost::int128_type) + BOOST_HASH_SPECIALIZE(boost::uint128_type) +#endif + +#if BOOST_HASH_HAS_OPTIONAL + template + BOOST_HASH_SPECIALIZE_TEMPLATE_REF(std::optional) +#endif + +#if !defined(BOOST_HASH_HAS_VARIANT) + template + BOOST_HASH_SPECIALIZE_TEMPLATE_REF(std::variant) + BOOST_HASH_SPECIALIZE(std::monostate) +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) + BOOST_HASH_SPECIALIZE(std::type_index) +#endif + +#undef BOOST_HASH_SPECIALIZE +#undef BOOST_HASH_SPECIALIZE_REF +#undef BOOST_HASH_SPECIALIZE_TEMPLATE_REF + +// Specializing boost::hash for pointers. + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + + template + struct hash + : public boost::hash_detail::hash_base + { + std::size_t operator()(T* v) const + { +#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) + return boost::hash_value(v); +#else + std::size_t x = static_cast( + reinterpret_cast(v)); + + return x + (x >> 3); +#endif + } + }; + +#else + + // For compilers without partial specialization, we define a + // boost::hash for all remaining types. But hash_impl is only defined + // for pointers in 'extensions.hpp' - so when BOOST_HASH_NO_EXTENSIONS + // is defined there will still be a compile error for types not supported + // in the standard. + + namespace hash_detail + { + template + struct hash_impl; + + template <> + struct hash_impl + { + template + struct inner + : public boost::hash_detail::hash_base + { + std::size_t operator()(T val) const + { +#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 590) + return boost::hash_value(val); +#else + std::size_t x = static_cast( + reinterpret_cast(val)); + + return x + (x >> 3); +#endif + } + }; + }; + } + + template struct hash + : public boost::hash_detail::hash_impl::value> + ::BOOST_NESTED_TEMPLATE inner + { + }; + +#endif +} + +#undef BOOST_HASH_CHAR_TRAITS +#undef BOOST_FUNCTIONAL_HASH_ROTL32 + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + +#endif // BOOST_FUNCTIONAL_HASH_HASH_HPP + +// Include this outside of the include guards in case the file is included +// twice - once with BOOST_HASH_NO_EXTENSIONS defined, and then with it +// undefined. + +#if !defined(BOOST_HASH_NO_EXTENSIONS) \ + && !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP) +#include +#endif diff --git a/src/third-party/boost/boost/container_hash/hash_fwd.hpp b/src/third-party/boost/boost/container_hash/hash_fwd.hpp new file mode 100644 index 00000000..a87c182d --- /dev/null +++ b/src/third-party/boost/boost/container_hash/hash_fwd.hpp @@ -0,0 +1,36 @@ + +// Copyright 2005-2009 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Based on Peter Dimov's proposal +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf +// issue 6.18. + +#if !defined(BOOST_FUNCTIONAL_HASH_FWD_HPP) +#define BOOST_FUNCTIONAL_HASH_FWD_HPP + +#include +#include + +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + + +namespace boost +{ + template struct hash; + + template void hash_combine(std::size_t& seed, T const& v); + + template std::size_t hash_range(It, It); + template void hash_range(std::size_t&, It, It); + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) + template inline std::size_t hash_range(T*, T*); + template inline void hash_range(std::size_t&, T*, T*); +#endif +} + +#endif diff --git a/src/third-party/boost/boost/core/pointer_traits.hpp b/src/third-party/boost/boost/core/pointer_traits.hpp new file mode 100644 index 00000000..e0ebfb07 --- /dev/null +++ b/src/third-party/boost/boost/core/pointer_traits.hpp @@ -0,0 +1,233 @@ +/* +Copyright 2017-2018 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) +*/ +#ifndef BOOST_CORE_POINTER_TRAITS_HPP +#define BOOST_CORE_POINTER_TRAITS_HPP + +#include +#if !defined(BOOST_NO_CXX11_POINTER_TRAITS) +#include +#else +#include +#endif + +namespace boost { + +#if !defined(BOOST_NO_CXX11_POINTER_TRAITS) +template +struct pointer_traits + : std::pointer_traits { + template + struct rebind_to { + typedef typename std::pointer_traits::template rebind type; + }; +}; + +template +struct pointer_traits + : std::pointer_traits { + template + struct rebind_to { + typedef U* type; + }; +}; +#else +namespace detail { + +template +struct ptr_void { + typedef void type; +}; + +template +struct ptr_first; + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +template class T, class U, class... Args> +struct ptr_first > { + typedef U type; +}; +#else +template class T, class U> +struct ptr_first > { + typedef U type; +}; + +template class T, class U1, class U2> +struct ptr_first > { + typedef U1 type; +}; + +template class T, class U1, class U2, class U3> +struct ptr_first > { + typedef U1 type; +}; +#endif + +template +struct ptr_element { + typedef typename ptr_first::type type; +}; + +template +struct ptr_element::type> { + typedef typename T::element_type type; +}; + +template +struct ptr_difference { + typedef std::ptrdiff_t type; +}; + +template +struct ptr_difference::type> { + typedef typename T::difference_type type; +}; + +template +struct ptr_transform; + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +template class T, class U, class... Args, class V> +struct ptr_transform, V> { + typedef T type; +}; +#else +template class T, class U, class V> +struct ptr_transform, V> { + typedef T type; +}; + +template class T, class U1, class U2, class V> +struct ptr_transform, V> { + typedef T type; +}; + +template class T, + class U1, class U2, class U3, class V> +struct ptr_transform, V> { + typedef T type; +}; +#endif + +template +struct ptr_rebind { + typedef typename ptr_transform::type type; +}; + +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) +template +struct ptr_rebind >::type> { + typedef typename T::template rebind type; +}; +#endif + +template +struct ptr_value { + typedef T type; +}; + +template<> +struct ptr_value { + typedef struct { } type; +}; + +} /* detail */ + +template +struct pointer_traits { + typedef T pointer; + typedef typename detail::ptr_element::type element_type; + typedef typename detail::ptr_difference::type difference_type; + template + struct rebind_to { + typedef typename detail::ptr_rebind::type type; + }; +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + template + using rebind = typename detail::ptr_rebind::type; +#endif + static pointer + pointer_to(typename detail::ptr_value::type& v) { + return pointer::pointer_to(v); + } +}; + +template +struct pointer_traits { + typedef T* pointer; + typedef T element_type; + typedef std::ptrdiff_t difference_type; + template + struct rebind_to { + typedef U* type; + }; +#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + template + using rebind = U*; +#endif + static T* + pointer_to(typename detail::ptr_value::type& v) BOOST_NOEXCEPT { + return boost::addressof(v); + } +}; +#endif + +template +BOOST_CONSTEXPR inline T* +to_address(T* v) BOOST_NOEXCEPT +{ + return v; +} + +#if !defined(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION) +namespace detail { + +template +inline T* +ptr_address(T* v, int) BOOST_NOEXCEPT +{ + return v; +} + +template +inline auto +ptr_address(const T& v, int) BOOST_NOEXCEPT +-> decltype(boost::pointer_traits::to_address(v)) +{ + return boost::pointer_traits::to_address(v); +} + +template +inline auto +ptr_address(const T& v, long) BOOST_NOEXCEPT +{ + return boost::detail::ptr_address(v.operator->(), 0); +} + +} /* detail */ + +template +inline auto +to_address(const T& v) BOOST_NOEXCEPT +{ + return boost::detail::ptr_address(v, 0); +} +#else +template +inline typename pointer_traits::element_type* +to_address(const T& v) BOOST_NOEXCEPT +{ + return boost::to_address(v.operator->()); +} +#endif + +} /* boost */ + +#endif diff --git a/src/third-party/boost/boost/detail/container_fwd.hpp b/src/third-party/boost/boost/detail/container_fwd.hpp new file mode 100644 index 00000000..04ce9727 --- /dev/null +++ b/src/third-party/boost/boost/detail/container_fwd.hpp @@ -0,0 +1,157 @@ + +// Copyright 2005-2011 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Note: if you change this include guard, you also need to change +// container_fwd_compile_fail.cpp +#if !defined(BOOST_DETAIL_CONTAINER_FWD_HPP) +#define BOOST_DETAIL_CONTAINER_FWD_HPP + +#if defined(_MSC_VER) && \ + !defined(BOOST_DETAIL_TEST_CONFIG_ONLY) +# pragma once +#endif + +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +// // +// Define BOOST_DETAIL_NO_CONTAINER_FWD if you don't want this header to // +// forward declare standard containers. // +// // +// BOOST_DETAIL_CONTAINER_FWD to make it foward declare containers even if it // +// normally doesn't. // +// // +// BOOST_DETAIL_NO_CONTAINER_FWD overrides BOOST_DETAIL_CONTAINER_FWD. // +// // +//////////////////////////////////////////////////////////////////////////////// + +#if !defined(BOOST_DETAIL_NO_CONTAINER_FWD) +# if defined(BOOST_DETAIL_CONTAINER_FWD) + // Force forward declarations. +# elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) + // STLport +# define BOOST_DETAIL_NO_CONTAINER_FWD +# elif defined(__LIBCOMO__) + // Comeau STL: +# define BOOST_DETAIL_NO_CONTAINER_FWD +# elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) + // Rogue Wave library: +# define BOOST_DETAIL_NO_CONTAINER_FWD +# elif defined(_LIBCPP_VERSION) + // libc++ +# define BOOST_DETAIL_NO_CONTAINER_FWD +# elif defined(__GLIBCPP__) || defined(__GLIBCXX__) + // GNU libstdc++ 3 + // + // Disable forwarding for all recent versions, as the library has a + // versioned namespace mode, and I don't know how to detect it. +# if __GLIBCXX__ >= 20070513 \ + || defined(_GLIBCXX_DEBUG) \ + || defined(_GLIBCXX_PARALLEL) \ + || defined(_GLIBCXX_PROFILE) +# define BOOST_DETAIL_NO_CONTAINER_FWD +# else +# if defined(__GLIBCXX__) && __GLIBCXX__ >= 20040530 +# define BOOST_CONTAINER_FWD_COMPLEX_STRUCT +# endif +# endif +# elif defined(__STL_CONFIG_H) + // generic SGI STL + // + // Forward declaration seems to be okay, but it has a couple of odd + // implementations. +# define BOOST_CONTAINER_FWD_BAD_BITSET +# if !defined(__STL_NON_TYPE_TMPL_PARAM_BUG) +# define BOOST_CONTAINER_FWD_BAD_DEQUE +# endif +# elif defined(__MSL_CPP__) + // MSL standard lib: +# define BOOST_DETAIL_NO_CONTAINER_FWD +# elif defined(__IBMCPP__) + // The default VACPP std lib, forward declaration seems to be fine. +# elif defined(MSIPL_COMPILE_H) + // Modena C++ standard library +# define BOOST_DETAIL_NO_CONTAINER_FWD +# elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) + // Dinkumware Library (this has to appear after any possible replacement + // libraries) +# else +# define BOOST_DETAIL_NO_CONTAINER_FWD +# endif +#endif + +#if !defined(BOOST_DETAIL_TEST_CONFIG_ONLY) + +#if defined(BOOST_DETAIL_NO_CONTAINER_FWD) && \ + !defined(BOOST_DETAIL_TEST_FORCE_CONTAINER_FWD) + +#include +#include +#include +#include +#include +#include +#include +#include + +#else + +#include + +#if defined(BOOST_CONTAINER_FWD_BAD_DEQUE) +#include +#endif + +#if defined(BOOST_CONTAINER_FWD_BAD_BITSET) +#include +#endif + +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4099) // struct/class mismatch in fwd declarations +#endif + +namespace std +{ + template class allocator; + template class basic_string; + + template struct char_traits; + +#if defined(BOOST_CONTAINER_FWD_COMPLEX_STRUCT) + template struct complex; +#else + template class complex; +#endif + +#if !defined(BOOST_CONTAINER_FWD_BAD_DEQUE) + template class deque; +#endif + + template class list; + template class vector; + template class map; + template + class multimap; + template class set; + template class multiset; + +#if !defined(BOOST_CONTAINER_FWD_BAD_BITSET) + template class bitset; +#endif + template struct pair; +} + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + +#endif // BOOST_DETAIL_NO_CONTAINER_FWD && + // !defined(BOOST_DETAIL_TEST_FORCE_CONTAINER_FWD) + +#endif // BOOST_DETAIL_TEST_CONFIG_ONLY + +#endif diff --git a/src/third-party/boost/boost/detail/select_type.hpp b/src/third-party/boost/boost/detail/select_type.hpp new file mode 100644 index 00000000..c13946f3 --- /dev/null +++ b/src/third-party/boost/boost/detail/select_type.hpp @@ -0,0 +1,36 @@ +// (C) Copyright David Abrahams 2001. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org for most recent version including documentation. + +// Revision History +// 09 Feb 01 Applied John Maddock's Borland patch Moving +// specialization to unspecialized template (David Abrahams) +// 06 Feb 01 Created (David Abrahams) + +#ifndef SELECT_TYPE_DWA20010206_HPP +# define SELECT_TYPE_DWA20010206_HPP + +namespace boost { namespace detail { + + // Template class if_true -- select among 2 types based on a bool constant expression + // Usage: + // typename if_true<(bool_const_expression)>::template then::type + + // HP aCC cannot deal with missing names for template value parameters + template struct if_true + { + template + struct then { typedef T type; }; + }; + + template <> + struct if_true + { + template + struct then { typedef F type; }; + }; +}} +#endif // SELECT_TYPE_DWA20010206_HPP diff --git a/src/third-party/boost/boost/functional/hash.hpp b/src/third-party/boost/boost/functional/hash.hpp new file mode 100644 index 00000000..327a3eca --- /dev/null +++ b/src/third-party/boost/boost/functional/hash.hpp @@ -0,0 +1,6 @@ + +// Copyright 2005-2009 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include diff --git a/src/third-party/boost/boost/functional/hash_fwd.hpp b/src/third-party/boost/boost/functional/hash_fwd.hpp new file mode 100644 index 00000000..62bc23c7 --- /dev/null +++ b/src/third-party/boost/boost/functional/hash_fwd.hpp @@ -0,0 +1,6 @@ + +// Copyright 2005-2009 Daniel James. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include diff --git a/src/third-party/boost/boost/integer/static_log2.hpp b/src/third-party/boost/boost/integer/static_log2.hpp new file mode 100644 index 00000000..56c7a001 --- /dev/null +++ b/src/third-party/boost/boost/integer/static_log2.hpp @@ -0,0 +1,127 @@ +// -------------- Boost static_log2.hpp header file ----------------------- // +// +// Copyright (C) 2001 Daryle Walker. +// Copyright (C) 2003 Vesa Karvonen. +// Copyright (C) 2003 Gennaro Prota. +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// --------------------------------------------------- +// See http://www.boost.org/libs/integer for documentation. +// ------------------------------------------------------------------------- // + + +#ifndef BOOST_INTEGER_STATIC_LOG2_HPP +#define BOOST_INTEGER_STATIC_LOG2_HPP + +#include "boost/integer_fwd.hpp" // for boost::intmax_t + +namespace boost { + + namespace detail { + + namespace static_log2_impl { + + // choose_initial_n<> + // + // Recursively doubles its integer argument, until it + // becomes >= of the "width" (C99, 6.2.6.2p4) of + // static_log2_argument_type. + // + // Used to get the maximum power of two less then the width. + // + // Example: if on your platform argument_type has 48 value + // bits it yields n=32. + // + // It's easy to prove that, starting from such a value + // of n, the core algorithm works correctly for any width + // of static_log2_argument_type and that recursion always + // terminates with x = 1 and n = 0 (see the algorithm's + // invariant). + + typedef boost::static_log2_argument_type argument_type; + typedef boost::static_log2_result_type result_type; + + template + struct choose_initial_n { + + BOOST_STATIC_CONSTANT(bool, c = (argument_type(1) << n << n) != 0); + BOOST_STATIC_CONSTANT( + result_type, + value = !c*n + choose_initial_n<2*c*n>::value + ); + + }; + + template <> + struct choose_initial_n<0> { + BOOST_STATIC_CONSTANT(result_type, value = 0); + }; + + + + // start computing from n_zero - must be a power of two + const result_type n_zero = 16; + const result_type initial_n = choose_initial_n::value; + + // static_log2_impl<> + // + // * Invariant: + // 2n + // 1 <= x && x < 2 at the start of each recursion + // (see also choose_initial_n<>) + // + // * Type requirements: + // + // argument_type maybe any unsigned type with at least n_zero + 1 + // value bits. (Note: If larger types will be standardized -e.g. + // unsigned long long- then the argument_type typedef can be + // changed without affecting the rest of the code.) + // + + template + struct static_log2_impl { + + BOOST_STATIC_CONSTANT(bool, c = (x >> n) > 0); // x >= 2**n ? + BOOST_STATIC_CONSTANT( + result_type, + value = c*n + (static_log2_impl< (x>>c*n), n/2 >::value) + ); + + }; + + template <> + struct static_log2_impl<1, 0> { + BOOST_STATIC_CONSTANT(result_type, value = 0); + }; + + } + } // detail + + + + // -------------------------------------- + // static_log2 + // ---------------------------------------- + + template + struct static_log2 { + + BOOST_STATIC_CONSTANT( + static_log2_result_type, + value = detail::static_log2_impl::static_log2_impl::value + ); + + }; + + + template <> + struct static_log2<0> { }; + +} + + + +#endif // include guard diff --git a/src/third-party/boost/boost/intrusive/detail/config_begin.hpp b/src/third-party/boost/boost/intrusive/detail/config_begin.hpp new file mode 100644 index 00000000..8bd57a3b --- /dev/null +++ b/src/third-party/boost/boost/intrusive/detail/config_begin.hpp @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-2013 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_CONFIG_HPP +#include +#endif + +#ifdef BOOST_MSVC + + #pragma warning (push) + #pragma warning (disable : 4275) // non DLL-interface classkey "identifier" used as base for DLL-interface classkey "identifier" + #pragma warning (disable : 4251) // "identifier" : class "type" needs to have dll-interface to be used by clients of class "type2" + #pragma warning (disable : 4675) // "method" should be declared "static" and have exactly one parameter + #pragma warning (disable : 4996) // "function": was declared deprecated + #pragma warning (disable : 4503) // "identifier" : decorated name length exceeded, name was truncated + #pragma warning (disable : 4284) // odd return type for operator-> + #pragma warning (disable : 4244) // possible loss of data + #pragma warning (disable : 4521) ////Disable "multiple copy constructors specified" + #pragma warning (disable : 4127) //conditional expression is constant + #pragma warning (disable : 4146) // unary minus operator applied to unsigned type, result still unsigned + #pragma warning (disable : 4267) //conversion from 'X' to 'Y', possible loss of data + #pragma warning (disable : 4541) //'typeid' used on polymorphic type 'boost::exception' with /GR- + #pragma warning (disable : 4512) //'typeid' used on polymorphic type 'boost::exception' with /GR- + #pragma warning (disable : 4522) // "class" : multiple assignment operators specified + #pragma warning (disable : 4706) //assignment within conditional expression + #pragma warning (disable : 4710) // function not inlined + #pragma warning (disable : 4714) // "function": marked as __forceinline not inlined + #pragma warning (disable : 4711) // function selected for automatic inline expansion + #pragma warning (disable : 4786) // identifier truncated in debug info + #pragma warning (disable : 4996) // "function": was declared deprecated +#endif + +//#define BOOST_INTRUSIVE_USE_ITERATOR_FACADE +//#define BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE diff --git a/src/third-party/boost/boost/intrusive/detail/config_end.hpp b/src/third-party/boost/boost/intrusive/detail/config_end.hpp new file mode 100644 index 00000000..a081443e --- /dev/null +++ b/src/third-party/boost/boost/intrusive/detail/config_end.hpp @@ -0,0 +1,15 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-2013 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#if defined BOOST_MSVC + #pragma warning (pop) +#endif diff --git a/src/third-party/boost/boost/intrusive/detail/has_member_function_callable_with.hpp b/src/third-party/boost/boost/intrusive/detail/has_member_function_callable_with.hpp new file mode 100644 index 00000000..92ef60ee --- /dev/null +++ b/src/third-party/boost/boost/intrusive/detail/has_member_function_callable_with.hpp @@ -0,0 +1,366 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/container for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_CALLABLE_WITH_HPP +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_CALLABLE_WITH_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +//In case no decltype and no variadics, mark that we don't support 0 arg calls due to +//compiler ICE in GCC 3.4/4.0/4.1 and, wrong SFINAE for GCC 4.2/4.3/MSVC10/MSVC11 +#if defined(BOOST_NO_CXX11_DECLTYPE) && defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +# if defined(BOOST_GCC) && (BOOST_GCC < 40400) +# define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED +# elif defined(BOOST_INTEL) && (BOOST_INTEL < 1200) +# define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED +# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1800) +# define BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED +# endif +#endif //#if defined(BOOST_NO_CXX11_DECLTYPE) && defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +#include +#include +#include + +namespace boost_intrusive_hmfcw { + +typedef char yes_type; +struct no_type{ char dummy[2]; }; + +struct dont_care +{ + dont_care(...); +}; + +#if defined(BOOST_NO_CXX11_DECLTYPE) + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +template +struct make_dontcare +{ + typedef dont_care type; +}; + +#endif + +struct private_type +{ + static private_type p; + private_type const &operator,(int) const; +}; + +template +no_type is_private_type(T const &); +yes_type is_private_type(private_type const &); + +#endif //#if defined(BOOST_NO_CXX11_DECLTYPE) + +#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_DECLTYPE) + +template struct remove_cv { typedef T type; }; +template struct remove_cv { typedef T type; }; +template struct remove_cv { typedef T type; }; +template struct remove_cv { typedef T type; }; + +#endif + +} //namespace boost_intrusive_hmfcw { + +#endif //BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_CALLABLE_WITH_HPP + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME + #error "You MUST define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME before including this header!" +#endif + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN + #error "You MUST define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN before including this header!" +#endif + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX + #error "You MUST define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX before including this header!" +#endif + +#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX < BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN + #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX value MUST be greater or equal than BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN!" +#endif + +#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX == 0 + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF +#else + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF , +#endif + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG + #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG not defined!" +#endif + +#ifndef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END + #error "BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END not defined!" +#endif + +BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) + //With decltype and variadic templaes, things are pretty easy + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + template + static decltype(boost::move_detail::declval(). + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(::boost::move_detail::declval()...) + , boost_intrusive_hmfcw::yes_type()) Test(U* f); + template + static boost_intrusive_hmfcw::no_type Test(...); + static const bool value = sizeof(Test((Fun*)0)) == sizeof(boost_intrusive_hmfcw::yes_type); + }; + +#else //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_DECLTYPE) + + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// + // + // has_member_function_callable_with_impl_XXX + // declaration, special case and 0 arg specializaton + // + ///////////////////////////////////////////////////////// + + template + class BOOST_MOVE_CAT(has_member_function_named_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + struct BaseMixin + { + void BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME() + {} //Some compilers require the definition or linker errors happen + }; + + struct Base + : public boost_intrusive_hmfcw::remove_cv::type, public BaseMixin + { //Declare the unneeded default constructor as some old compilers wrongly require it with is_convertible + Base(){} + }; + template class Helper{}; + + template + static boost_intrusive_hmfcw::no_type deduce + (U*, Helper* = 0); + static boost_intrusive_hmfcw::yes_type deduce(...); + + public: + static const bool value = sizeof(boost_intrusive_hmfcw::yes_type) == sizeof(deduce((Base*)0)); + }; + + #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// + // + // has_member_function_callable_with_impl_XXX for 1 to N arguments + // + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// + + //defined(BOOST_NO_CXX11_DECLTYPE) must be true + template + struct FunWrapTmpl : Fun + { + using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME; + FunWrapTmpl(); + template + boost_intrusive_hmfcw::private_type BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(DontCares...) const; + }; + + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME); + + //No BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME member specialization + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + + { + static const bool value = false; + }; + + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + static bool const value = (sizeof(boost_intrusive_hmfcw::no_type) == sizeof(boost_intrusive_hmfcw::is_private_type + ( (::boost::move_detail::declval + < FunWrapTmpl >(). + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(::boost::move_detail::declval()...), 0) ) + ) + ); + }; + + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + : public BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + ::value + , Args...> + {}; + #else //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// + // + // has_member_function_callable_with_impl_XXX specializations + // + ///////////////////////////////////////////////////////// + + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME); + + //No BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME member specialization + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + + { + static const bool value = false; + }; + + #if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN == 0 + //0 arg specialization when BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME is present + #if !defined(BOOST_NO_CXX11_DECLTYPE) + + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + template + static decltype(boost::move_detail::declval().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME() + , boost_intrusive_hmfcw::yes_type()) Test(U* f); + + template + static boost_intrusive_hmfcw::no_type Test(...); + static const bool value = sizeof(Test((Fun*)0)) == sizeof(boost_intrusive_hmfcw::yes_type); + }; + + #else //defined(BOOST_NO_CXX11_DECLTYPE) + + #if !defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED) + + template().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(), 0)> + struct BOOST_MOVE_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { boost_intrusive_hmfcw::yes_type dummy[N ? 1 : 2]; }; + + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { + template static BOOST_MOVE_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + Test(BOOST_MOVE_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)*); + template static boost_intrusive_hmfcw::no_type Test(...); + static const bool value = sizeof(Test< Fun >(0)) == sizeof(boost_intrusive_hmfcw::yes_type); + }; + + #else //defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED) + + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + { //Some compilers gives ICE when instantiating the 0 arg version so it is not supported. + static const bool value = true; + }; + + #endif//!defined(BOOST_INTRUSIVE_DETAIL_HAS_MEMBER_FUNCTION_CALLABLE_WITH_0_ARGS_UNSUPPORTED) + #endif //!defined(BOOST_NO_CXX11_DECLTYPE) + #endif //#if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN == 0 + + #if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX > 0 + //1 to N arg specialization when BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME is present + //Declare some unneeded default constructor as some old compilers wrongly require it with is_convertible + #if defined(BOOST_NO_CXX11_DECLTYPE) + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION(N)\ + \ + template\ + struct BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)\ + : Fun\ + {\ + using Fun::BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME;\ + BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)();\ + boost_intrusive_hmfcw::private_type BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME\ + (BOOST_MOVE_REPEAT##N(boost_intrusive_hmfcw::dont_care)) const;\ + };\ + \ + template\ + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)\ + {\ + static bool const value = (sizeof(boost_intrusive_hmfcw::no_type) == sizeof(boost_intrusive_hmfcw::is_private_type\ + ( (::boost::move_detail::declval\ + < BOOST_MOVE_CAT(FunWrap##N, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) >().\ + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(BOOST_MOVE_DECLVAL##N), 0) )\ + )\ + );\ + };\ + // + #else + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION(N)\ + template\ + struct BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)\ + \ + {\ + template\ + static decltype(boost::move_detail::declval().\ + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME(BOOST_MOVE_DECLVAL##N)\ + , boost_intrusive_hmfcw::yes_type()) Test(U* f);\ + template\ + static boost_intrusive_hmfcw::no_type Test(...);\ + static const bool value = sizeof(Test((Fun*)0)) == sizeof(boost_intrusive_hmfcw::yes_type);\ + };\ + // + #endif + //////////////////////////////////// + // Build and invoke BOOST_MOVE_ITERATE_NTOM macrofunction, note that N has to be at least 1 + //////////////////////////////////// + #if BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN == 0 + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN 1 + #else + #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN + #endif + BOOST_MOVE_CAT + (BOOST_MOVE_CAT(BOOST_MOVE_CAT(BOOST_MOVE_ITERATE_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN), TO) + ,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX) + (BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION) + #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATION + #undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_ITERATE_MIN + //////////////////////////////////// + // End of BOOST_MOVE_ITERATE_NTOM + //////////////////////////////////// + #endif //BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX > 0 + + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// + // + // has_member_function_callable_with_FUNC + // + ///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// + + //Otherwise use the preprocessor + template + struct BOOST_MOVE_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + : public BOOST_MOVE_CAT(has_member_function_callable_with_impl_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME) + ::value + BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF BOOST_MOVE_CAT(BOOST_MOVE_TARG,BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX)> + {}; + #endif //defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#endif + +BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END + +//Undef local macros +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_COMMA_IF + +//Undef user defined macros +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG +#undef BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END diff --git a/src/third-party/boost/boost/intrusive/detail/mpl.hpp b/src/third-party/boost/boost/intrusive/detail/mpl.hpp new file mode 100644 index 00000000..15230881 --- /dev/null +++ b/src/third-party/boost/boost/intrusive/detail/mpl.hpp @@ -0,0 +1,216 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-2014 +// (C) Copyright Microsoft Corporation 2014 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_MPL_HPP +#define BOOST_INTRUSIVE_DETAIL_MPL_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#include +#include +#include + +namespace boost { +namespace intrusive { +namespace detail { + +using boost::move_detail::is_same; +using boost::move_detail::add_const; +using boost::move_detail::remove_const; +using boost::move_detail::remove_cv; +using boost::move_detail::remove_reference; +using boost::move_detail::add_reference; +using boost::move_detail::remove_pointer; +using boost::move_detail::add_pointer; +using boost::move_detail::true_type; +using boost::move_detail::false_type; +using boost::move_detail::enable_if_c; +using boost::move_detail::enable_if; +using boost::move_detail::disable_if_c; +using boost::move_detail::disable_if; +using boost::move_detail::is_convertible; +using boost::move_detail::if_c; +using boost::move_detail::if_; +using boost::move_detail::is_const; +using boost::move_detail::identity; +using boost::move_detail::alignment_of; +using boost::move_detail::is_empty; +using boost::move_detail::addressof; +using boost::move_detail::integral_constant; +using boost::move_detail::enable_if_convertible; +using boost::move_detail::disable_if_convertible; +using boost::move_detail::bool_; +using boost::move_detail::true_; +using boost::move_detail::false_; +using boost::move_detail::yes_type; +using boost::move_detail::no_type; +using boost::move_detail::apply; +using boost::move_detail::eval_if_c; +using boost::move_detail::eval_if; +using boost::move_detail::unvoid_ref; +using boost::move_detail::add_const_if_c; + +template +struct ls_zeros +{ + static const std::size_t value = (S & std::size_t(1)) ? 0 : (1 + ls_zeros<(S>>1u)>::value); +}; + +template<> +struct ls_zeros<0> +{ + static const std::size_t value = 0; +}; + +template<> +struct ls_zeros<1> +{ + static const std::size_t value = 0; +}; + +// Infrastructure for providing a default type for T::TNAME if absent. +#define BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(TNAME) \ + template \ + struct boost_intrusive_has_type_ ## TNAME \ + { \ + template \ + static char test(int, typename X::TNAME*); \ + \ + template \ + static int test(...); \ + \ + static const bool value = (1 == sizeof(test(0, 0))); \ + }; \ + \ + template \ + struct boost_intrusive_default_type_ ## TNAME \ + { \ + struct DefaultWrap { typedef DefaultType TNAME; }; \ + \ + typedef typename \ + ::boost::intrusive::detail::if_c \ + < boost_intrusive_has_type_ ## TNAME::value \ + , T, DefaultWrap>::type::TNAME type; \ + }; \ + // + +#define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \ + typename INSTANTIATION_NS_PREFIX \ + boost_intrusive_default_type_ ## TNAME< T, TIMPL >::type \ +// + +#define BOOST_INTRUSIVE_HAS_TYPE(INSTANTIATION_NS_PREFIX, T, TNAME) \ + INSTANTIATION_NS_PREFIX \ + boost_intrusive_has_type_ ## TNAME< T >::value \ +// + +#define BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(TNAME)\ + template \ + struct boost_intrusive_eval_default_type_ ## TNAME \ + { \ + template \ + static char test(int, typename X::TNAME*); \ + \ + template \ + static int test(...); \ + \ + struct DefaultWrap \ + { typedef typename DefaultType::type TNAME; }; \ + \ + static const bool value = (1 == sizeof(test(0, 0))); \ + \ + typedef typename \ + ::boost::intrusive::detail::eval_if_c \ + < value \ + , ::boost::intrusive::detail::identity \ + , ::boost::intrusive::detail::identity \ + >::type::TNAME type; \ + }; \ +// + +#define BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(INSTANTIATION_NS_PREFIX, T, TNAME, TIMPL) \ + typename INSTANTIATION_NS_PREFIX \ + boost_intrusive_eval_default_type_ ## TNAME< T, TIMPL >::type \ +// + +#define BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(TRAITS_PREFIX, TYPEDEF_TO_FIND) \ +template \ +struct TRAITS_PREFIX##_bool\ +{\ + template\ + struct two_or_three {yes_type _[2 + Add];};\ + template static yes_type test(...);\ + template static two_or_three test (int);\ + static const std::size_t value = sizeof(test(0));\ +};\ +\ +template \ +struct TRAITS_PREFIX##_bool_is_true\ +{\ + static const bool value = TRAITS_PREFIX##_bool::value > sizeof(yes_type)*2;\ +};\ +// + +#define BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(TRAITS_NAME, FUNC_NAME) \ + template \ + class TRAITS_NAME \ + { \ + private: \ + template struct helper;\ + template \ + static ::boost::intrusive::detail::yes_type test(helper<&T::FUNC_NAME>*); \ + template static ::boost::intrusive::detail::no_type test(...); \ + public: \ + static const bool value = sizeof(test(0)) == sizeof(::boost::intrusive::detail::yes_type); \ + }; \ +// + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED(TRAITS_NAME, FUNC_NAME) \ +template \ +struct TRAITS_NAME \ +{ \ + struct BaseMixin \ + { \ + void FUNC_NAME(); \ + }; \ + struct Base : public Type, public BaseMixin { Base(); }; \ + template class Helper{}; \ + template \ + static ::boost::intrusive::detail::no_type test(U*, Helper* = 0); \ + static ::boost::intrusive::detail::yes_type test(...); \ + static const bool value = sizeof(::boost::intrusive::detail::yes_type) == sizeof(test((Base*)(0))); \ +};\ +// + +#define BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED_IGNORE_SIGNATURE(TRAITS_NAME, FUNC_NAME) \ +BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED(TRAITS_NAME##_ignore_signature, FUNC_NAME) \ +\ +template \ +struct TRAITS_NAME \ + : public TRAITS_NAME##_ignore_signature \ +{};\ +// + +} //namespace detail +} //namespace intrusive +} //namespace boost + +#include + +#endif //BOOST_INTRUSIVE_DETAIL_MPL_HPP diff --git a/src/third-party/boost/boost/intrusive/detail/workaround.hpp b/src/third-party/boost/boost/intrusive/detail/workaround.hpp new file mode 100644 index 00000000..594ac0b2 --- /dev/null +++ b/src/third-party/boost/boost/intrusive/detail/workaround.hpp @@ -0,0 +1,53 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/interprocess for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP +#define BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +#ifndef BOOST_CONFIG_HPP +#include +#endif + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + #define BOOST_INTRUSIVE_PERFECT_FORWARDING +#endif + +//Macros for documentation purposes. For code, expands to the argument +#define BOOST_INTRUSIVE_IMPDEF(TYPE) TYPE +#define BOOST_INTRUSIVE_SEEDOC(TYPE) TYPE +#define BOOST_INTRUSIVE_DOC1ST(TYPE1, TYPE2) TYPE2 +#define BOOST_INTRUSIVE_I , +#define BOOST_INTRUSIVE_DOCIGN(T1) T1 + +#define BOOST_INTRUSIVE_DISABLE_FORCEINLINE + +#if defined(BOOST_INTRUSIVE_DISABLE_FORCEINLINE) + #define BOOST_INTRUSIVE_FORCEINLINE inline +#elif defined(BOOST_INTRUSIVE_FORCEINLINE_IS_BOOST_FORCELINE) + #define BOOST_INTRUSIVE_FORCEINLINE BOOST_FORCEINLINE +#elif defined(BOOST_MSVC) && defined(_DEBUG) + //"__forceinline" and MSVC seems to have some bugs in debug mode + #define BOOST_INTRUSIVE_FORCEINLINE inline +#elif defined(__GNUC__) && ((__GNUC__ < 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ < 5))) + //Older GCCs have problems with forceinline + #define BOOST_INTRUSIVE_FORCEINLINE inline +#else + #define BOOST_INTRUSIVE_FORCEINLINE BOOST_FORCEINLINE +#endif + +#endif //#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP diff --git a/src/third-party/boost/boost/intrusive/pointer_rebind.hpp b/src/third-party/boost/boost/intrusive/pointer_rebind.hpp new file mode 100644 index 00000000..9592e06e --- /dev/null +++ b/src/third-party/boost/boost/intrusive/pointer_rebind.hpp @@ -0,0 +1,188 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_POINTER_REBIND_HPP +#define BOOST_INTRUSIVE_POINTER_REBIND_HPP + +#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP +#include +#endif //BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP + +#ifndef BOOST_CONFIG_HPP +# include +#endif + +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + +namespace boost { +namespace intrusive { + +/////////////////////////// +//struct pointer_rebind_mode +/////////////////////////// +template +struct pointer_has_rebind +{ + template struct any + { any(const V&) { } }; + + template + static char test(int, typename X::template rebind*); + + template + static int test(any, void*); + + static const bool value = (1 == sizeof(test(0, 0))); +}; + +template +struct pointer_has_rebind_other +{ + template struct any + { any(const V&) { } }; + + template + static char test(int, typename X::template rebind::other*); + + template + static int test(any, void*); + + static const bool value = (1 == sizeof(test(0, 0))); +}; + +template +struct pointer_rebind_mode +{ + static const unsigned int rebind = (unsigned int)pointer_has_rebind::value; + static const unsigned int rebind_other = (unsigned int)pointer_has_rebind_other::value; + static const unsigned int mode = rebind + rebind*rebind_other; +}; + +//////////////////////// +//struct pointer_rebinder +//////////////////////// +template +struct pointer_rebinder; + +// Implementation of pointer_rebinder::type if Ptr has +// its own rebind::other type (C++03) +template +struct pointer_rebinder< Ptr, U, 2u > +{ + typedef typename Ptr::template rebind::other type; +}; + +// Implementation of pointer_rebinder::type if Ptr has +// its own rebind template. +template +struct pointer_rebinder< Ptr, U, 1u > +{ + typedef typename Ptr::template rebind type; +}; + +// Specialization of pointer_rebinder if Ptr does not +// have its own rebind template but has a the form Ptr, +// where An... comprises zero or more type parameters. +// Many types fit this form, hence many pointers will get a +// reasonable default for rebind. +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +template