source: trunk/test/rnd_test.cc @ 358

Last change on this file since 358 was 358, checked in by Peter, 17 years ago

cleaned up in random_singleton

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 620 bytes
Line 
1// $Id: rnd_test.cc 358 2005-08-03 16:09:44Z peter $
2
3#include <iostream>
4#include <c++_tools/utility/random_singleton.h>
5
6
7using namespace theplu;
8
9int main()
10{
11  utility::random_singleton* my_rnd;
12  my_rnd = utility::random_singleton::instance( -1 );
13 
14  double* prob = new double[ 5 ];
15  prob[ 0 ] = 0.2; 
16  prob[ 1 ] = 0.2;
17  prob[ 2 ] = 0.2;
18  prob[ 3 ] = 0.2;
19  prob[ 4 ] = 0.2;
20  my_rnd->general_distribution_prob( 5, prob );
21  delete prob;
22
23  int antal[5];
24  antal[ 0 ] = 0;
25  antal[ 1 ] = 0;
26  antal[ 2 ] = 0;
27  antal[ 3 ] = 0;
28  antal[ 4 ] = 0;
29
30  for( size_t i = 0; i < 100; ++i )
31    antal[ my_rnd->rnd_discrete() ]++;
32
33  delete my_rnd;
34
35  return 0;
36}
Note: See TracBrowser for help on using the repository browser.