Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[669123]: src / lib / function / DFunction.cc Maximize Restore History

Download this file

DFunction.cc    38 lines (29 with data), 765 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
#include <config.h>
#include <distribution/RScalarDist.h>
#include <function/DFunction.h>
using std::vector;
using std::string;
namespace jags {
DFunction::DFunction(RScalarDist const *dist)
: DPQFunction(dist->name(), dist)
{}
double DFunction::evaluate(vector<double const *> const &args) const
{
double x = *args[0];
vector<double const *> param(args.size() - 1);
for (unsigned int i = 1; i < args.size(); ++i) {
param[i-1] = args[i];
}
return dist()->d(x, PDF_FULL, param, false);
}
bool
DFunction::checkParameterValue(vector<double const *> const &args) const
{
if (dist()->discrete()) {
double x = *args[0];
if (x != static_cast<int>(x))
return false;
}
return checkArgs(args);
}
}