/usr/include/opengm/utilities/accumulation.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 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | #pragma once
#ifndef OPENGM_ACCUMULATION_HXX
#define OPENGM_ACCUMULATION_HXX
#include "opengm/datastructures/fast_sequence.hxx"
/// \cond HIDDEN_SYMBOLS
namespace opengm {
template<class Value, class State, class Accumulator>
class Accumulation {
public:
/// value type of the accumulation
typedef Value ValueType;
/// state type of the accumulation
typedef State LabelType;
Accumulation();
ValueType value() const;
size_t size() const;
Value neutral() const;
void state(FastSequence<size_t>&) const;
template<class OUT_CONTAINER>
void state(OUT_CONTAINER &) const;
LabelType state(size_t) const;
void clear();
void operator()(const ValueType&, const opengm::FastSequence<size_t>&);
template<class CONTAINER>
void operator()(const ValueType&, const CONTAINER&);
void operator()(const ValueType&);
private:
ValueType value_;
opengm::FastSequence<size_t> state_;
};
template<class Value, class State, class Accumulator>
inline
Accumulation<Value, State, Accumulator>::Accumulation()
: value_(Accumulator::template neutral<ValueType>()),
state_(opengm::FastSequence<size_t>())
{}
template<class Value, class State, class Accumulator>
inline typename Accumulation<Value, State, Accumulator>::ValueType
Accumulation<Value, State, Accumulator>::value() const
{
return(value_);
}
template<class Value, class State, class Accumulator>
inline size_t
Accumulation<Value, State, Accumulator>::size() const
{
return state_.size();
}
template<class Value, class State, class Accumulator>
inline typename Accumulation<Value, State, Accumulator>::ValueType
Accumulation<Value, State, Accumulator>::neutral() const
{
return state_.size();
}
template<class Value, class State, class Accumulator>
inline void
Accumulation<Value, State, Accumulator>::state
(
opengm::FastSequence<size_t>& out
) const
{
out = state_;
}
template<class Value, class State, class Accumulator>
template<class OUT_CONTAINER>
inline void
Accumulation<Value, State, Accumulator>::state
(
OUT_CONTAINER& out
) const
{
out.resize(state_.size());
for(size_t i=0;i<state_.size();++i) {
out[i]=state_[i];
}
}
template<class Value, class State, class Accumulator>
inline typename Accumulation<Value, State, Accumulator>::LabelType
Accumulation<Value, State, Accumulator>::state
(
size_t index
) const
{
return state_[index];
}
template<class Value, class State, class Accumulator>
inline void
Accumulation<Value, State, Accumulator>::clear()
{
Accumulator::neutral(value_);
state_.resize(0);
}
template<class Value, class State, class Accumulator>
inline void
Accumulation<Value, State, Accumulator>::operator()
(
const ValueType& value,
const opengm::FastSequence<size_t>& state
) {
if(Accumulator::bop(value, value_)) {
state_ = state;
OPENGM_ASSERT(state_.size()==state.size());
}
Accumulator::op(value, value_, value_);
//OPENGM_ASSERT(state_.size()==state.size());
}
template<class Value, class State, class Accumulator>
template<class CONTAINER>
inline void
Accumulation<Value, State, Accumulator>::operator()
(
const ValueType& value,
const CONTAINER & state
)
{
if(Accumulator::bop(value, value_)) {
state_.resize(state.size());
for(size_t i=0;i<state.size();++i) {
state_[i] = state[i];
}
}
Accumulator::op(value, value_, value_);
OPENGM_ASSERT(state_.size()==state.size());
}
template<class Value, class State, class Accumulator>
inline void
Accumulation<Value, State, Accumulator>::operator()
(
const ValueType& value
)
{
Accumulator::op(value, value_, value_);
}
} // namespace opengm
/// \endcond
#endif // #ifndef OPENGM_ACCUMULATION_HXX
|