[e23e50]: src / lib / sampler / MutableSampler.cc Maximize Restore History

Download this file

MutableSampler.cc    66 lines (53 with data), 1.3 kB

 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
#include <sampler/MutableSampler.h>
#include <sampler/MutableSampleMethod.h>
#include <graph/StochasticNode.h>
#include <sampler/GraphView.h>
#include <stdexcept>
using std::vector;
using std::logic_error;
using std::string;
namespace jags {
MutableSampler::MutableSampler(GraphView *gv,
vector<MutableSampleMethod *> const &methods,
std::string const &name)
: Sampler(gv), _methods(methods), _name(name)
{
}
MutableSampler::~MutableSampler()
{
for (unsigned int ch = 0; ch < _methods.size(); ++ch) {
delete _methods[ch];
}
}
void MutableSampler::update(vector<RNG*> const &rngs)
{
for (unsigned int ch = 0; ch < rngs.size(); ++ch) {
_methods[ch]->update(rngs[ch]);
}
}
void MutableSampler::adaptOff()
{
for (unsigned int ch = 0; ch < _methods.size(); ++ch) {
_methods[ch]->adaptOff();
}
}
bool MutableSampler::checkAdaptation() const
{
for (unsigned int ch = 0; ch < _methods.size(); ++ch) {
if (!_methods[ch]->checkAdaptation()) return false;
}
return true;
}
bool MutableSampler::isAdaptive() const
{
for (unsigned int ch = 0; ch < _methods.size(); ++ch) {
if (_methods[ch]->isAdaptive())
return true;
}
return false;
}
string MutableSampler::name() const
{
return _name;
}
} //namespace jags