2 #ifndef OPENGM_EXPLICIT_FUNCTION_HXX 3 #define OPENGM_EXPLICIT_FUNCTION_HXX 14 template<
class T,
class I=
size_t,
class L=
size_t>
51 template <
class SHAPE_ITERATOR>
57 template <
class SHAPE_ITERATOR>
65 template<
class T,
class I,
class L>
73 template<
class T,
class I,
class L>
80 template<
class INDEX_OUTPUT_ITERATOR,
class VALUE_OUTPUT_ITERATOR >
82 template<
class INDEX_INPUT_ITERATOR ,
class VALUE_INPUT_ITERATOR>
87 template<
class T,
class I,
class L>
95 template<
class T,
class I,
class L>
103 template<
class T,
class I,
class L>
104 template<
class INDEX_OUTPUT_ITERATOR,
class VALUE_OUTPUT_ITERATOR >
108 INDEX_OUTPUT_ITERATOR indexOutIterator,
109 VALUE_OUTPUT_ITERATOR valueOutIterator
113 *valueOutIterator=src(0);
119 *indexOutIterator=src.
shape(i);
122 for(
size_t i=0;i<src.
size();++i) {
123 *valueOutIterator=src(i);
129 template<
class T,
class I,
class L>
130 template<
class INDEX_INPUT_ITERATOR,
class VALUE_INPUT_ITERATOR >
133 INDEX_INPUT_ITERATOR indexOutIterator,
134 VALUE_INPUT_ITERATOR valueOutIterator,
137 if(*indexOutIterator==0) {
142 const size_t dim=*indexOutIterator;
143 std::vector<size_t>
shape(dim);
145 for(
size_t i=0;i<dim;++i) {
146 shape[i]=*indexOutIterator;
150 dst.
resize(shape.begin(), shape.end() );
151 for(
size_t i=0;i<dst.
size();++i) {
152 dst(i)=*valueOutIterator;
158 template<
class FUNC,
class T,
class I,
class L>
170 template<
class FUNC,
class T,
class I,
class L>
174 const FUNC &
function,
178 typedef ShapeWalker<typename FUNC::FunctionShapeIteratorType> Walker;
181 for (I i = 0; i <
function.size(); ++i, ++walker) {
182 out(walker.coordinateTuple().begin()) =
183 function(walker.coordinateTuple().begin());
189 #endif // OPENGM_EXPLICIT_FUNCTION_HXX void assign(const allocator_type &=allocator_type())
Clear Marray.
FunctionShapeIteratorType functionShapeEnd() const
ExplicitFunction< T, I, L > cloneAsExplicitFunction(const FUNC &function)
Fallback implementation of member functions of OpenGM functions.
Marray(const allocator_type &=allocator_type())
Empty constructor.
Runtime-flexible multi-dimensional views and arrays.
const size_t * shapeEnd() const
Get a constant iterator to the end of the shape vector.
Marray< T, A > & operator=(const T &)
Assignment.
ExplicitFunction(const T &value)
construct a constant explicit function of order 0
Function encoded as a dense multi-dimensional array, marray::Marray.
const size_t * shapeBegin() const
Get a constant iterator to the beginning of the shape vector.
const size_t FUNCTION_TYPE_ID_OFFSET
User-defined function have ids smaller than FUNCTION_TYPE_ID_OFFSET.
ExplicitFunction & operator=(const ExplicitFunction &other)
const size_t dimension() const
Get the dimension.
FunctionShapeIteratorType functionShapeBegin() const
Runtime-flexible multi-dimensional array.
ExplicitFunction(SHAPE_ITERATOR shapeBegin, SHAPE_ITERATOR shapeEnd, const T &value)
construct a function encoded by a value table (whose entries are initialized with the same value) ...
ExplicitFunction(SHAPE_ITERATOR shapeBegin, SHAPE_ITERATOR shapeEnd)
construct a function encoded by a value table (whose entries are initialized as 0) ...
const size_t shape(const size_t) const
Get the shape in one dimension.
void resize(ShapeIterator, ShapeIterator, const T &=T())
Resize (existing entries are preserved, new entries are initialized).
ExplicitFunction(const ExplicitFunction &other)
const size_t size() const
Get the number of data items.