/usr/include/JAGS/compiler/LogicalFactory.h is in jags 4.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 66 67 68 69 70 71 72 73 | #ifndef LOGICAL_FACTORY_H_
#define LOGICAL_FACTORY_H_
#include <vector>
#include <utility>
#include <map>
#include <cfloat>
#include <function/FunctionPtr.h>
#include <compiler/NodeFactory.h>
namespace jags {
class Function;
class Node;
class Model;
class LogicalNode;
/**
* A "logical pair", consisting of a function and a vector of arguments,
* uniquely defines a logical node.
*/
typedef std::pair<FunctionPtr,std::vector<Node const *> > LogicalPair;
/**
* @short "Less than" function for LogicalPair objects.
*
* Two LogicalPairs A and B are considered to be equivalent
* (i.e. lt(A,B) and lt(B,A) are both false) if they have the same
* function, and the same vector of parameters. Observed parameters
* are considered equal if they have the same value (within a certain
* numerical tolerance).
*
* For non-equivalent LogicalPairs, the ordering is unique, but
* arbitrary. The only use of this function is for the STL map class
* with LogicalPair as key.
*/
bool lt(LogicalPair const &arg1, LogicalPair const &arg2);
/**
* @short Factory object for logical nodes
*
* The value of a logical node is determined uniquely by its function
* and its parameters. The purpose of a LogicalFactory is to avoid
* unnecessary duplication of logical nodes by having a factory object
* for them that will create and/or lookup logical nodes based on
* these arguments.
*/
class LogicalFactory
{
std::map<LogicalPair, Node*, fuzzy_less<LogicalPair> > _logicalmap;
public:
/**
* Get a logical node with a given function and given parameters.
* The results are cached, so if a request is repeated, the same
* node will be returned. If a newly allocated node is returned,
* it is also added to the given Model.
*/
Node *getNode(FunctionPtr const &func,
std::vector<Node const*> const ¶m,
Model &model);
/**
* Returns a newly allocated LogicalNode.
*/
static LogicalNode* newNode(FunctionPtr const &func,
std::vector<Node const *> const &parents,
unsigned int nchain);
};
} /* namespace jags */
#endif /* LOGICAL_FACTORY_H_ */
|