File: random.cpp

package info (click to toggle)
visp 3.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 119,296 kB
  • sloc: cpp: 500,914; ansic: 52,904; xml: 22,642; python: 7,365; java: 4,247; sh: 482; makefile: 237; objc: 145
file content (32 lines) | stat: -rw-r--r-- 746 bytes parent folder | download
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
#include <iostream>
#include <visp3/core/vpUniRand.h>

int main()
{
  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;
}