Merge branch 'master' of https://github.com/tqchen/xgboost
Initial development of R pacakge and merge with the modification from tqchen.
This commit is contained in:
commit
d9f363632a
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,3 +35,4 @@ Debug
|
|||||||
*suo
|
*suo
|
||||||
*test*
|
*test*
|
||||||
.Rhistory
|
.Rhistory
|
||||||
|
*.dll
|
||||||
|
|||||||
@ -213,7 +213,7 @@ extern "C" {
|
|||||||
&olen);
|
&olen);
|
||||||
FILE *fo = utils::FopenCheck(CHAR(asChar(fname)), "w");
|
FILE *fo = utils::FopenCheck(CHAR(asChar(fname)), "w");
|
||||||
for (size_t i = 0; i < olen; ++i) {
|
for (size_t i = 0; i < olen; ++i) {
|
||||||
fprintf(fo, "booster[%lu]:\n", i);
|
fprintf(fo, "booster[%u]:\n", static_cast<unsigned>(i));
|
||||||
fprintf(fo, "%s", res[i]);
|
fprintf(fo, "%s", res[i]);
|
||||||
}
|
}
|
||||||
fclose(fo);
|
fclose(fo);
|
||||||
|
|||||||
@ -10,7 +10,9 @@
|
|||||||
#else
|
#else
|
||||||
#ifndef DISABLE_OPENMP
|
#ifndef DISABLE_OPENMP
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#warning "OpenMP is not available, compile to single thread code"
|
#warning "OpenMP is not available, compile to single thread code."\
|
||||||
|
"You may want to ungrade your compiler to enable OpenMP support,"\
|
||||||
|
"to get benefit of multi-threading."
|
||||||
#else
|
#else
|
||||||
// TODO add warning for msvc
|
// TODO add warning for msvc
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -89,16 +89,19 @@ struct Random{
|
|||||||
/*! \brief set random number seed */
|
/*! \brief set random number seed */
|
||||||
inline void Seed(unsigned sd) {
|
inline void Seed(unsigned sd) {
|
||||||
this->rseed = sd;
|
this->rseed = sd;
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER)||defined(_WIN32)
|
||||||
srand(rseed);
|
srand(rseed);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/*! \brief return a real number uniform in [0,1) */
|
/*! \brief return a real number uniform in [0,1) */
|
||||||
inline double RandDouble(void) {
|
inline double RandDouble(void) {
|
||||||
#ifndef _MSC_VER
|
// use rand instead of rand_r in windows, for MSVC it is fine since rand is threadsafe
|
||||||
return static_cast<double>(rand_r(&rseed)) / (static_cast<double>(RAND_MAX) + 1.0);
|
// For cygwin and mingw, this can slows down parallelism, but rand_r is only used in objective-inl.hpp, won't affect speed in general
|
||||||
#else
|
// todo, replace with another PRNG
|
||||||
|
#if defined(_MSC_VER)||defined(_WIN32)
|
||||||
return static_cast<double>(rand()) / (static_cast<double>(RAND_MAX) + 1.0);
|
return static_cast<double>(rand()) / (static_cast<double>(RAND_MAX) + 1.0);
|
||||||
|
#else
|
||||||
|
return static_cast<double>(rand_r(&rseed)) / (static_cast<double>(RAND_MAX) + 1.0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// random number seed
|
// random number seed
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user