From c9f2f47acbf66713a2d50b0022d4c942b9819952 Mon Sep 17 00:00:00 2001 From: tqchen Date: Tue, 2 Sep 2014 00:12:15 -0700 Subject: [PATCH] fix som solaris --- src/io/simple_dmatrix-inl.hpp | 10 +++++----- src/learner/dmatrix.h | 4 ++-- src/tree/param.h | 18 +++++++++--------- src/tree/updater_refresh-inl.hpp | 1 - src/utils/io.h | 3 +-- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/io/simple_dmatrix-inl.hpp b/src/io/simple_dmatrix-inl.hpp index 36c6c8fd7..ca2eeadac 100644 --- a/src/io/simple_dmatrix-inl.hpp +++ b/src/io/simple_dmatrix-inl.hpp @@ -147,9 +147,9 @@ class DMatrixSimple : public DataMatrix { * \param fname file name, used to print message */ inline void LoadBinary(utils::IStream &fs, bool silent = false, const char *fname = NULL) { - int magic; - utils::Check(fs.Read(&magic, sizeof(magic)) != 0, "invalid input file format"); - utils::Check(magic == kMagic, "invalid format,magic number mismatch"); + int tmagic; + utils::Check(fs.Read(&tmagic, sizeof(tmagic)) != 0, "invalid input file format"); + utils::Check(tmagic == kMagic, "invalid format,magic number mismatch"); info.LoadBinary(fs); FMatrixS::LoadBinary(fs, &row_ptr_, &row_data_); @@ -177,8 +177,8 @@ class DMatrixSimple : public DataMatrix { */ inline void SaveBinary(const char* fname, bool silent = false) const { utils::FileStream fs(utils::FopenCheck(fname, "wb")); - int magic = kMagic; - fs.Write(&magic, sizeof(magic)); + int tmagic = kMagic; + fs.Write(&tmagic, sizeof(tmagic)); info.SaveBinary(fs); FMatrixS::SaveBinary(fs, row_ptr_, row_data_); diff --git a/src/learner/dmatrix.h b/src/learner/dmatrix.h index 791b3467d..bef84900a 100644 --- a/src/learner/dmatrix.h +++ b/src/learner/dmatrix.h @@ -125,12 +125,12 @@ struct MetaInfo { } // try to load weight information from file, if exists inline bool TryLoadFloatInfo(const char *field, const char* fname, bool silent = false) { - std::vector &weights = this->GetFloatInfo(field); + std::vector &data = this->GetFloatInfo(field); FILE *fi = fopen64(fname, "r"); if (fi == NULL) return false; float wt; while (fscanf(fi, "%f", &wt) == 1) { - weights.push_back(wt); + data.push_back(wt); } if (!silent) { utils::Printf("loading %s from %s\n", field, fname); diff --git a/src/tree/param.h b/src/tree/param.h index 52c273749..602644e85 100644 --- a/src/tree/param.h +++ b/src/tree/param.h @@ -295,14 +295,14 @@ struct SplitEntry{ * \brief decides whether a we can replace current entry with the statistics given * This function gives better priority to lower index when loss_chg equals * not the best way, but helps to give consistent result during multi-thread execution - * \param loss_chg the loss reduction get through the split + * \param new_loss_chg the loss reduction get through the split * \param split_index the feature index where the split is on */ - inline bool NeedReplace(bst_float loss_chg, unsigned split_index) const { + inline bool NeedReplace(bst_float new_loss_chg, unsigned split_index) const { if (this->split_index() <= split_index) { - return loss_chg > this->loss_chg; + return new_loss_chg > this->loss_chg; } else { - return !(this->loss_chg > loss_chg); + return !(this->loss_chg > new_loss_chg); } } /*! @@ -322,19 +322,19 @@ struct SplitEntry{ } /*! * \brief update the split entry, replace it if e is better - * \param loss_chg loss reduction of new candidate + * \param new_loss_chg loss reduction of new candidate * \param split_index feature index to split on * \param split_value the split point * \param default_left whether the missing value goes to left * \return whether the proposed split is better and can replace current split */ - inline bool Update(bst_float loss_chg, unsigned split_index, - float split_value, bool default_left) { + inline bool Update(bst_float new_loss_chg, unsigned split_index, + float new_split_value, bool default_left) { if (this->NeedReplace(loss_chg, split_index)) { - this->loss_chg = loss_chg; + this->loss_chg = new_loss_chg; if (default_left) split_index |= (1U << 31); this->sindex = split_index; - this->split_value = split_value; + this->split_value = new_split_value; return true; } else { return false; diff --git a/src/tree/updater_refresh-inl.hpp b/src/tree/updater_refresh-inl.hpp index d184dcb39..2c7b19bea 100644 --- a/src/tree/updater_refresh-inl.hpp +++ b/src/tree/updater_refresh-inl.hpp @@ -29,7 +29,6 @@ class TreeRefresher: public IUpdater { const std::vector &trees) { if (trees.size() == 0) return; // number of threads - int nthread; // thread temporal space std::vector< std::vector > stemp; std::vector fvec_temp; diff --git a/src/utils/io.h b/src/utils/io.h index 4a80e9a58..a15e2f0ce 100644 --- a/src/utils/io.h +++ b/src/utils/io.h @@ -93,8 +93,7 @@ class FileStream : public IStream { private: FILE *fp; public: - explicit FileStream(FILE *fp) { - this->fp = fp; + explicit FileStream(FILE *fp) : fp(fp) { } virtual size_t Read(void *ptr, size_t size) { return fread(ptr, size, 1, fp);