rngthreadexample.cpp 912 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. compile the example program with the following command line:
  3. g++ -O3 rngthreadexample.cpp rng_paraqueue_pool.cpp rng_queue_pool.cpp rngqueue.cpp -o rngthreadex -lgsl -lgslcblas -I/usr/include/qt4/QtCore -I/usr/include/qt4 -lQtCore -lpthread
  4. */
  5. #include <iostream>
  6. #include "rng_queue_pool.hpp"
  7. #include "rng_paraqueue_pool.hpp"
  8. using namespace std;
  9. int main()
  10. {
  11. const int NLoops=1000;
  12. const double PoissonLambda=0.3;
  13. int NRngVectors=6;
  14. int NRNumbersPerVector=500;
  15. IRngQueue* rnq = RngParaQueuePool::getRngQueuePool()
  16. ->getRngQueue(kRngPoisson, PoissonLambda, NRngVectors, NRNumbersPerVector);
  17. const int NumsPerLine=35;
  18. cout << "Random numbers:\n";
  19. for (int i=0; i<NLoops;++i)
  20. {
  21. if ((i%NumsPerLine) == 0) cout << "\n";
  22. double RandomNum = rnq->getRandomNumber();
  23. cout << RandomNum << " ";
  24. }
  25. cout << "\n";
  26. return 0;
  27. }