forked from grf-labs/grf
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* master: Fix a typo in the `@keywords` roxygen directive. (grf-labs#481) Ensuring DiceKriging does not break forest training (grf-labs#455) CI: Disable lintr (grf-labs#480) Platform-independent random numbers [using stdlib copy] (grf-labs#469) test_regression_forest.R: fix argument name (grf-labs#477) CI: Only warn on lint error (grf-labs#474)
- Loading branch information
Showing
19 changed files
with
1,544 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# third_party/random | ||
|
||
## What are these files? | ||
|
||
They are copies of `random` and `algorithm` headers from the [llvm](https://github.com/llvm-mirror/libcxx/blob/master/include/) standard library. | ||
|
||
|
||
## Motivation | ||
|
||
Users complained about stability of random numbers across machines when setting seed across different platforms. See issue [#379](https://github.com/grf-labs/grf/issues/379). | ||
|
||
As [pointed out](https://github.com/grf-labs/grf/issues/379#issuecomment-480641123) by @jtibshirani: | ||
|
||
> the mersenne twister has the same implementation across platforms, the other random methods may differ from compiler to compiler | ||
|
||
In PR [#469](https://github.com/grf-labs/grf/pull/469), @halflearned included this reduced copy of the relevant headers, ensuring random number generation is done in a consistent way across compilers. | ||
|
||
|
||
## How to reproduce | ||
|
||
#### File `random.hpp` | ||
|
||
Extract only the relevant classes and functions from `random.hpp`: | ||
|
||
+ `__independent_bits_engine` | ||
+ `__clz` | ||
+ `__log2` | ||
+ `__log2_imp` | ||
+ `__generate_canonical` | ||
+ `uniform_int_distribution` | ||
+ `poisson_distribution` | ||
+ `uniform_real_distribution` | ||
+ `normal_distribution` | ||
+ `exponential_distribution` | ||
+ `discrete_distribution` | ||
|
||
From each class, remove all methods associated with `operator<<`. | ||
|
||
Find and remove the following `_LIBCPP` macros: | ||
+ `_LIBCPP_BEGIN_NAMESPACE_STD` | ||
+ `_LIBCPP_CONSTEXPR` | ||
+ `_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK` | ||
+ `_LIBCPP_END_NAMESPACE_STD` | ||
+ `_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER` | ||
+ `_LIBCPP_INLINE_VISIBILITY` | ||
+ `_LIBCPP_MSVCRT` | ||
+ `_LIBCPP_POP_MACROS` | ||
+ `_LIBCPP_PUSH_MACROS` | ||
+ `_LIBCPP_RANDOM` | ||
+ `_LIBCPP_TEMPLATE_VIS` | ||
+ `_LIBCPP_TYPE_VIS` | ||
+ `_LIBCPP_USING_DEV_RANDOM` | ||
|
||
Find and replace prefix: | ||
+ `_VSTD::` -> `std::` | ||
|
||
Add `namespace nonstd`. | ||
|
||
|
||
#### File `algorithm.hpp` | ||
|
||
Include modified `random.hpp` | ||
|
||
Extract relevant class: | ||
|
||
+ `shuffle` | ||
|
||
Replace prefix: | ||
|
||
+ `std::uniform_int_distribution` -> `nonstd::uniform_int_distribution` | ||
|
||
Add `namespace nonstd`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <limits> | ||
#include <cmath> | ||
#include <algorithm> | ||
#include <iterator> | ||
#include "random/random.hpp" | ||
|
||
#ifndef _GRFSTD_ALGORITHM | ||
#define _GRFSTD_ALGORITHM | ||
|
||
namespace nonstd { | ||
|
||
template<class _RandomAccessIterator, class _UniformRandomNumberGenerator> | ||
void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, | ||
#ifndef _LIBCPP_CXX03_LANG | ||
_UniformRandomNumberGenerator &&__g) | ||
#else | ||
_UniformRandomNumberGenerator& __g) | ||
#endif | ||
{ | ||
typedef typename std::iterator_traits<_RandomAccessIterator>::difference_type difference_type; | ||
typedef nonstd::uniform_int_distribution<ptrdiff_t> _Dp; | ||
typedef typename _Dp::param_type _Pp; | ||
difference_type __d = __last - __first; | ||
if (__d > 1) { | ||
_Dp __uid; | ||
for (--__last, --__d; __first < __last; ++__first, --__d) { | ||
difference_type __i = __uid(__g, _Pp(0, __d)); | ||
if (__i != difference_type(0)) | ||
std::swap(*__first, *(__first + __i)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif // _GRFSTD_ALGORITHM |
Oops, something went wrong.