CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
CLHEP::RandMultiGauss Class Reference

#include <RandMultiGauss.h>

+ Inheritance diagram for CLHEP::RandMultiGauss:

Public Member Functions

 RandMultiGauss (HepRandomEngine &anEngine, const HepVector &mu, const HepSymMatrix &S)
 
 RandMultiGauss (HepRandomEngine *anEngine, const HepVector &mu, const HepSymMatrix &S)
 
 RandMultiGauss (HepRandomEngine &anEngine)
 
 RandMultiGauss (HepRandomEngine *anEngine)
 
virtual ~RandMultiGauss ()
 
HepVector fire ()
 
HepVector fire (const HepVector &mu, const HepSymMatrix &S)
 
void fireArray (const int size, HepVector *array)
 
void fireArray (const int size, HepVector *array, const HepVector &mu, const HepSymMatrix &S)
 
HepVector operator() ()
 
HepVector operator() (const HepVector &mu, const HepSymMatrix &S)
 
- Public Member Functions inherited from CLHEP::HepRandomVector
 HepRandomVector ()
 
 HepRandomVector (long seed)
 
 HepRandomVector (HepRandomEngine &engine)
 
 HepRandomVector (HepRandomEngine *engine)
 
virtual ~HepRandomVector ()
 
HepVector flat ()
 
HepVector flat (HepRandomEngine *theNewEngine)
 
void flatArray (const int size, HepVector *vect)
 
void flatArray (HepRandomEngine *theNewEngine, const int size, HepVector *vect)
 
virtual HepVector operator() ()
 

Additional Inherited Members

- Protected Attributes inherited from CLHEP::HepRandomVector
HepRandomEnginetheEngine
 

Detailed Description

Author
Mark Fischler mf@fn.nosp@m.al.g.nosp@m.ov

Definition at line 45 of file RandMultiGauss.h.

Constructor & Destructor Documentation

◆ RandMultiGauss() [1/4]

CLHEP::RandMultiGauss::RandMultiGauss ( HepRandomEngine anEngine,
const HepVector mu,
const HepSymMatrix S 
)

Definition at line 59 of file RandMultiGauss.cc.

62 : localEngine(&anEngine),
63 deleteEngine(false),
64 set(false),
65 nextGaussian(0.0)
66{
67 if (S.num_row() != mu.num_row()) {
68 std::cerr << "In constructor of RandMultiGauss distribution: \n" <<
69 " Dimension of mu (" << mu.num_row() <<
70 ") does not match dimension of S (" << S.num_row() << ")\n";
71 std::cerr << "---Exiting to System\n";
72 exit(1);
73 }
74 defaultMu = mu;
75 defaultSigmas = HepVector(S.num_row());
76 prepareUsigmas (S, defaultU, defaultSigmas);
77}
#define exit(x)

◆ RandMultiGauss() [2/4]

CLHEP::RandMultiGauss::RandMultiGauss ( HepRandomEngine anEngine,
const HepVector mu,
const HepSymMatrix S 
)

Definition at line 79 of file RandMultiGauss.cc.

82 : localEngine(anEngine),
83 deleteEngine(true),
84 set(false),
85 nextGaussian(0.0)
86{
87 if (S.num_row() != mu.num_row()) {
88 std::cerr << "In constructor of RandMultiGauss distribution: \n" <<
89 " Dimension of mu (" << mu.num_row() <<
90 ") does not match dimension of S (" << S.num_row() << ")\n";
91 std::cerr << "---Exiting to System\n";
92 exit(1);
93 }
94 defaultMu = mu;
95 defaultSigmas = HepVector(S.num_row());
96 prepareUsigmas (S, defaultU, defaultSigmas);
97}

◆ RandMultiGauss() [3/4]

CLHEP::RandMultiGauss::RandMultiGauss ( HepRandomEngine anEngine)

Definition at line 99 of file RandMultiGauss.cc.

100 : localEngine(&anEngine),
101 deleteEngine(false),
102 set(false),
103 nextGaussian(0.0)
104{
105 defaultMu = HepVector(2,0);
106 defaultU = HepMatrix(2,1);
107 defaultSigmas = HepVector(2);
108 defaultSigmas(1) = 1.;
109 defaultSigmas(2) = 1.;
110}

◆ RandMultiGauss() [4/4]

CLHEP::RandMultiGauss::RandMultiGauss ( HepRandomEngine anEngine)

Definition at line 112 of file RandMultiGauss.cc.

113 : localEngine(anEngine),
114 deleteEngine(true),
115 set(false),
116 nextGaussian(0.0)
117{
118 defaultMu = HepVector(2,0);
119 defaultU = HepMatrix(2,1);
120 defaultSigmas = HepVector(2);
121 defaultSigmas(1) = 1.;
122 defaultSigmas(2) = 1.;
123}

◆ ~RandMultiGauss()

CLHEP::RandMultiGauss::~RandMultiGauss ( )
virtual

Definition at line 125 of file RandMultiGauss.cc.

125 {
126 if ( deleteEngine ) delete localEngine;
127}

Member Function Documentation

◆ fire() [1/2]

HepVector CLHEP::RandMultiGauss::fire ( )

Definition at line 211 of file RandMultiGauss.cc.

211 {
212 // Returns a pair of unit normals, using the S and mu set in constructor,
213 // utilizing the engine belonging to this instance of RandMultiGauss.
214
215 return defaultMu + deviates ( defaultU, defaultSigmas,
216 localEngine, set, nextGaussian );
217
218} // fire();

Referenced by operator()(), and testRandMultiGauss().

◆ fire() [2/2]

HepVector CLHEP::RandMultiGauss::fire ( const HepVector mu,
const HepSymMatrix S 
)

Definition at line 221 of file RandMultiGauss.cc.

221 {
222
223 HepMatrix U;
224 HepVector sigmas(mu.num_row());
225
226 if (mu.num_row() == S.num_row()) {
227 prepareUsigmas ( S, U, sigmas );
228 return mu + deviates ( U, sigmas, localEngine, set, nextGaussian );
229 } else {
230 std::cerr << "In firing RandMultiGauss distribution with explicit mu and S: \n"
231 << " Dimension of mu (" << mu.num_row() <<
232 ") does not match dimension of S (" << S.num_row() << ")\n";
233 std::cerr << "---Exiting to System\n";
234 exit(1);
235 }
236 return mu; // This line cannot be reached. But without returning
237 // some HepVector here, KCC 3.3 complains.
238
239} // fire(mu, S);

◆ fireArray() [1/2]

void CLHEP::RandMultiGauss::fireArray ( const int  size,
HepVector array 
)

Definition at line 246 of file RandMultiGauss.cc.

246 {
247
248 int i;
249 for (i = 0; i < size; ++i) {
250 array[i] = defaultMu + deviates ( defaultU, defaultSigmas,
251 localEngine, set, nextGaussian );
252 }
253
254} // fireArray ( size, vect )

◆ fireArray() [2/2]

void CLHEP::RandMultiGauss::fireArray ( const int  size,
HepVector array,
const HepVector mu,
const HepSymMatrix S 
)

Definition at line 257 of file RandMultiGauss.cc.

258 {
259
260 // For efficiency, we diagonalize S once and generate all the vectors based
261 // on that U and sigmas.
262
263 HepMatrix U;
264 HepVector sigmas(mu.num_row());
265 HepVector mu_ (mu);
266
267 if (mu.num_row() == S.num_row()) {
268 prepareUsigmas ( S, U, sigmas );
269 } else {
270 std::cerr <<
271 "In fireArray for RandMultiGauss distribution with explicit mu and S: \n"
272 << " Dimension of mu (" << mu.num_row() <<
273 ") does not match dimension of S (" << S.num_row() << ")\n";
274 std::cerr << "---Exiting to System\n";
275 exit(1);
276 }
277
278 int i;
279 for (i=0; i<size; ++i) {
280 array[i] = mu_ + deviates(U, sigmas, localEngine, set, nextGaussian);
281 }
282
283} // fireArray ( size, vect, mu, S )

◆ operator()() [1/2]

HepVector CLHEP::RandMultiGauss::operator() ( )
virtual

Reimplemented from CLHEP::HepRandomVector.

Definition at line 289 of file RandMultiGauss.cc.

289 {
290 return fire();
291}

◆ operator()() [2/2]

HepVector CLHEP::RandMultiGauss::operator() ( const HepVector mu,
const HepSymMatrix S 
)

Definition at line 293 of file RandMultiGauss.cc.

294 {
295 return fire(mu,S);
296}

The documentation for this class was generated from the following files: