LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
afw
11.0-2-g04d2804
include
lsst
afw
math
Random.h
Go to the documentation of this file.
1
// -*- lsst-c++ -*-
2
3
/*
4
* LSST Data Management System
5
* Copyright 2008, 2009, 2010 LSST Corporation.
6
*
7
* This product includes software developed by the
8
* LSST Project (http://www.lsst.org/).
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the LSST License Statement and
21
* the GNU General Public License along with this program. If not,
22
* see <http://www.lsstcorp.org/LegalNotices/>.
23
*/
24
25
32
#ifndef LSST_AFW_MATH_RANDOM_H
33
#define LSST_AFW_MATH_RANDOM_H
34
35
#include "boost/shared_ptr.hpp"
36
37
#include "gsl/gsl_rng.h"
38
39
#include "
lsst/pex/exceptions.h
"
40
#include "
lsst/pex/policy/Policy.h
"
41
42
43
namespace
lsst {
namespace
afw {
namespace
math {
44
62
class
Random
{
63
public
:
64
66
enum
Algorithm
{
68
MT19937
= 0,
70
RANLXS0
,
72
RANLXS1
,
74
RANLXS2
,
76
RANLXD1
,
78
RANLXD2
,
80
RANLUX
,
82
RANLUX389
,
84
CMRG
,
86
MRG
,
88
TAUS
,
90
TAUS2
,
92
GFSR4
,
94
NUM_ALGORITHMS
95
};
96
97
// -- Constructor --------
98
explicit
Random
(
Algorithm
algorithm =
MT19937
,
unsigned
long
seed = 1);
99
explicit
Random
(std::string
const
& algorithm,
unsigned
long
seed = 1);
100
explicit
Random
(
lsst::pex::policy::Policy::Ptr
const
policy);
101
// Use compiler generated destructor and shallow copy constructor/assignment operator
102
103
Random
deepCopy
()
const
;
104
106
116
typedef
std::string
State
;
117
State
getState
()
const
;
118
void
setState
(
State
const
& state);
119
std::size_t
getStateSize
()
const
;
121
122
// -- Accessors --------
123
Algorithm
getAlgorithm
()
const
;
124
std::string
getAlgorithmName
()
const
;
125
static
std::vector<std::string>
const
&
getAlgorithmNames
();
126
unsigned
long
getSeed
()
const
;
127
128
// -- Modifiers: generating random numbers --------
129
double
uniform
();
130
double
uniformPos
();
131
unsigned
long
uniformInt
(
unsigned
long
n);
132
133
// -- Modifiers: computing random variates for various distributions --------
134
double
flat
(
double
const
a,
double
const
b
);
135
double
gaussian
();
136
double
chisq
(
double
const
nu);
137
double
poisson
(
double
const
nu);
138
139
private
:
140
boost::shared_ptr< ::gsl_rng>
_rng
;
141
unsigned
long
_seed
;
142
Algorithm
_algorithm
;
143
144
static ::gsl_rng_type
const
*
const
_gslRngTypes
[
NUM_ALGORITHMS
];
145
static
char
const
*
const
_algorithmNames
[
NUM_ALGORITHMS
];
146
static
char
const
*
const
_algorithmEnvVarName
;
147
static
char
const
*
const
_seedEnvVarName
;
148
149
void
initialize
();
150
void
initialize
(std::string
const
&);
151
};
152
153
/************************************************************************************************************/
154
/*
155
* Create Images containing random numbers
156
*/
157
template
<
typename
ImageT>
158
void
randomUniformImage
(ImageT *
image
,
Random
&rand);
159
160
template
<
typename
ImageT>
161
void
randomUniformPosImage
(ImageT *
image
,
Random
&rand);
162
163
template
<
typename
ImageT>
164
void
randomUniformIntImage
(ImageT *
image
,
Random
&rand,
unsigned
long
n);
165
166
template
<
typename
ImageT>
167
void
randomFlatImage
(ImageT *
image
,
Random
&rand,
double
const
a,
double
const
b
);
168
169
template
<
typename
ImageT>
170
void
randomGaussianImage
(ImageT *
image
,
Random
&rand);
171
172
template
<
typename
ImageT>
173
void
randomChisqImage
(ImageT *
image
,
Random
&rand,
double
const
nu);
174
175
template
<
typename
ImageT>
176
void
randomPoissonImage
(ImageT *
image
,
Random
&rand,
double
const
mu);
177
178
179
}}}
// end of namespace lsst::afw::math
180
181
#endif // LSST_AFW_MATH_RANDOM_H
182
lsst::afw::math::randomUniformImage
void randomUniformImage(ImageT *image, Random &rand)
Definition:
RandomImage.cc:112
lsst::afw::math::Random::State
std::string State
Definition:
Random.h:116
lsst::afw::math::Random::Random
Random(Algorithm algorithm=MT19937, unsigned long seed=1)
Definition:
Random.cc:151
lsst::afw::math::Random::poisson
double poisson(double const nu)
Definition:
Random.cc:390
exceptions.h
Include files required for standard LSST Exception handling.
lsst::afw::math::Random::_algorithm
Algorithm _algorithm
Definition:
Random.h:142
lsst::pex::policy::Policy::Ptr
boost::shared_ptr< Policy > Ptr
Definition:
Policy.h:172
lsst::afw::math::Random::RANLXD2
Definition:
Random.h:78
lsst::afw::math::Random::_seed
unsigned long _seed
Definition:
Random.h:141
lsst::afw::math::Random::uniformInt
unsigned long uniformInt(unsigned long n)
Definition:
Random.cc:341
lsst::afw::math::Random::getSeed
unsigned long getSeed() const
Definition:
Random.cc:285
lsst::afw::math::Random::_seedEnvVarName
static char const *const _seedEnvVarName
Definition:
Random.h:147
lsst::afw::math::Random::_rng
boost::shared_ptr< ::gsl_rng > _rng
Definition:
Random.h:140
lsst::afw::math::Random::initialize
void initialize()
Definition:
Random.cc:96
lsst::afw::math::randomFlatImage
void randomFlatImage(ImageT *image, Random &rand, double const a, double const b)
Definition:
RandomImage.cc:143
image
table::Key< table::Array< Kernel::Pixel > > image
Definition:
FixedKernel.cc:117
lsst::afw::math::Random::RANLXS0
Definition:
Random.h:70
lsst::afw::math::Random::getStateSize
std::size_t getStateSize() const
Definition:
Random.cc:247
lsst::afw::math::Random::MRG
Definition:
Random.h:86
lsst::afw::math::randomUniformPosImage
void randomUniformPosImage(ImageT *image, Random &rand)
Definition:
RandomImage.cc:122
lsst::afw::math::Random::NUM_ALGORITHMS
Definition:
Random.h:94
lsst::afw::math::Random::_algorithmEnvVarName
static char const *const _algorithmEnvVarName
Definition:
Random.h:146
lsst::afw::math::Random::setState
void setState(State const &state)
Definition:
Random.cc:236
lsst::afw::math::Random::RANLUX389
Definition:
Random.h:82
lsst::afw::math::randomChisqImage
void randomChisqImage(ImageT *image, Random &rand, double const nu)
Definition:
RandomImage.cc:165
lsst::afw::math::Random::getAlgorithm
Algorithm getAlgorithm() const
Definition:
Random.cc:256
lsst::afw::math::randomGaussianImage
void randomGaussianImage(ImageT *image, Random &rand)
Definition:
RandomImage.cc:155
lsst::afw::math::Random::chisq
double chisq(double const nu)
Definition:
Random.cc:380
lsst::afw::math::Random::getAlgorithmName
std::string getAlgorithmName() const
Definition:
Random.cc:263
lsst::afw::math::Random::flat
double flat(double const a, double const b)
Definition:
Random.cc:358
lsst::afw::math::Random::_algorithmNames
static char const *const _algorithmNames[NUM_ALGORITHMS]
Definition:
Random.h:145
lsst::afw::math::Random::gaussian
double gaussian()
Definition:
Random.cc:370
lsst::afw::math::Random::uniformPos
double uniformPos()
Definition:
Random.cc:319
lsst::afw::math::Random::Algorithm
Algorithm
Definition:
Random.h:66
lsst::afw::math::Random::RANLXS1
Definition:
Random.h:72
lsst::afw::math::Random::CMRG
Definition:
Random.h:84
lsst::afw::math::randomUniformIntImage
void randomUniformIntImage(ImageT *image, Random &rand, unsigned long n)
Definition:
RandomImage.cc:132
Policy.h
lsst::afw::math::randomPoissonImage
void randomPoissonImage(ImageT *image, Random &rand, double const mu)
Definition:
RandomImage.cc:177
lsst::afw::math::Random::GFSR4
Definition:
Random.h:92
b
afw::table::Key< double > b
Definition:
DoubleGaussianPsf.cc:49
lsst::afw::math::Random::RANLUX
Definition:
Random.h:80
lsst::afw::math::Random::TAUS2
Definition:
Random.h:90
lsst::afw::math::Random::deepCopy
Random deepCopy() const
Definition:
Random.cc:223
lsst::afw::math::Random::RANLXS2
Definition:
Random.h:74
lsst::afw::math::Random::uniform
double uniform()
Definition:
Random.cc:304
lsst::afw::math::Random
Definition:
Random.h:62
lsst::afw::math::Random::getState
State getState() const
Definition:
Random.cc:232
lsst::afw::math::Random::_gslRngTypes
::gsl_rng_type const *const _gslRngTypes[NUM_ALGORITHMS]
Definition:
Random.h:144
lsst::afw::math::Random::TAUS
Definition:
Random.h:88
lsst::afw::math::Random::MT19937
Definition:
Random.h:68
lsst::afw::math::Random::getAlgorithmNames
static std::vector< std::string > const & getAlgorithmNames()
Definition:
Random.cc:270
lsst::afw::math::Random::RANLXD1
Definition:
Random.h:76
Generated on Thu Sep 24 2015 02:29:15 for LSSTApplications by
1.8.5