/usr/include/opengm/graphicalmodel/space/simplediscretespace.hxx is in libopengm-dev 2.3.6-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 | #pragma once
#ifndef OPENGM_SIMPLE_DISCRETE_SPACE_HXX
#define OPENGM_SIMPLE_DISCRETE_SPACE_HXX
#include "opengm/opengm.hxx"
#include "opengm/graphicalmodel/space/space_base.hxx"
namespace opengm {
/// Discrete space in which all variables have the same number of labels
///
/// \ingroup spaces
template<class I = std::size_t, class L = std::size_t>
class SimpleDiscreteSpace
: public SpaceBase<SimpleDiscreteSpace<I, L>, I, L> {
public:
typedef I IndexType;
typedef L LabelType;
SimpleDiscreteSpace();
SimpleDiscreteSpace(const IndexType, const LabelType);
void assign(const IndexType, const LabelType);
template<class Iterator> void assignDense(Iterator, Iterator);
IndexType addVariable(const LabelType);
IndexType numberOfVariables() const;
LabelType numberOfLabels(const IndexType) const;
bool isSimpleSpace() const ;
private:
IndexType numberOfVariables_;
LabelType numberOfLabels_;
};
template<class I, class L>
inline
SimpleDiscreteSpace<I, L>::SimpleDiscreteSpace()
: numberOfVariables_(),
numberOfLabels_()
{}
template<class I, class L>
inline
SimpleDiscreteSpace<I, L>::SimpleDiscreteSpace
(
const IndexType numberOfVariables,
const LabelType numberOfLabels
)
: numberOfVariables_(numberOfVariables),
numberOfLabels_(numberOfLabels)
{}
template<class I, class L>
template<class Iterator>
inline void
SimpleDiscreteSpace<I, L>::assignDense
(
Iterator begin,
Iterator end
) {
numberOfVariables_ = std::distance(begin, end);
numberOfLabels_ = static_cast<L>(*begin);
while(begin != end) {
if(numberOfLabels_ != static_cast<LabelType>(*begin)) {
throw opengm::RuntimeError("*begin == SimpleDiscreteSpace.numberOfLabels_ is violated in SimpleDiscreteSpace::assignDense");
}
++begin;
}
}
template<class I, class L>
inline void
SimpleDiscreteSpace<I, L>::assign
(
const IndexType numberOfVariables,
const LabelType numberOfLabels
) {
numberOfVariables_ = numberOfVariables;
numberOfLabels_ = numberOfLabels;
}
template<class I, class L>
inline typename SimpleDiscreteSpace<I, L>::IndexType
SimpleDiscreteSpace<I, L>::addVariable
(
const LabelType numberOfLabels
) {
if(numberOfLabels != numberOfLabels_) {
throw opengm::RuntimeError("numberOfLabels == SimpleDiscreteSpace.numberOfLabels_ is violated in SimpleDiscreteSpace::addVariable");
}
++numberOfVariables_;
return numberOfVariables_ - 1;
}
template<class I, class L>
inline typename SimpleDiscreteSpace<I, L>::IndexType
SimpleDiscreteSpace<I, L>::numberOfVariables() const {
return numberOfVariables_;
}
template<class I, class L>
inline typename SimpleDiscreteSpace<I, L>::LabelType
SimpleDiscreteSpace<I, L>::numberOfLabels
(
const IndexType dimension
) const {
return numberOfLabels_;
}
template<class I, class L>
inline bool
SimpleDiscreteSpace<I, L>::isSimpleSpace() const{
return true;
}
} // namespace opengm
#endif // #ifndef OPENGM_SIMPLE_DISCRETE_SPACE_HXX
|