/usr/include/pcl-1.7/pcl/common/random.h is in libpcl-dev 1.7.2-14build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | /*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2012, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#ifndef PCL_COMMON_RANDOM_H_
#define PCL_COMMON_RANDOM_H_
#ifdef __GNUC__
#pragma GCC system_header
#endif
#include <boost/random/uniform_real.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/variate_generator.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <pcl/pcl_macros.h>
namespace pcl
{
namespace common
{
/// uniform distribution dummy struct
template <typename T> struct uniform_distribution;
/// uniform distribution int specialized
template<>
struct uniform_distribution<int>
{
typedef boost::uniform_int<int> type;
};
/// uniform distribution float specialized
template<>
struct uniform_distribution<float>
{
typedef boost::uniform_real<float> type;
};
/// normal distribution
template<typename T>
struct normal_distribution
{
typedef boost::normal_distribution<T> type;
};
/** \brief UniformGenerator class generates a random number from range [min, max] at each run picked
* according to a uniform distribution i.e eaach number within [min, max] has almost the same
* probability of being drawn.
*
* \author Nizar Sallem
*/
template<typename T>
class UniformGenerator
{
public:
struct Parameters
{
Parameters (T _min = 0, T _max = 1, pcl::uint32_t _seed = 1)
: min (_min)
, max (_max)
, seed (_seed)
{}
T min;
T max;
pcl::uint32_t seed;
};
/** Constructor
* \param min: included lower bound
* \param max: included higher bound
* \param seed: seeding value
*/
UniformGenerator(T min = 0, T max = 1, pcl::uint32_t seed = -1);
/** Constructor
* \param parameters uniform distribution parameters and generator seed
*/
UniformGenerator(const Parameters& parameters);
/** Change seed value
* \param[in] seed new generator seed value
*/
void
setSeed (pcl::uint32_t seed);
/** Set the uniform number generator parameters
* \param[in] min minimum allowed value
* \param[in] max maximum allowed value
* \param[in] seed random number generator seed (applied if != -1)
*/
void
setParameters (T min, T max, pcl::uint32_t seed = -1);
/** Set generator parameters
* \param parameters uniform distribution parameters and generator seed
*/
void
setParameters (const Parameters& parameters);
/// \return uniform distribution parameters and generator seed
const Parameters&
getParameters () { return (parameters_); }
/// \return a randomly generated number in the interval [min, max]
inline T
run () { return (generator_ ()); }
private:
typedef boost::mt19937 EngineType;
typedef typename uniform_distribution<T>::type DistributionType;
/// parameters
Parameters parameters_;
/// uniform distribution
DistributionType distribution_;
/// random number generator
EngineType rng_;
/// generator of random number from a uniform distribution
boost::variate_generator<EngineType&, DistributionType> generator_;
};
/** \brief NormalGenerator class generates a random number from a normal distribution specified
* by (mean, sigma).
*
* \author Nizar Sallem
*/
template<typename T>
class NormalGenerator
{
public:
struct Parameters
{
Parameters (T _mean = 0, T _sigma = 1, pcl::uint32_t _seed = 1)
: mean (_mean)
, sigma (_sigma)
, seed (_seed)
{}
T mean;
T sigma;
pcl::uint32_t seed;
};
/** Constructor
* \param[in] mean normal mean
* \param[in] sigma normal variation
* \param[in] seed seeding value
*/
NormalGenerator(T mean = 0, T sigma = 1, pcl::uint32_t seed = -1);
/** Constructor
* \param parameters normal distribution parameters and seed
*/
NormalGenerator(const Parameters& parameters);
/** Change seed value
* \param[in] seed new seed value
*/
void
setSeed (pcl::uint32_t seed);
/** Set the normal number generator parameters
* \param[in] mean mean of the normal distribution
* \param[in] sigma standard variation of the normal distribution
* \param[in] seed random number generator seed (applied if != -1)
*/
void
setParameters (T mean, T sigma, pcl::uint32_t seed = -1);
/** Set generator parameters
* \param parameters normal distribution parameters and seed
*/
void
setParameters (const Parameters& parameters);
/// \return normal distribution parameters and generator seed
const Parameters&
getParameters () { return (parameters_); }
/// \return a randomly generated number in the normal distribution (mean, sigma)
inline T
run () { return (generator_ ()); }
typedef boost::mt19937 EngineType;
typedef typename normal_distribution<T>::type DistributionType;
/// parameters
Parameters parameters_;
/// normal distribution
DistributionType distribution_;
/// random number generator
EngineType rng_;
/// generator of random number from a normal distribution
boost::variate_generator<EngineType&, DistributionType > generator_;
};
}
}
#include <pcl/common/impl/random.hpp>
#endif
|