[082b02]: src / modules / bugs / functions / IfElse.cc  Maximize  Restore  History

Download this file

57 lines (46 with data), 1.2 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
#include <config.h>
#include "IfElse.h"
using std::vector;
namespace jags {
namespace bugs {
IfElse::IfElse () : ScalarFunction("ifelse", 3)
{
}
double IfElse::evaluate(vector<double const *> const &args) const
{
return *args[0] ? *args[1] : *args[2];
}
bool IfElse::isDiscreteValued(vector<bool> const &mask) const
{
return mask[1] && mask[2];
}
bool IfElse::isScale(vector<bool> const &mask,
vector<bool> const &fixed) const
{
//Don't even bother with the case where the predicate is a
//scale function. False negatives are allowed and this is a
//silly case
if (mask[0]) return false;
if (fixed.empty()) {
//result is a scale function if both arguments are
return mask[1] && mask[2];
}
else {
//..but is never a fixed scale function
return false;
}
}
bool IfElse::isLinear(vector<bool> const &mask,
vector<bool> const &fixed) const
{
if (mask[0]) return false;
if (fixed.empty()) {
//result is a linear function if either argument is
return mask[1] || mask[2];
}
else {
//..but is never a fixed scale function
return false;
}
}
}}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks