This file is indexed.

/usr/include/opengm/functions/modelviewfunction.hxx is in libopengm-dev 2.3.6+20160905-1.

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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#pragma once
#ifndef OPENGM_MODELVIEWFUNCTION_HXX
#define OPENGM_MODELVIEWFUNCTION_HXX

#include "opengm/functions/function_properties_base.hxx"

namespace opengm {

/// Function that refers to a factor of another GraphicalModel
///
/// \tparam GM type of the graphical model which we want to view
/// \tparam MARRAY type of the array that holds the offset
///
/// \ingroup functions
template<class GM, class MARRAY>
class ModelViewFunction
: public FunctionBase<ModelViewFunction<GM,MARRAY>,
            typename GM::ValueType,
            typename GM::IndexType,
            typename GM::LabelType>
{
public:
   typedef GM GraphicalModelType;
   typedef MARRAY OffsetType;
   typedef typename GM::ValueType ValueType;
   typedef typename GM::ValueType value_type;
   typedef typename GM::IndexType IndexType;
   typedef typename GM::LabelType LabelType;

   ModelViewFunction(const GraphicalModelType& gm, const IndexType factorIndex, const ValueType scale, OffsetType const* offset);
   ModelViewFunction(const GraphicalModelType& gm, const IndexType factorIndex, const ValueType scale);
   ModelViewFunction(OffsetType const* offset);

   template<class Iterator> ValueType operator()(Iterator begin) const;
   size_t size() const;
   LabelType shape(const size_t i) const;
   size_t dimension() const;

private:
   /// ViewType
   enum ViewType {
      /// only view
      VIEW,
      /// view with a offset
      VIEWOFFSET,
      /// only offset
      OFFSET
   };

   GraphicalModelType const* gm_;
   IndexType factorIndex_;
   ValueType scale_;
   OffsetType const* offset_;
   ViewType viewType_;
};

/// constructor
/// \param gm graphical model we want to view
/// \param factorIndex index of the factor of gm we want to view
/// \param scale scaling factor of the view function
/// \param offset pointer to the offset marray
template<class GM, class MARRAY>
inline ModelViewFunction<GM, MARRAY>::ModelViewFunction
(
   const GM& gm ,
   const typename  ModelViewFunction<GM, MARRAY>::IndexType factorIndex,
   const typename  ModelViewFunction<GM, MARRAY>::ValueType scale,
   MARRAY const* offset
)
:  gm_(&gm),
   factorIndex_(factorIndex),
   scale_(scale),
   offset_(offset),
   viewType_(VIEWOFFSET)
{
   //viewType_ = VIEWOFFSET;
   OPENGM_ASSERT((*offset_).size() == gm_->operator[](factorIndex_).size());
   OPENGM_ASSERT((*offset_).dimension() == gm_->operator[](factorIndex_).numberOfVariables());
   for(size_t i=0; i<(*offset_).dimension();++i)
      OPENGM_ASSERT((*offset_).shape(i) == gm_->operator[](factorIndex_).numberOfLabels(i));
}

/// Constructor
/// \param gm graphical model we want to view
/// \param factorIndex index of the factor of gm we want to view
/// \param scale scaling factor of the view function
template<class GM, class MARRAY>
inline ModelViewFunction<GM, MARRAY>::ModelViewFunction
(
   const GM& gm,
   const typename  ModelViewFunction<GM, MARRAY>::IndexType factorIndex,
   const ValueType scale
)
:  gm_(&gm),
   factorIndex_(factorIndex),
   scale_(scale),
   viewType_(VIEW)
{
}

/// Constructor
/// \param offset pointer to the offset marray
template<class GM, class MARRAY>
inline ModelViewFunction<GM, MARRAY>::ModelViewFunction
(
   MARRAY const* offset
)
:  gm_(NULL),
   factorIndex_(0),
   scale_(0),
   offset_(offset),
   viewType_(OFFSET)
{
}

template<class GM, class MARRAY>
template<class Iterator>
inline typename opengm::ModelViewFunction<GM, MARRAY>::ValueType
ModelViewFunction<GM, MARRAY>::operator()
(
   Iterator begin
) const
{
   switch(viewType_) {
      case VIEWOFFSET:
         return scale_*gm_->operator[](factorIndex_)(begin) + (*offset_)(begin);
      case VIEW:
         return scale_*gm_->operator[](factorIndex_)(begin);
      case OFFSET:
         return (*offset_)(begin);
      default:
         break;
   }
   return 0;
}

template<class GM, class MARRAY>
inline typename ModelViewFunction<GM, MARRAY>::LabelType
ModelViewFunction<GM, MARRAY>::shape(const size_t i) const
{
   switch(viewType_) {
      case VIEWOFFSET:
         OPENGM_ASSERT(gm_->operator[](factorIndex_).shape(i)==(*offset_).shape(i));
         return (*offset_).shape(i);
      case VIEW:
         return gm_->operator[](factorIndex_).shape(i);
      case OFFSET:
         return (*offset_).shape(i);
      //default:
   }
   // To avoid compiler error "warning : control reached end
   return 0;
}

template<class GM, class MARRAY>
inline size_t ModelViewFunction<GM, MARRAY>::size() const
{
   switch(viewType_) {
      case VIEWOFFSET:
         return (*offset_).size();
      case VIEW:
         return gm_->operator[](factorIndex_).size();
      case OFFSET:
         return (*offset_).size();
      //default:
   }
   return 0;
}

template<class GM, class MARRAY>
inline size_t ModelViewFunction<GM, MARRAY>::dimension() const
{
   switch(viewType_) {
   case VIEWOFFSET:
      OPENGM_ASSERT(gm_->operator[](factorIndex_).numberOfVariables()==(*offset_).dimension());
      return (*offset_).dimension();
   case VIEW:
      return gm_->operator[](factorIndex_).numberOfVariables();
   case OFFSET:
      return (*offset_).dimension();
   default:
      ;
   }
   // To avoid compiler error "warning : control reached end
   return 0;
}

} // namespace opengm

#endif // #ifndef OPENGM_MODELVIEWFUNCTION_HXX