From f7b22815103252925710180976cd9e09303c54b3 Mon Sep 17 00:00:00 2001 From: kalenhaha Date: Fri, 9 May 2014 14:14:43 +0800 Subject: [PATCH] fix some warnings --- regrank/xgboost_regrank_obj.hpp | 10 +++++----- regrank/xgboost_regrank_sample.h | 8 ++++---- utils/xgboost_omp.h | 2 +- utils/xgboost_random.h | 3 +-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/regrank/xgboost_regrank_obj.hpp b/regrank/xgboost_regrank_obj.hpp index 5fded0aa2..8b31d9dc9 100644 --- a/regrank/xgboost_regrank_obj.hpp +++ b/regrank/xgboost_regrank_obj.hpp @@ -342,14 +342,14 @@ namespace xgboost{ virtual inline void GetLambda(const std::vector &preds, const std::vector &labels, const std::vector &group_index, - const std::vector> &pairs, std::vector lambda, int group) = 0; + const std::vector< std::pair > &pairs, std::vector lambda, int group) = 0; inline void GetGroupGradient(const std::vector &preds, const std::vector &labels, const std::vector &group_index, std::vector &grad, std::vector &hess, - const std::vector> pairs, + const std::vector< std::pair > pairs, int group){ std::vector lambda; @@ -383,7 +383,7 @@ namespace xgboost{ utils::Assert(group_index.size() != 0 && group_index.back() == preds.size(), "rank loss must have group file"); for (size_t i = 0; i < group_index.size() - 1; i++){ - std::vector> pairs = sampler_.GenPairs(preds, info.labels, group_index[i], group_index[i + 1]); + std::vector< std::pair > pairs = sampler_.GenPairs(preds, info.labels, group_index[i], group_index[i + 1]); GetGroupGradient(preds, info.labels, group_index, grad, hess, pairs, i); } } @@ -428,7 +428,7 @@ namespace xgboost{ inline void GetLambda(const std::vector &preds, const std::vector &labels, const std::vector &group_index, - const std::vector> &pairs, std::vector lambda, int group){ + const std::vector< std::pair > &pairs, std::vector lambda, int group){ std::vector< Triple > sorted_triple; std::vector index_remap; float IDCG; @@ -515,7 +515,7 @@ namespace xgboost{ inline void GetLambda(const std::vector &preds, const std::vector &labels, const std::vector &group_index, - const std::vector> &pairs, std::vector lambda, int group){ + const std::vector< std::pair > &pairs, std::vector lambda, int group){ std::vector< Triple > sorted_triple; std::vector index_remap; std::vector< Quadruple > map_acc; diff --git a/regrank/xgboost_regrank_sample.h b/regrank/xgboost_regrank_sample.h index 0ae147b21..fa4d82f84 100644 --- a/regrank/xgboost_regrank_sample.h +++ b/regrank/xgboost_regrank_sample.h @@ -62,7 +62,7 @@ namespace xgboost { * \param end, the end index of a specified group * \return the generated pairs */ - virtual std::vector> GenPairs(const std::vector &preds, + virtual std::vector< std::pair > GenPairs(const std::vector &preds, const std::vector &labels, int start, int end) = 0; @@ -78,10 +78,10 @@ namespace xgboost { * we should guarantee the labels are 0 or 1 */ struct BinaryLinearSampler :public IPairSampler{ - virtual std::vector> GenPairs(const std::vector &preds, + virtual std::vector< std::pair > GenPairs(const std::vector &preds, const std::vector &labels, int start, int end) { - std::vector> ans; + std::vector< std::pair > ans; return ans; } }; @@ -100,7 +100,7 @@ namespace xgboost { ~PairSamplerWrapper(){ delete sampler_; } - std::vector> GenPairs(const std::vector &preds, + std::vector< std::pair > GenPairs(const std::vector &preds, const std::vector &labels, int start, int end){ utils::Assert(sampler_ != NULL, "Not config the sampler yet. Add rank:sampler in the config file\n"); diff --git a/utils/xgboost_omp.h b/utils/xgboost_omp.h index 3a8062b7e..ea1e7173c 100644 --- a/utils/xgboost_omp.h +++ b/utils/xgboost_omp.h @@ -10,7 +10,7 @@ #if defined(_OPENMP) #include #else -//#warning "OpenMP is not available, compile to single thread code" +#warning "OpenMP is not available, compile to single thread code" inline int omp_get_thread_num() { return 0; } inline int omp_get_num_threads() { return 1; } inline void omp_set_num_threads(int nthread) {} diff --git a/utils/xgboost_random.h b/utils/xgboost_random.h index 358ac2074..c4a4e763e 100644 --- a/utils/xgboost_random.h +++ b/utils/xgboost_random.h @@ -137,8 +137,7 @@ namespace xgboost{ } /*! \brief return a real number uniform in [0,1) */ inline double RandDouble( void ){ -// return static_cast( rand_r( &rseed ) ) / (static_cast( RAND_MAX )+1.0); - return 0; + return static_cast( rand_r( &rseed ) ) / (static_cast( RAND_MAX )+1.0); } // random number seed unsigned rseed;