"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "include/armadillo_bits/arma_rng.hpp" between
armadillo-10.8.2.tar.xz and armadillo-11.0.0.tar.xz

About: Armadillo is a C++ linear algebra library (matrix maths) aiming towards a good balance between speed and ease of use.

arma_rng.hpp  (armadillo-10.8.2.tar.xz):arma_rng.hpp  (armadillo-11.0.0.tar.xz)
skipping to change at line 75 skipping to change at line 75
class arma_rng class arma_rng
{ {
public: public:
#if defined(ARMA_RNG_ALT) #if defined(ARMA_RNG_ALT)
typedef arma_rng_alt::seed_type seed_type; typedef arma_rng_alt::seed_type seed_type;
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
typedef std::mt19937_64::result_type seed_type; typedef std::mt19937_64::result_type seed_type;
#else #else
typedef arma_rng_cxx98::seed_type seed_type; typedef arma_rng_cxx03::seed_type seed_type;
#endif #endif
#if defined(ARMA_RNG_ALT) #if defined(ARMA_RNG_ALT)
static constexpr int rng_method = 2; static constexpr int rng_method = 2;
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
static constexpr int rng_method = 1; static constexpr int rng_method = 1;
#else #else
static constexpr int rng_method = 0; static constexpr int rng_method = 0;
#endif #endif
skipping to change at line 109 skipping to change at line 109
#if defined(ARMA_RNG_ALT) #if defined(ARMA_RNG_ALT)
{ {
arma_rng_alt::set_seed(val); arma_rng_alt::set_seed(val);
} }
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
{ {
mt19937_64_instance.seed(val); mt19937_64_instance.seed(val);
} }
#else #else
{ {
arma_rng_cxx98::set_seed(val); arma_rng_cxx03::set_seed(val);
} }
#endif #endif
} }
arma_cold arma_cold
inline inline
void void
arma_rng::set_seed_random() arma_rng::set_seed_random()
{ {
seed_type seed1 = seed_type(0); seed_type seed1 = seed_type(0);
skipping to change at line 211 skipping to change at line 211
return eT( arma_rng_alt::randi_val() ); return eT( arma_rng_alt::randi_val() );
} }
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
{ {
constexpr double scale = double(std::numeric_limits<int>::max()) / double( std::mt19937_64::max()); constexpr double scale = double(std::numeric_limits<int>::max()) / double( std::mt19937_64::max());
return eT( double(mt19937_64_instance()) * scale ); return eT( double(mt19937_64_instance()) * scale );
} }
#else #else
{ {
return eT( arma_rng_cxx98::randi_val() ); return eT( arma_rng_cxx03::randi_val() );
} }
#endif #endif
} }
inline inline
static static
int int
max_val() max_val()
{ {
#if defined(ARMA_RNG_ALT) #if defined(ARMA_RNG_ALT)
{ {
return arma_rng_alt::randi_max_val(); return arma_rng_alt::randi_max_val();
} }
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
{ {
return std::numeric_limits<int>::max(); return std::numeric_limits<int>::max();
} }
#else #else
{ {
return arma_rng_cxx98::randi_max_val(); return arma_rng_cxx03::randi_max_val();
} }
#endif #endif
} }
inline inline
static static
void void
fill(eT* mem, const uword N, const int a, const int b) fill(eT* mem, const uword N, const int a, const int b)
{ {
#if defined(ARMA_RNG_ALT) #if defined(ARMA_RNG_ALT)
skipping to change at line 253 skipping to change at line 253
arma_rng_alt::randi_fill(mem, N, a, b); arma_rng_alt::randi_fill(mem, N, a, b);
} }
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
{ {
std::uniform_int_distribution<int> local_i_distr(a, b); std::uniform_int_distribution<int> local_i_distr(a, b);
for(uword i=0; i<N; ++i) { mem[i] = eT(local_i_distr(mt19937_64_instance) ); } for(uword i=0; i<N; ++i) { mem[i] = eT(local_i_distr(mt19937_64_instance) ); }
} }
#else #else
{ {
if(N == uword(1)) { arma_rng_cxx98::randi_fill(mem, uword(1), a, b); retu rn; } if(N == uword(1)) { arma_rng_cxx03::randi_fill(mem, uword(1), a, b); retu rn; }
typedef typename std::mt19937_64::result_type local_seed_type; typedef typename std::mt19937_64::result_type local_seed_type;
std::mt19937_64 local_engine; std::mt19937_64 local_engine;
std::uniform_int_distribution<int> local_i_distr(a, b); std::uniform_int_distribution<int> local_i_distr(a, b);
local_engine.seed( local_seed_type(std::rand()) ); local_engine.seed( local_seed_type(std::rand()) );
for(uword i=0; i<N; ++i) { mem[i] = eT(local_i_distr(local_engine)); } for(uword i=0; i<N; ++i) { mem[i] = eT(local_i_distr(local_engine)); }
} }
skipping to change at line 288 skipping to change at line 288
return eT( arma_rng_alt::randu_val() ); return eT( arma_rng_alt::randu_val() );
} }
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
{ {
constexpr double scale = double(1.0) / double(std::mt19937_64::max()); constexpr double scale = double(1.0) / double(std::mt19937_64::max());
return eT( double(mt19937_64_instance()) * scale ); return eT( double(mt19937_64_instance()) * scale );
} }
#else #else
{ {
return eT( arma_rng_cxx98::randu_val() ); return eT( arma_rng_cxx03::randu_val() );
} }
#endif #endif
} }
inline inline
static static
void void
fill(eT* mem, const uword N) fill(eT* mem, const uword N)
{ {
#if defined(ARMA_RNG_ALT) #if defined(ARMA_RNG_ALT)
skipping to change at line 310 skipping to change at line 310
for(uword i=0; i < N; ++i) { mem[i] = eT( arma_rng_alt::randu_val() ); } for(uword i=0; i < N; ++i) { mem[i] = eT( arma_rng_alt::randu_val() ); }
} }
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
{ {
std::uniform_real_distribution<double> local_u_distr; std::uniform_real_distribution<double> local_u_distr;
for(uword i=0; i < N; ++i) { mem[i] = eT( local_u_distr(mt19937_64_instan ce) ); } for(uword i=0; i < N; ++i) { mem[i] = eT( local_u_distr(mt19937_64_instan ce) ); }
} }
#else #else
{ {
if(N == uword(1)) { mem[0] = eT( arma_rng_cxx98::randu_val() ); return; } if(N == uword(1)) { mem[0] = eT( arma_rng_cxx03::randu_val() ); return; }
typedef typename std::mt19937_64::result_type local_seed_type; typedef typename std::mt19937_64::result_type local_seed_type;
std::mt19937_64 local_engine; std::mt19937_64 local_engine;
std::uniform_real_distribution<double> local_u_distr; std::uniform_real_distribution<double> local_u_distr;
local_engine.seed( local_seed_type(std::rand()) ); local_engine.seed( local_seed_type(std::rand()) );
for(uword i=0; i < N; ++i) { mem[i] = eT( local_u_distr(local_engine) ); } for(uword i=0; i < N; ++i) { mem[i] = eT( local_u_distr(local_engine) ); }
} }
skipping to change at line 349 skipping to change at line 349
{ {
std::uniform_real_distribution<double> local_u_distr; std::uniform_real_distribution<double> local_u_distr;
const T a = T( local_u_distr(mt19937_64_instance) ); const T a = T( local_u_distr(mt19937_64_instance) );
const T b = T( local_u_distr(mt19937_64_instance) ); const T b = T( local_u_distr(mt19937_64_instance) );
return std::complex<T>(a, b); return std::complex<T>(a, b);
} }
#else #else
{ {
const T a = T( arma_rng_cxx98::randu_val() ); const T a = T( arma_rng_cxx03::randu_val() );
const T b = T( arma_rng_cxx98::randu_val() ); const T b = T( arma_rng_cxx03::randu_val() );
return std::complex<T>(a, b); return std::complex<T>(a, b);
} }
#endif #endif
} }
inline inline
static static
void void
fill(std::complex<T>* mem, const uword N) fill(std::complex<T>* mem, const uword N)
skipping to change at line 388 skipping to change at line 388
const T a = T( local_u_distr(mt19937_64_instance) ); const T a = T( local_u_distr(mt19937_64_instance) );
const T b = T( local_u_distr(mt19937_64_instance) ); const T b = T( local_u_distr(mt19937_64_instance) );
mem[i] = std::complex<T>(a, b); mem[i] = std::complex<T>(a, b);
} }
} }
#else #else
{ {
if(N == uword(1)) if(N == uword(1))
{ {
const T a = T( arma_rng_cxx98::randu_val() ); const T a = T( arma_rng_cxx03::randu_val() );
const T b = T( arma_rng_cxx98::randu_val() ); const T b = T( arma_rng_cxx03::randu_val() );
mem[0] = std::complex<T>(a, b); mem[0] = std::complex<T>(a, b);
return; return;
} }
typedef typename std::mt19937_64::result_type local_seed_type; typedef typename std::mt19937_64::result_type local_seed_type;
std::mt19937_64 local_engine; std::mt19937_64 local_engine;
std::uniform_real_distribution<double> local_u_distr; std::uniform_real_distribution<double> local_u_distr;
skipping to change at line 435 skipping to change at line 435
return eT( arma_rng_alt::randn_val() ); return eT( arma_rng_alt::randn_val() );
} }
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
{ {
std::normal_distribution<double> local_n_distr; std::normal_distribution<double> local_n_distr;
return eT( local_n_distr(mt19937_64_instance) ); return eT( local_n_distr(mt19937_64_instance) );
} }
#else #else
{ {
return eT( arma_rng_cxx98::randn_val() ); return eT( arma_rng_cxx03::randn_val() );
} }
#endif #endif
} }
inline inline
static static
void void
dual_val(eT& out1, eT& out2) dual_val(eT& out1, eT& out2)
{ {
#if defined(ARMA_RNG_ALT) #if defined(ARMA_RNG_ALT)
skipping to change at line 458 skipping to change at line 458
} }
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
{ {
std::normal_distribution<double> local_n_distr; std::normal_distribution<double> local_n_distr;
out1 = eT( local_n_distr(mt19937_64_instance) ); out1 = eT( local_n_distr(mt19937_64_instance) );
out2 = eT( local_n_distr(mt19937_64_instance) ); out2 = eT( local_n_distr(mt19937_64_instance) );
} }
#else #else
{ {
arma_rng_cxx98::randn_dual_val(out1, out2); arma_rng_cxx03::randn_dual_val(out1, out2);
} }
#endif #endif
} }
inline inline
static static
void void
fill_simple(eT* mem, const uword N) fill_simple(eT* mem, const uword N)
{ {
#if defined(ARMA_RNG_ALT) #if defined(ARMA_RNG_ALT)
skipping to change at line 486 skipping to change at line 486
if(i < N) { mem[i] = eT( arma_rng_alt::randn_val() ); } if(i < N) { mem[i] = eT( arma_rng_alt::randn_val() ); }
} }
#elif defined(ARMA_USE_EXTERN_RNG) #elif defined(ARMA_USE_EXTERN_RNG)
{ {
std::normal_distribution<double> local_n_distr; std::normal_distribution<double> local_n_distr;
for(uword i=0; i < N; ++i) { mem[i] = eT( local_n_distr(mt19937_64_instan ce) ); } for(uword i=0; i < N; ++i) { mem[i] = eT( local_n_distr(mt19937_64_instan ce) ); }
} }
#else #else
{ {
if(N == uword(1)) { mem[0] = eT( arma_rng_cxx98::randn_val() ); return; } if(N == uword(1)) { mem[0] = eT( arma_rng_cxx03::randn_val() ); return; }
typedef typename std::mt19937_64::result_type local_seed_type; typedef typename std::mt19937_64::result_type local_seed_type;
std::mt19937_64 local_engine; std::mt19937_64 local_engine;
std::normal_distribution<double> local_n_distr; std::normal_distribution<double> local_n_distr;
local_engine.seed( local_seed_type(std::rand()) ); local_engine.seed( local_seed_type(std::rand()) );
for(uword i=0; i < N; ++i) { mem[i] = eT( local_n_distr(local_engine) ); } for(uword i=0; i < N; ++i) { mem[i] = eT( local_n_distr(local_engine) ); }
} }
skipping to change at line 620 skipping to change at line 620
mem[i] = std::complex<T>(a,b); mem[i] = std::complex<T>(a,b);
} }
} }
#else #else
{ {
if(N == uword(1)) if(N == uword(1))
{ {
T a = T(0); T a = T(0);
T b = T(0); T b = T(0);
arma_rng_cxx98::randn_dual_val(a,b); arma_rng_cxx03::randn_dual_val(a,b);
mem[0] = std::complex<T>(a,b); mem[0] = std::complex<T>(a,b);
return; return;
} }
typedef typename std::mt19937_64::result_type local_seed_type; typedef typename std::mt19937_64::result_type local_seed_type;
std::mt19937_64 local_engine; std::mt19937_64 local_engine;
std::normal_distribution<double> local_n_distr; std::normal_distribution<double> local_n_distr;
 End of changes. 13 change blocks. 
15 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)