fix som solaris

This commit is contained in:
tqchen 2014-09-02 00:12:15 -07:00
parent bb5c151f57
commit c9f2f47acb
5 changed files with 17 additions and 19 deletions

View File

@ -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_);

View File

@ -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<float> &weights = this->GetFloatInfo(field);
std::vector<float> &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);

View File

@ -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;

View File

@ -29,7 +29,6 @@ class TreeRefresher: public IUpdater {
const std::vector<RegTree*> &trees) {
if (trees.size() == 0) return;
// number of threads
int nthread;
// thread temporal space
std::vector< std::vector<TStats> > stemp;
std::vector<RegTree::FVec> fvec_temp;

View File

@ -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);