/usr/include/JAGS/util/dim.h is in jags 3.4.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 | #ifndef DIM_H_
#define DIM_H_
/**
* @short Some low-level utility functions.
*/
#include <vector>
#include <algorithm>
/**
* Tests whether the dimension represented by the vector "dim"
* corresponds to a scalar quantity.
*
* Note that isScalar, isVector, and isArray are mutually exclusive.
*/
inline bool isScalar(std::vector<unsigned int> const &dim)
{
return dim.size() == 1 && dim[0] == 1;
}
/**
* Tests whether the dimension represented by the vector "dim"
* corresponds to a vector quantity.
* Note that isScalar, isVector, and isArray are mutually exclusive.
*/
inline bool isVector(std::vector<unsigned int> const &dim)
{
return dim.size() == 1 && dim[0] > 1;
}
/**
* Tests whether the dimension represented by the vector "dim"
* corresponds to an array.
*
* Note that isScalar, isVector, and isArray are mutually exclusive.
*/
inline bool isArray(std::vector<unsigned int> const &dim)
{
return dim.size() > 1;
}
/**
* Tests whether the dimension represented by the vector "dim"
* corresponds to a two-dimensional array.
*/
inline bool isMatrix(std::vector<unsigned int> const &dim)
{
return dim.size() == 2;
}
/**
* Tests whether the dimension represented by the vector "dim"
* corresponds to a matrix with the same number of rows as columns.
*/
inline bool isSquareMatrix(std::vector<unsigned int> const &dim)
{
return dim.size() == 2 && dim[0] == dim[1];
}
/**
* Returns the product of the elements of a vector. The most common
* usage of this function in the JAGS library is to calculate the
* number of elements in an array, given its dimensions.
*/
unsigned int product(std::vector<unsigned int> const &arg);
/**
* Drops redundant dimensions
*/
std::vector<unsigned int> drop(std::vector<unsigned int> const &dims);
/**
* Returns a constant reference to a unique vector
*
* Vectors of unsigned integers are frequently repeated objects in
* the JAGS library (Typically as dimensions of Nodes). This function
* creates a unique constant reference to the requested vector. This
* avoids redundant copies of the vector taking up memory.
*/
std::vector<unsigned int> const &getUnique(std::vector<unsigned int> const &dim);
/**
* Returns a constant reference to a unique vector
*
* Vectors of parameter dimensions are frequently repeated objects
* in the JAGS library. This function returns a reference to a unique
* copy of the requested vector in order to save memory.
*
*/
std::vector<std::vector<unsigned int> > const &
getUnique(std::vector<std::vector<unsigned int> > const &dimvec);
#endif /* DIM_H_ */
|