/usr/include/JAGS/model/NodeArray.h is in jags 4.1.0-1.
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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | #ifndef NODE_ARRAY_H_
#define NODE_ARRAY_H_
#include <graph/Graph.h>
#include <sarray/SimpleRange.h>
#include <string>
#include <map>
namespace jags {
class SArray;
class Model;
class AggNode;
/**
* @short Multi-dimensional array that can be tiled with Node objects
*
* A NodeArray is a container class for nodes. A NodeArray may
* represent a scalar, vector, matrix or multi-dimensional container
* that can be tiled with Nodes using the insert member function.
* Subsets of the NodeArray can be retrieved with the getSubset
* function.
*/
class NodeArray {
friend class NodeArraySubset;
std::string _name;
SimpleRange _range;
Graph _member_graph;
unsigned int _nchain;
std::vector<Node *> _node_pointers;
std::vector<unsigned int> _offsets;
std::map<Range, Node *> _mv_nodes;
std::map<Range, AggNode *> _generated_nodes;
/* Forbid copying */
NodeArray(NodeArray const &orig);
NodeArray &operator=(NodeArray const &rhs);
public:
/**
* Constructor. Creates a NodeArray with the given name and dimension
*/
NodeArray(std::string const &name, std::vector<unsigned int> const &dim,
unsigned int nchain);
/**
* Inserts a node into the subset of the NodeArray defined by range.
* The dimension of the node must conform with the given range.
* The given range must not overlap any previously inserted node.
* Repeated indices in the given range are not allowed.
*
* The node is added to an internal graph.
*
* @exception runtime_error
*/
void insert(Node *node, Range const &range);
/**
* Returns a subset of the NodeArray. If the range corresponds to a
* previously inserted node, this will be returned. Otherwise, an
* aggregate node will be generated, and it will be added to the
* given model. Generated nodes are cached so a future call to
* getSubset will return the same node. If the range is not
* completely covered by inserted nodes, a NULL pointer will be
* returned.
*/
Node* getSubset(Range const &range, Model &model);
/**
* Sets the values of the nodes in the array.
*
* @param value SArray containing values to be used. The value
* vector of the SArray may contain missing values. If so, then the
* part of the value vector corresponding to each inserted node must be
* either completely missing (in which no action is taken) or
* contain no missing values.
*
* @param value array with dimensions matching the NodeArray containing
* values.
*
* @param chain Index number of chain to which to apply values.
*/
void setValue(SArray const &value, unsigned int chain);
/**
* Gets the values of selected nodes that have been inserted into
* the array.
*
* @param value SArray to which values should be written.
*
* @param chain Index number of chain to read.
*
* @param condition. Boolean function that returns true for nodes
* whose values are to be read.
*/
void getValue(SArray &value, unsigned int chain,
bool (*condition)(Node const *)) const;
/**
* Set data, creating a constant node for any non-missing value. An
* exception is thrown if any of the non-missing values corresponds
* to an existing node in the array.
*/
void setData(SArray const &value, Model *model);
/**
* Returns the name of the node array
*/
std::string const &name() const;
/**
* Returns the range of indices covered by the NodeArray
*/
SimpleRange const &range() const;
/**
* Returns the range corresponding to the given node, if it
* belongs to the graph associated with the NodeArray. If it is
* not in the graph, a NULL Range is returned.
*/
Range getRange(Node const *node) const;
/**
* Returns the number of chains of the nodes stored in the array
*/
unsigned int nchain() const;
};
} /* namespace jags */
#endif /* NODE_ARRAY_H */
|