lean
Avril 4 years ago
parent eec7fa4167
commit 315295bbf1
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -9,12 +9,23 @@ extern "C" {
void frng_test();
void xorng_test();
void drng_test();
void rng_test();
#ifdef __cplusplus
}
// RNG interfaces
#include <rng/frng.hpp>
#include <rng/drng.hpp>
#include <rng/xoroshiro128plus.hpp>
namespace rng {
void test_algo(RNG&& rng);
template<class R,
typename std::enable_if<std::is_base_of<RNG, R>::value>::value __fuck>
inline void test_algo(R&& rng) { test_algo(static_cast<RNG&&>(rng)); }
}
#endif
#endif /* _RNG_H */

@ -43,9 +43,10 @@ int main(int argc, char** argv)
{
struct prog_args args = {.argc = argc, .argv = argv};
frng_test();
xorng_test();
drng_test();
rng_test();
//frng_test();
//xorng_test();
//drng_test();
if( argv[1] ) {
map_and_then(argv[1], &map_callback, &args);

@ -2,7 +2,7 @@
#include <ctime>
#include <iostream>
#include <rng/drng.h>
#include <rng/drng.hpp>
namespace rng
{

@ -0,0 +1,37 @@
#include <iostream>
#include <rng.h>
namespace rng {
void test_algo(RNG&& rng)
{
using namespace std;
for(int i=0;i<10;i++) {
double d = rng.next_double();
long l = rng.next_long(-10, 10);
std::array<bool, 10> ar;
for(auto& i : ar) i = rng.chance();
cout << "\t(Sampled: " << d;
cout << ", Long: " << l;
cout << ", Bools: [ ";
for(const auto& i : ar) cout << i << " ";
cout << "])" << endl;
}
}
}
extern "C" void rng_test()
{
using namespace std;
cout << "frng:" << endl;
rng::test_algo(rng::frng(1.0, 1.2));
cout << "drng:" << endl;
rng::test_algo(rng::drng(10));
cout << "xoroshiro128+" << endl;
rng::test_algo(rng::xoroshiro128plus(100ul, 200ul));
}
Loading…
Cancel
Save