/usr/include/opengm/functions/function_properties.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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | #pragma once
#ifndef OPENGM_FUNCTION_PROPERTIES_HXX
#define OPENGM_FUNCTION_PROPERTIES_HXX
#include <cmath>
#include "opengm/opengm.hxx"
#include "opengm/utilities/shape_accessor.hxx"
#include "opengm/utilities/accessor_iterator.hxx"
#include "opengm/utilities/accumulation.hxx"
#include "opengm/utilities/indexing.hxx"
#include "opengm/utilities/functors.hxx"
#include "opengm/operations/adder.hxx"
#include "opengm/operations/and.hxx"
#include "opengm/operations/or.hxx"
#include "opengm/operations/minimizer.hxx"
#include "opengm/operations/maximizer.hxx"
#include "opengm/operations/adder.hxx"
#include "opengm/operations/integrator.hxx"
#include "opengm/operations/multiplier.hxx"
#define OPENGM_FUNCTION_TYPEDEF_MACRO typedef typename FunctionType::ValueType ValueType;\
typedef typename FunctionType::IndexType IndexType;\
typedef typename FunctionType::LabelType LabelType;\
typedef typename FunctionType::FunctionShapeIteratorType FunctionShapeIteratorType
namespace opengm {
struct BinaryProperties{
enum Values{
IsPotts=0,
IsSubmodular1=1,
IsPositive=2
};
};
struct ValueProperties{
enum Values{
Sum=0,
Product=1,
Minimum=2,
Maximum=3,
FeasibleValue
};
};
template<int PROPERTY_ID,class FUNCTION>
class BinaryFunctionProperties;
template<int PROPERTY_ID,class FUNCTION>
class ValueFunctionProperties;
namespace detail_properties{
template<class FUNCTION,class ACCUMULATOR>
class AllValuesInAnyOrderFunctionProperties;
template<class FUNCTION,class ACCUMULATOR>
class AtLeastAllUniqueValuesFunctionProperties;
}
// Fallback implementation(s) of binary properties
template<class FUNCTION>
class BinaryFunctionProperties<BinaryProperties::IsPotts, FUNCTION> {
typedef FUNCTION FunctionType;
OPENGM_FUNCTION_TYPEDEF_MACRO;
public:
static bool op(const FunctionType & f) {
ShapeWalker<FunctionShapeIteratorType> shapeWalker(f.functionShapeBegin(), f.dimension());
ValueType vEqual = f(shapeWalker.coordinateTuple().begin());
++shapeWalker;
ValueType vNotEqual = f(shapeWalker.coordinateTuple().begin());
++shapeWalker;
for (IndexType i = 2; i < f.size(); ++i, ++shapeWalker) {
// all labels are equal
if (isEqualValueVector(shapeWalker.coordinateTuple())) {
if (vEqual != f(shapeWalker.coordinateTuple().begin()))
return false;
} // all labels are not equal
else {
if (vNotEqual != f(shapeWalker.coordinateTuple().begin()))
return false;
}
}
return true;
}
};
// Fallback implementation(s) of (real) value properties
// Some basic properties are derived from
// "AllValuesInAnyOrderFunctionProperties" and
// "AtLeastAllUniqueValuesFunctionProperties"
template<class FUNCTION>
class ValueFunctionProperties<ValueProperties::Product, FUNCTION>
: public detail_properties::AllValuesInAnyOrderFunctionProperties<FUNCTION,Multiplier>{
};
template<class FUNCTION>
class ValueFunctionProperties<ValueProperties::Sum, FUNCTION>
: public detail_properties::AllValuesInAnyOrderFunctionProperties<FUNCTION,Adder>{
};
template<class FUNCTION>
class ValueFunctionProperties<ValueProperties::Minimum, FUNCTION>
: public detail_properties::AtLeastAllUniqueValuesFunctionProperties<FUNCTION,Minimizer>{
};
template<class FUNCTION>
class ValueFunctionProperties<ValueProperties::Maximum, FUNCTION>
: public detail_properties::AtLeastAllUniqueValuesFunctionProperties<FUNCTION,Maximizer>{
};
namespace detail_properties{
template<class FUNCTION,class ACCUMULATOR>
class AllValuesInAnyOrderFunctionProperties{
typedef FUNCTION FunctionType;
OPENGM_FUNCTION_TYPEDEF_MACRO;
public:
static ValueType op(const FunctionType & f) {
opengm::AccumulationFunctor<ACCUMULATOR,ValueType> functor;
f.forAllValuesInAnyOrder(functor);
return functor.value();
}
};
template<class FUNCTION,class ACCUMULATOR>
class AtLeastAllUniqueValuesFunctionProperties{
typedef FUNCTION FunctionType;
OPENGM_FUNCTION_TYPEDEF_MACRO;
public:
static ValueType op(const FunctionType & f) {
opengm::AccumulationFunctor<ACCUMULATOR,ValueType> functor;
f.forAllValuesInAnyOrder(functor);
return functor.value();
}
};
}
}// namespace opengm
#endif //OPENGM_FUNCTION_PROPERTIES_HXX
|