/usr/include/JAGS/sarray/SArray.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 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 125 | #ifndef SARRAY_H_
#define SARRAY_H_
#include <sarray/SimpleRange.h>
#include <vector>
#include <string>
namespace jags {
/**
* @short multi-dimensional real-valued array
*
* An SArray represents a multi-dimensional array of double precision values.
*/
class SArray
{
const SimpleRange _range;
std::vector<double> _value;
bool _discrete;
std::vector<std::vector<std::string> > _s_dimnames;
std::vector<std::string> _dimnames;
SArray &operator=(SArray const &rhs);
public:
/**
* Constructor for SArrays.
*
* On construction, the elements of the value array are all equal to
* JAGS_NA.
*
* @param dim Dimension of SArray to be constructed
*/
SArray(std::vector<unsigned int> const &dim);
/**
* Copy constructor.
*
* Note that the assignment operator of the SArray class is
* declared private, and so cannot be used. An SArray can only be
* copied by a constructor. This ensures that, once constructed,
* an SArray cannot change its length or dimension.
*/
SArray(SArray const &orig);
/**
* Sets the value of an SArray.
*
* @param value vector of values to be assigned. The size of this
* vector must match the length of the SArray or a length_error
* exception will be thrown.
*
* @exception length_error
*/
void setValue(std::vector<double> const &value);
/**
* Sets the value of an SArray to an integer vector
*/
void setValue(std::vector<int> const &value);
/**
* Sets the value of a single element of SArray
*
* @param value Scalar value to be assigned
*
* @param offset Distance along the value array
*/
void setValue(double value, unsigned int offset);
/**
* The value of the SArray .
*
* Values are given in column-major order (i.e. with the left hand
* index moving fastest), like the S language and Fortran.
*
* @return A reference to a vector of values.
*/
std::vector<double> const &value() const;
/**
* Indicates whether the SArray should contain integer-values or
* real values.
*/
bool isDiscreteValued() const;
/**
* Returns the range associated with the SArray.
*/
SimpleRange const &range() const;
/**
* Returns the names of the dimensions. A newly created SArray has
* no dimension names and this function returns an empty vector.
*/
std::vector<std::string> const &dimNames() const;
/**
* Sets the names of the dimensions.
*
* @param names A vector of names that is either empty, or of size
* equal to the number of dimensions.
*/
void setDimNames(std::vector<std::string> const &names);
/**
* Returns the names of one of dimensions, corresponding to
* dimnames()[i+1] in the S language. A newly created SArray has
* no dimnames and so this function returns an empty vector.
*
* @param i Requested dimension.
*/
std::vector<std::string> const &getSDimNames(unsigned int i) const;
/**
* Sets the names of the ith dimension, corresponding to dimnames()[i+1]
* in the S language.
*
* @param names A vector of names of size equal to the ith dimension
* value vector, or zero.
* @param i Requested dimension
*/
void setSDimNames(std::vector<std::string> const &names, unsigned int i);
/**
* It is convenient to inline these functions so that an SArray
* can be thought of as having some of the dimension attributes of
* its associated range.
*/
unsigned int length() const { return range().length(); }
unsigned int ndim(bool drop) const { return range().ndim(drop); }
std::vector<unsigned int> const &
dim(bool drop) const { return range().dim(drop); }
};
} /* namespace jags */
#endif /* SARRAY_H_ */
|