From ac1cc15b905cb4ce22c63530d096d2da0376737f Mon Sep 17 00:00:00 2001 From: tqchen Date: Fri, 15 Aug 2014 21:24:23 -0700 Subject: [PATCH] pass fmatrix as const --- src/gbm/gbm.h | 2 +- src/gbm/gbtree-inl.hpp | 4 ++-- src/tree/updater.h | 2 +- src/tree/updater_colmaker-inl.hpp | 8 +++++--- src/tree/updater_prune-inl.hpp | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gbm/gbm.h b/src/gbm/gbm.h index 640bcbafc..5a9a3af98 100644 --- a/src/gbm/gbm.h +++ b/src/gbm/gbm.h @@ -46,7 +46,7 @@ class IGradBooster { * root_index.size() can be 0 which indicates that no pre-partition involved */ virtual void DoBoost(const std::vector &gpair, - FMatrix &fmat, + const FMatrix &fmat, const std::vector &root_index) = 0; /*! * \brief generate predictions for given feature matrix diff --git a/src/gbm/gbtree-inl.hpp b/src/gbm/gbtree-inl.hpp index d610ce5ad..5ccbcd1f1 100644 --- a/src/gbm/gbtree-inl.hpp +++ b/src/gbm/gbtree-inl.hpp @@ -83,7 +83,7 @@ class GBTree : public IGradBooster { utils::Assert(trees.size() == 0, "GBTree: model already initialized"); } virtual void DoBoost(const std::vector &gpair, - FMatrix &fmat, + const FMatrix &fmat, const std::vector &root_index) { if (mparam.num_output_group == 1) { this->BoostNewTrees(gpair, fmat, root_index, 0); @@ -174,7 +174,7 @@ class GBTree : public IGradBooster { } // do group specific group inline void BoostNewTrees(const std::vector &gpair, - FMatrix &fmat, + const FMatrix &fmat, const std::vector &root_index, int bst_group) { this->InitUpdater(); diff --git a/src/tree/updater.h b/src/tree/updater.h index 50b30e69f..5c4075b65 100644 --- a/src/tree/updater.h +++ b/src/tree/updater.h @@ -37,7 +37,7 @@ class IUpdater { * there can be multiple trees when we train random forest style model */ virtual void Update(const std::vector &gpair, - FMatrix &fmat, + const FMatrix &fmat, const std::vector &root_index, const std::vector &trees) = 0; // destructor diff --git a/src/tree/updater_colmaker-inl.hpp b/src/tree/updater_colmaker-inl.hpp index 483f0fda8..1868f8f41 100644 --- a/src/tree/updater_colmaker-inl.hpp +++ b/src/tree/updater_colmaker-inl.hpp @@ -24,7 +24,7 @@ class ColMaker: public IUpdater { param.SetParam(name, val); } virtual void Update(const std::vector &gpair, - FMatrix &fmat, + const FMatrix &fmat, const std::vector &root_index, const std::vector &trees) { @@ -71,7 +71,8 @@ class ColMaker: public IUpdater { // constructor explicit Builder(const TrainParam ¶m) : param(param) {} // update one tree, growing - virtual void Update(const std::vector &gpair, FMatrix &fmat, + virtual void Update(const std::vector &gpair, + const FMatrix &fmat, const std::vector &root_index, RegTree *p_tree) { this->InitData(gpair, fmat, root_index, *p_tree); @@ -100,7 +101,8 @@ class ColMaker: public IUpdater { private: // initialize temp data structure - inline void InitData(const std::vector &gpair, FMatrix &fmat, + inline void InitData(const std::vector &gpair, + const FMatrix &fmat, const std::vector &root_index, const RegTree &tree) { utils::Assert(tree.param.num_nodes == tree.param.num_roots, "ColMaker: can only grow new tree"); {// setup position diff --git a/src/tree/updater_prune-inl.hpp b/src/tree/updater_prune-inl.hpp index e96951684..bfb71b727 100644 --- a/src/tree/updater_prune-inl.hpp +++ b/src/tree/updater_prune-inl.hpp @@ -21,7 +21,8 @@ class TreePruner: public IUpdater { param.SetParam(name, val); } // update the tree, do pruning - virtual void Update(const std::vector &gpair, FMatrix &fmat, + virtual void Update(const std::vector &gpair, + const FMatrix &fmat, const std::vector &root_index, const std::vector &trees) { for (size_t i = 0; i < trees.size(); ++i) {