fix windows warnings

This commit is contained in:
Tianqi Chen 2015-04-19 00:20:52 -07:00
parent 9527b55f35
commit 18277086d9
5 changed files with 16 additions and 14 deletions

View File

@ -6,10 +6,11 @@
*/
#ifndef XGBOOST_IO_LIBSVM_PARSER_H_
#define XGBOOST_IO_LIBSVM_PARSER_H_
#define NOMINMAX
#include <vector>
#include <cstring>
#include <cctype>
#include <algorithm>
#include "../utils/omp.h"
#include "../utils/utils.h"
#include "../sync/sync.h"
@ -120,12 +121,12 @@ class LibSVMPageFactory {
while (isdigit(*p) && p != end) ++p;
if (*p == ':') {
out->data.push_back(SparseBatch::Entry(atol(head),
atof(p + 1)));
static_cast<bst_float>(atof(p + 1))));
} else {
if (out->label.size() != 0) {
out->offset.push_back(out->data.size());
}
out->label.push_back(atof(head));
out->label.push_back(static_cast<float>(atof(head)));
}
while (!isspace(*p) && p != end) ++p;
}

View File

@ -26,7 +26,7 @@ class ThreadColPageIterator: public utils::IIterator<ColBatch> {
for (size_t i = 0; i < col_data_.size(); ++i) {
col_data_[i] = SparseBatch::Inst
(BeginPtr(page_->data) + page_->offset[i],
page_->offset[i + 1] - page_->offset[i]);
static_cast<bst_uint>(page_->offset[i + 1] - page_->offset[i]));
}
out_.col_data = BeginPtr(col_data_);
out_.size = col_data_.size();
@ -110,7 +110,7 @@ class FMatrixPage : public IFMatrix {
size_t ncol = this->NumCol();
col_index_.resize(0);
for (size_t i = 0; i < ncol; ++i) {
col_index_.push_back(i);
col_index_.push_back(static_cast<bst_uint>(i));
}
col_iter_.SetIndexSet(col_index_, false);
col_iter_.BeforeFirst();
@ -229,7 +229,7 @@ class FMatrixPage : public IFMatrix {
#pragma omp parallel for schedule(static)
for (bst_omp_uint i = 0; i < ndata; ++i) {
int tid = omp_get_thread_num();
for (bst_uint j = prow.offset[i]; j < prow.offset[i+1]; ++j) {
for (size_t j = prow.offset[i]; j < prow.offset[i+1]; ++j) {
const SparseBatch::Entry &e = prow.data[j];
if (enabled[e.index]) {
builder.AddBudget(e.index, tid);
@ -240,7 +240,7 @@ class FMatrixPage : public IFMatrix {
#pragma omp parallel for schedule(static)
for (bst_omp_uint i = 0; i < ndata; ++i) {
int tid = omp_get_thread_num();
for (bst_uint j = prow.offset[i]; j < prow.offset[i+1]; ++j) {
for (size_t j = prow.offset[i]; j < prow.offset[i+1]; ++j) {
const SparseBatch::Entry &e = prow.data[j];
builder.Push(e.index,
SparseBatch::Entry(ridx[i], e.fvalue),

View File

@ -165,7 +165,8 @@ class FMatrixS : public IFMatrix {
while (iter_->Next()) {
const RowBatch &batch = iter_->Value();
bmap.resize(bmap.size() + batch.size, true);
for (size_t i = 0; i < batch.size; ++i) {
long batch_size = static_cast<long>(batch.size);
for (long i = 0; i < batch_size; ++i) {
bst_uint ridx = static_cast<bst_uint>(batch.base_rowid + i);
if (pkeep == 1.0f || random::SampleBinary(pkeep)) {
buffered_rowset_.push_back(ridx);
@ -174,7 +175,7 @@ class FMatrixS : public IFMatrix {
}
}
#pragma omp parallel for schedule(static)
for (size_t i = 0; i < batch.size; ++i) {
for (long i = 0; i < batch_size; ++i) {
int tid = omp_get_thread_num();
bst_uint ridx = static_cast<bst_uint>(batch.base_rowid + i);
if (bmap[ridx]) {
@ -193,7 +194,7 @@ class FMatrixS : public IFMatrix {
while (iter_->Next()) {
const RowBatch &batch = iter_->Value();
#pragma omp parallel for schedule(static)
for (size_t i = 0; i < batch.size; ++i) {
for (long i = 0; i < static_cast<long>(batch.size); ++i) {
int tid = omp_get_thread_num();
bst_uint ridx = static_cast<bst_uint>(batch.base_rowid + i);
if (bmap[ridx]) {

View File

@ -130,7 +130,7 @@ struct EvalMClassBase : public IEvaluator {
const float wt = info.GetWeight(i);
int label = static_cast<int>(info.labels[i]);
if (label >= 0 && label < static_cast<int>(nclass)) {
sum += Derived::EvalRow(info.labels[i],
sum += Derived::EvalRow(label,
BeginPtr(preds) + i * nclass,
nclass) * wt;
wsum += wt;

View File

@ -149,9 +149,9 @@ extern "C"{
DMatrixSimple &mat = *p_mat;
utils::ParallelGroupBuilder<RowBatch::Entry> builder(&mat.row_ptr_, &mat.row_data_);
builder.InitBudget(0, nthread);
bst_ulong ncol = nindptr - 1;
long ncol = static_cast<long>(nindptr - 1);
#pragma omp parallel for schedule(static)
for (bst_ulong i = 0; i < ncol; ++i) {
for (long i = 0; i < ncol; ++i) {
int tid = omp_get_thread_num();
for (unsigned j = col_ptr[i]; j < col_ptr[i+1]; ++j) {
builder.AddBudget(indices[j], tid);
@ -159,7 +159,7 @@ extern "C"{
}
builder.InitStorage();
#pragma omp parallel for schedule(static)
for (bst_ulong i = 0; i < ncol; ++i) {
for (long i = 0; i < ncol; ++i) {
int tid = omp_get_thread_num();
for (unsigned j = col_ptr[i]; j < col_ptr[i+1]; ++j) {
builder.Push(indices[j],