File: random.cpp

package info (click to toggle)
visp 3.7.0-7
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 166,380 kB
  • sloc: cpp: 392,705; ansic: 224,448; xml: 23,444; python: 13,701; java: 4,792; sh: 206; objc: 145; makefile: 118
file content (34 lines) | stat: -rw-r--r-- 852 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpUniRand.h>

int main()
{
#ifdef ENABLE_VISP_NAMESPACE
  using namespace VISP_NAMESPACE_NAME;
#endif

  vpUniRand rng;
  for (int i = 0; i < 10; i++) {
    std::cout << rng.uniform(0, 6) << std::endl; // produces int values
    std::cout << rng.uniform(0.0, 6.0) << std::endl; // produces double values
  }

  std::vector<int> v;
  for (unsigned int i = 0; i < 10; i++) {
    v.push_back(i);
  }

  std::vector<int> shuffled_v = vpUniRand::shuffleVector<int>(v);
  std::cout << "Original vector = [\t";
  for (unsigned int i = 0; i < 10; i++) {
    std::cout << v[i] << "\t";
  }
  std::cout << "]" <<  std::endl;

  std::cout << "Shuffled vector = [\t";
  for (unsigned int i = 0; i < 10; i++) {
    std::cout << shuffled_v[i] << "\t";
  }
  std::cout << "]" <<  std::endl;
}