aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@gmail.com>2016-06-08 10:35:44 +0800
committerAaron LI <aaronly.me@gmail.com>2016-06-08 10:35:44 +0800
commit07a92b6abede8ba98bf7edcf5aa18dedc61db999 (patch)
treea7b6ed0d325c9e69803bee0a1bc24f824d8d2863
parent0c1664bb92a407cdbc2a7d0396e38edb3e911632 (diff)
downloadopt-utilities-07a92b6abede8ba98bf7edcf5aa18dedc61db999.tar.bz2
Fix minor compilation warnings
-rw-r--r--data_sets/default_data_set.hpp14
-rw-r--r--statistics/logchisq.hpp38
2 files changed, 25 insertions, 27 deletions
diff --git a/data_sets/default_data_set.hpp b/data_sets/default_data_set.hpp
index 51e6b70..696403e 100644
--- a/data_sets/default_data_set.hpp
+++ b/data_sets/default_data_set.hpp
@@ -26,7 +26,7 @@ namespace opt_utilities
// private:
public:
std::vector<data<Ty,Tx> > data_vec;
-
+
data_set<Ty,Tx>* do_clone()const
{
return new default_data_set<Ty,Tx>(*this);
@@ -37,17 +37,17 @@ namespace opt_utilities
{
return data_vec.at(i);
}
-
+
size_t do_size()const
{
return data_vec.size();
}
-
+
void do_add_data(const data<Ty,Tx>& d)
{
data_vec.push_back(d);
}
-
+
void do_clear()
{
data_vec.clear();
@@ -56,7 +56,7 @@ namespace opt_utilities
public:
default_data_set()
{}
-
+
default_data_set(const default_data_set<Ty,Tx>& rhs)
:data_vec(rhs.data_vec)
{}
@@ -64,7 +64,7 @@ namespace opt_utilities
default_data_set(const data_set<Ty,Tx>& rhs)
{
data_vec.resize(rhs.size());
- for(int i=0;i<data_vec.size();++i)
+ for(size_t i=0;i<data_vec.size();++i)
{
data_vec[i]=(rhs.get_data(i));
}
@@ -86,7 +86,7 @@ namespace opt_utilities
return *this;
}
-
+
};
}
diff --git a/statistics/logchisq.hpp b/statistics/logchisq.hpp
index 57cf7aa..c9601c1 100644
--- a/statistics/logchisq.hpp
+++ b/statistics/logchisq.hpp
@@ -24,8 +24,8 @@ namespace opt_utilities
:opt_exception("log chisq statistics cannot be used when has negative data!")
{}
};
-
-
+
+
/**
\brief chi-square statistic
@@ -42,8 +42,8 @@ namespace opt_utilities
private:
bool verb;
int n;
-
-
+
+
statistic<Ty,Tx,Tp,Ts,Tstr>* do_clone()const
{
// return const_cast<statistic<Ty,Tx,Tp>*>(this);
@@ -54,7 +54,7 @@ namespace opt_utilities
{
return "chi^2 statistic";
}
-
+
public:
void verbose(bool v)
{
@@ -64,8 +64,8 @@ namespace opt_utilities
logchisq()
:verb(false)
{}
-
-
+
+
Ts do_eval(const Tp& p)
{
@@ -93,7 +93,7 @@ namespace opt_utilities
}
}
-
+
return result;
}
};
@@ -113,7 +113,7 @@ namespace opt_utilities
private:
bool verb;
int n;
-
+
statistic<Ty,Tx,Tp,Ts,Tstr>* do_clone()const
{
// return const_cast<statistic<Ty,Tx,Tp>*>(this);
@@ -133,19 +133,19 @@ namespace opt_utilities
logchisq()
:verb(false)
{}
-
-
+
+
Ty do_eval(const Tp& p)
{
Ty result(0);
- for(int i=0;i!=(this->get_data_set()).size();++i)
+ for(size_t i=0;i!=(this->get_data_set()).size();++i)
{
Ty y_model=this->eval_model(this->get_data_set().get_data(i).get_x(),p);
Ty y_obs=this->get_data_set().get_data(i).get_y();
Ty y_err;
-
+
if(y_model>y_obs)
{
y_err=std::abs(this->get_data_set().get_data(i).get_y_upper_err());
@@ -161,10 +161,10 @@ namespace opt_utilities
Ty logy=std::log(y_obs);
Ty logym=std::log(y_model);
Ty logerr=std::log(y_obs+y_err)-log(y_obs);
-
-
+
+
Ty chi=(logy-logym)/logerr;
-
+
// Ty chi=(this->get_data_set().get_data(i).get_y()-this->eval_model(this->get_data_set().get_data(i).get_x(),p));
// cerr<<chi<<"\n";
result+=chi*chi;
@@ -187,15 +187,13 @@ namespace opt_utilities
}
}
-
+
return result;
}
};
#endif
-
+
}
#endif
//EOF
-
-