SourceForge has been redesigned. Learn more.
Close

[50073b]: / src / modules / bugs / samplers / MNormalFactory.cc  Maximize  Restore  History

Download this file

44 lines (34 with data), 986 Bytes

 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
#include <config.h>
#include "MNormal.h"
#include "MNormalFactory.h"
#include <graph/StochasticNode.h>
#include <distribution/Distribution.h>
#include <sampler/MutableSampler.h>
#include <sampler/SingletonGraphView.h>
#include <string>
#include <vector>
using std::vector;
using std::string;
namespace jags {
namespace bugs {
bool
MNormalFactory::canSample(StochasticNode * snode, Graph const &graph) const
{
return snode->distribution()->name() == "dmnorm" && !isBounded(snode);
}
Sampler *
MNormalFactory::makeSampler(StochasticNode *snode, Graph const &graph) const
{
unsigned int N = snode->nchain();
vector<MutableSampleMethod*> methods(N, 0);
SingletonGraphView *gv = new SingletonGraphView(snode, graph);
for (unsigned int ch = 0; ch < N; ++ch) {
methods[ch] = new MNormMetropolis(gv, ch);
}
return new MutableSampler(gv, methods, "bugs::MNormalMetropolis");
}
string MNormalFactory::name() const
{
return "bugs::MNormal";
}
}}