OpenGM  2.3.x
Discrete Graphical Model Library
grid_space.hxx
Go to the documentation of this file.
1 #pragma once
2 #ifndef OPENGM_GRID_DISCRETE_SPACE_HXX
3 #define OPENGM_GRID_DISCRETE_SPACE_HXX
4 
6 
7 #include "opengm/opengm.hxx"
9 
10 namespace opengm {
11 
15 template<class I = std::size_t , class L = std::size_t >
16 class GridSpace :public SpaceBase<GridSpace<I,L>,I,L>{
17 public:
18  typedef I IndexType;
19  typedef L LabelType;
20 
21  GridSpace();
22  GridSpace(const IndexType,const IndexType, const LabelType);
23  void assign(const IndexType ,const IndexType, const LabelType);
24  IndexType numberOfVariables() const;
25  IndexType dimX() const;
26  IndexType dimY() const;
27  LabelType numberOfLabels()const;
28  LabelType numberOfLabels(const IndexType) const;
29  LabelType numberOfLabels(const IndexType,const IndexType) const;
30  bool isSimpleSpace() const;
31 private:
32  IndexType dimX_;
33  IndexType dimY_;
34  LabelType numberOfStates_;
35 };
36 
37 template<class I, class L>
38 inline
39 GridSpace<I, L>::GridSpace()
40 : dimX_(),
41  dimY_(),
42  numberOfStates_()
43 {}
44 
45 template<class I, class L>
46 inline
47 GridSpace<I, L>::GridSpace
48 (
49  const typename GridSpace<I, L>::IndexType dimX,
50  const typename GridSpace<I, L>::IndexType dimY,
51  const typename GridSpace<I, L>::LabelType numberOfLabels
52 )
53 : dimX_(dimX),
54  dimY_(dimY),
55  numberOfStates_(numberOfLabels)
56 {}
57 
58 template<class I, class L>
59 inline void
60 GridSpace<I, L>::assign
61 (
62  const typename GridSpace<I, L>::IndexType dimX,
63  const typename GridSpace<I, L>::IndexType dimY,
64  const typename GridSpace<I, L>::LabelType numberOfLabels
65 ) {
66  numberOfStates_ = numberOfLabels;
67  dimX_ = dimX;
68  dimY_ = dimY;
69 }
70 
71 template<class I, class L>
72 inline typename GridSpace<I, L>::IndexType
73 GridSpace<I, L>::numberOfVariables() const{
74  return dimX_*dimY_;
75 }
76 
77 template<class I, class L>
78 inline typename GridSpace<I, L>::IndexType
79 GridSpace<I, L>::dimX() const{
80  return dimX_;
81 }
82 
83 template<class I, class L>
84 inline typename GridSpace<I, L>::IndexType
85 GridSpace<I, L>::dimY() const{
86  return dimY_;
87 }
88 
89 template<class I, class L>
90 inline typename GridSpace<I, L>::LabelType
91 GridSpace<I, L>::numberOfLabels() const{
92  return numberOfStates_;
93 }
94 
95 template<class I, class L>
96 inline typename GridSpace<I, L>::LabelType
97 GridSpace<I, L>::numberOfLabels
98 (
99  const typename GridSpace<I, L>::IndexType dimension
100 ) const{
101  return numberOfStates_;
102 }
103 
104 template<class I, class L>
105 inline bool
106 GridSpace<I, L>::isSimpleSpace() const{
107  return true;
108 }
109 
110 } // namespace opengm
111 
113 
114 #endif // #ifndef OPENGM_GRID_DISCRETE_SPACE_HXX
The OpenGM namespace.
Definition: config.hxx:43