/usr/include/opengm/graphicalmodel/space/static_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 | #pragma once
#ifndef OPENGM_STATIC_SIMPLE_DISCRETE_SPACE_HXX
#define OPENGM_STATIC_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<size_t LABELS, class I = std::size_t , class L = std::size_t>
class StaticSimpleDiscreteSpace
: public SpaceBase<StaticSimpleDiscreteSpace<LABELS, I, L>, I, L>
{
public:
typedef I IndexType;
typedef L LabelType;
StaticSimpleDiscreteSpace();
StaticSimpleDiscreteSpace(const IndexType);
void assign(const IndexType);
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_;
};
template<size_t LABELS,class I, class L>
inline
StaticSimpleDiscreteSpace<LABELS,I, L>::StaticSimpleDiscreteSpace()
: numberOfVariables_()
{}
template<size_t LABELS,class I, class L>
inline
StaticSimpleDiscreteSpace<LABELS,I, L>::StaticSimpleDiscreteSpace(
const IndexType numberOfVariables
)
: numberOfVariables_(numberOfVariables)
{}
template<size_t LABELS,class I, class L>
template<class Iterator>
inline void
StaticSimpleDiscreteSpace<LABELS,I, L>::assignDense(
Iterator begin,
Iterator end
) {
numberOfVariables_=std::distance(begin, end);
numberOfVariables_=static_cast<L>(*begin);
while(begin!=end) {
if(LABELS!=static_cast<size_t>(*begin)) {
throw opengm::RuntimeError("*begin==LABELS_ is violated \
in StaticSimpleDiscreteSpace::assignDense ");
}
++begin;
}
}
template<size_t LABELS,class I, class L>
inline void
StaticSimpleDiscreteSpace<LABELS,I, L>::assign(
const IndexType numberOfVariables
) {
numberOfVariables_ = numberOfVariables;
}
template<size_t LABELS,class I, class L>
inline I
StaticSimpleDiscreteSpace<LABELS,I, L>::addVariable(
const L numberOfLabels
) {
if(numberOfLabels!=static_cast<L> (LABELS)) {
throw opengm::RuntimeError("numberOfLabels==LABELS is violated \
in StaticSimpleDiscreteSpace::addVariable ");
}
}
template<size_t LABELS,class I, class L>
inline typename StaticSimpleDiscreteSpace<LABELS,I, L>::IndexType
StaticSimpleDiscreteSpace<LABELS,I, L>::numberOfVariables() const {
return numberOfVariables_;
}
template<size_t LABELS,class I, class L>
inline typename StaticSimpleDiscreteSpace<LABELS,I, L>::LabelType
StaticSimpleDiscreteSpace<LABELS,I, L>::numberOfLabels(
const IndexType dimension
) const {
return static_cast<L> LABELS;
}
template<size_t LABELS,class I, class L>
inline bool
StaticSimpleDiscreteSpace<LABELS,I, L>::isSimpleSpace() const
{
return true;
}
} // namespace opengm
#endif // #ifndef OPENGM_STATIC_SIMPLE_DISCRETE_SPACE_HXX
|