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

Download this file

64 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
#include <config.h>
#include <util/logical.h>
#include <util/dim.h>
#include <util/logical.h>
#include "DSumFunc.h"
using std::vector;
namespace jags {
namespace bugs {
DSumFunc::DSumFunc()
: ArrayFunction("dsum", 0)
{
}
void DSumFunc::evaluate(double *x,
vector<double const *> const &args,
vector<vector<unsigned int> > const &dims) const
{
unsigned int length = product(dims[0]);
for (unsigned int i = 0; i < length; ++i) {
x[i] = 0;
for (unsigned int j = 0; j < args.size(); ++j) {
x[i] += args[j][i];
}
}
}
bool DSumFunc::isDiscreteValued(vector<bool> const &mask) const
{
return allTrue(mask);
}
bool
DSumFunc::checkParameterDim(vector<vector<unsigned int> > const &dims) const
{
for (unsigned int i = 1; i < dims.size(); ++i) {
if (dims[i] != dims[0])
return false;
}
return true;
}
vector<unsigned int>
DSumFunc::dim(vector<vector<unsigned int> > const &dims) const
{
return dims[0];
}
bool DSumFunc::isLinear(vector<bool> const &mask,
vector<bool> const &fixed) const
{
return true;
}
bool DSumFunc::isScale(vector<bool> const &mask,
vector<bool> const &fixed) const
{
return allTrue(mask);
}
}}

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

Sign up for the SourceForge newsletter:





No, thanks