PSCF v1.1
Ar1Process.cpp
1/*
2* Util Package - C++ Utilities for Scientific Computation
3*
4* Copyright 2010 - 2017, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "Ar1Process.h"
9
10namespace Util
11{
12
13 /*
14 * Default constructor.
15 */
17 : x_(0.0),
18 B_(1.0),
19 C_(0.0),
20 randomPtr_(0),
21 isInitialized_(false)
22 {}
23
24 /*
25 * Constructor.
26 */
28 : x_(0.0),
29 B_(1.0),
30 C_(0.0),
31 randomPtr_(&random),
32 isInitialized_(false)
33 {}
34
35 /*
36 * Set pointer to random number generator.
37 */
39 { randomPtr_ = &random; }
40
41 /*
42 * Initialize process
43 *
44 * \param tau decay time (in discrete steps)
45 */
46 void Ar1Process::init(double tau)
47 {
48 // Precondition
49 if (randomPtr_ == 0) {
50 UTIL_THROW("Random number generator not yet set");
51 }
52
53 C_ = exp(-1.0/tau);
54 B_ = sqrt(1.0 - C_*C_);
55 x_ = B_*randomPtr_->gaussian();
56 isInitialized_ = true;
57 }
58
59}
void init(double tau)
Initialize process.
Definition: Ar1Process.cpp:46
void setRNG(Random &random)
Associate a random number generator.
Definition: Ar1Process.cpp:38
Ar1Process()
Constructor.
Definition: Ar1Process.cpp:16
Random number generator.
Definition: Random.h:47
double gaussian(void)
Return a Gaussian random number with zero average and unit variance.
Definition: Random.cpp:92
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Definition: global.h:51
Utility classes for scientific computation.
Definition: accumulators.mod:1