fix windows run

This commit is contained in:
Tianqi Chen
2014-11-23 22:12:55 -08:00
parent 77ffd0465b
commit fde580b08e
5 changed files with 43 additions and 18 deletions

View File

@@ -8,7 +8,9 @@
#include <algorithm>
// include all std functions
using namespace std;
#ifdef _MSC_VER
#define isnan(x) (_isnan(x) != 0)
#endif
#include "./xgboost_wrapper.h"
#include "../src/data.h"
#include "../src/learner/learner-inl.hpp"
@@ -149,7 +151,7 @@ extern "C"{
bst_ulong nrow,
bst_ulong ncol,
float missing) {
bool nan_missing = std::isnan(missing);
bool nan_missing = isnan(missing);
DMatrixSimple *p_mat = new DMatrixSimple();
DMatrixSimple &mat = *p_mat;
mat.info.info.num_row = nrow;
@@ -157,7 +159,7 @@ extern "C"{
for (bst_ulong i = 0; i < nrow; ++i, data += ncol) {
bst_ulong nelem = 0;
for (bst_ulong j = 0; j < ncol; ++j) {
if (std::isnan(data[j])) {
if (isnan(data[j])) {
utils::Check(nan_missing, "There are NAN in the matrix, however, you did not set missing=NAN");
} else {
if (nan_missing || data[j] != missing) {