random_generator.cpp
Go to the documentation of this file.
1 /*
2  * @brief sim_loc_random implements random number generators.
3  *
4  * Copyright (C) 2019 Ing.-Buero Dr. Michael Lehning, Hildesheim
5  * Copyright (C) 2019 SICK AG, Waldkirch
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * All rights reserved.
20  *
21  * Redistribution and use in source and binary forms, with or without
22  * modification, are permitted provided that the following conditions are met:
23  *
24  * * Redistributions of source code must retain the above copyright
25  * notice, this list of conditions and the following disclaimer.
26  * * Redistributions in binary form must reproduce the above copyright
27  * notice, this list of conditions and the following disclaimer in the
28  * documentation and/or other materials provided with the distribution.
29  * * Neither the name of SICK AG nor the names of its
30  * contributors may be used to endorse or promote products derived from
31  * this software without specific prior written permission
32  * * Neither the name of Ing.-Buero Dr. Michael Lehning nor the names of its
33  * contributors may be used to endorse or promote products derived from
34  * this software without specific prior written permission
35  *
36  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
37  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
40  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
41  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
42  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
43  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
44  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46  * POSSIBILITY OF SUCH DAMAGE.
47  *
48  * Authors:
49  * Michael Lehning <michael.lehning@lehning.de>
50  *
51  * Copyright 2019 SICK AG
52  * Copyright 2019 Ing.-Buero Dr. Michael Lehning
53  *
54  */
55 #include <time.h>
56 
58 
59 const std::string sick_scan::UniformRandomAsciiString::s_ascii_chars = " !\"#$%&'()*+,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~";
60 
61 
68 : m_random_engine(time(0)), m_uniform_distribution(lower_bound, upper_bound), m_random_generator(m_random_engine, m_uniform_distribution)
69 {
70 }
71 
76 {
77  return m_random_generator();
78 }
79 
85 std::vector<uint8_t> sick_scan::UniformRandomInteger::generate(int data_size)
86 {
87  std::vector<uint8_t> data(data_size, 0);
88  for(int n = 0; n < data_size; n++)
89  {
90  data[n] = (uint8_t)(m_random_generator() & 0xFF);
91  }
92  return data;
93 }
94 
99 {
100 }
101 
108 {
109  std::string random_string;
110  random_string.reserve(length);
111  for(size_t n = 0; n < length; n++)
112  random_string.push_back(s_ascii_chars[m_random_generator.generate()]);
113  return random_string;
114 }
static const std::string s_ascii_chars
list of ascii chars: " !\"#$%&&#39;()*+,-./0123456789:;=?@ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmno...
data
boost::variate_generator< boost::mt19937 &, boost::uniform_int<> > m_random_generator
random number generator (glues mersenne engine and distribution)
UniformRandomInteger(int lower_bound=0, int upper_bound=255)
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
UniformRandomInteger m_random_generator
random number generator


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Wed May 5 2021 03:05:48