Solve warning about comparison between signed and unsigned integer expressions.
authorDariusz Murakowski <murakdar@mit.edu>
Thu, 23 Apr 2015 05:37:30 +0000 (01:37 -0400)
committerDariusz Murakowski <murakdar@mit.edu>
Thu, 23 Apr 2015 05:37:30 +0000 (01:37 -0400)
ham_ss.cpp
ham_ss.h

index 323617d..9eba31a 100644 (file)
@@ -164,13 +164,13 @@ PottsHamiltonian::PottsHamiltonian(std::string &FILENAME) {
 // Also, "gauge fixing" sets field and couplings between
 // the commonest states to zero.
 
-double PottsHamiltonian::get_energy(const std::vector<int> &config) const {
+double PottsHamiltonian::get_energy(const std::vector<unsigned> &config) const {
     
     // Compute energy of the input configuration
     
     double E = 0;
     
-    for (int i=0;i<config.size();i++) {
+    for (unsigned i=0;i<config.size();i++) {
 
         //assert(config[i] <= J[i].size());
         
@@ -178,9 +178,10 @@ double PottsHamiltonian::get_energy(const std::vector<int> &config) const {
         
             E -= J[i][config[i]];
             
-            for (int j=i+1;j<config.size();j++) {
+            for (unsigned j=i+1;j<config.size();j++) {
             
-                if (config[j]!=J[i].size()) E -= J[index(i,j,config.size())][sindex(config[i],config[j],J[i].size(),J[j].size())];
+                if (config[j]!=J[i].size())
+                    E -= J[index(i,j,config.size())][sindex(config[i],config[j],J[i].size(),J[j].size())];
                 
             }
             
index dc949b2..d18306f 100644 (file)
--- a/ham_ss.h
+++ b/ham_ss.h
@@ -80,7 +80,7 @@ public:
     PottsHamiltonian(std::string &FILENAME);
     PottsHamiltonian() : bh(1.0), bJ(1.0) { }
     
-    double get_energy(const std::vector<int> &config) const;
+    double get_energy(const std::vector<unsigned> &config) const;
     
     void set_temp(double x)           { bh=x; bJ=x; }
     void set_temp(double x, double y) { bh=x; bJ=y; }