Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:21

0001 // name=SRngTest ; gcc $name.cc -std=c++11 -lstdc++ -I.. -o /tmp/$name && /tmp/$name
0002 #include <iostream>
0003 #include <iomanip>
0004 #include <functional>
0005 #include "SRng.hh"
0006 
0007 template <typename T> void test_rng( const std::function<T()>& fn )
0008 {
0009     T a ; 
0010     T b ; 
0011     bool done ; 
0012     unsigned count = 0 ; 
0013 
0014     do {
0015         a = fn() ; 
0016         b = fn() ; 
0017 
0018         std::cout 
0019             << " count " << std::setw(10) <<  count 
0020             << " a " << std::fixed << std::setw(10) << std::setprecision(4) <<  a 
0021             << " b " << std::fixed << std::setw(10) << std::setprecision(4) <<  b 
0022             << std::endl
0023             ; 
0024 
0025         done = a > 0.99 && b > 0.99 ; 
0026         count += 1 ;   
0027 
0028     } while( done == false ) ; 
0029 
0030 
0031     std::cout 
0032         << " result " 
0033         << " count " << count 
0034         << " a " << a 
0035         << " b " << b 
0036         << std::endl
0037         ; 
0038 }
0039 
0040 
0041 void test_rng_0()
0042 {
0043     unsigned seed = 1u ; 
0044     SRng<double> rng0(seed) ; 
0045     test_rng<double>(rng0); 
0046 }
0047 
0048 void test_rng_1()
0049 {
0050     unsigned seed = 1u ; 
0051     SRng<float> rng1(seed) ; 
0052     test_rng<float>(rng1); 
0053 }
0054 
0055 
0056 int main(int argc, char** argv)
0057 {
0058     //test_rng_0();  
0059     test_rng_1();  
0060     return 0;
0061 }
0062 
0063 
0064