This file is indexed.

/usr/include/opengm/python/numpyview.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
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
191
#ifndef NUMPYVIEW_INCL_HXX
#define	NUMPYVIEW_INCL_HXX

#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <numpy/noprefix.h>
#ifdef Bool
#undef Bool
#endif 
#include <stddef.h>
#include <opengm/graphicalmodel/graphicalmodel.hxx>

//template <typename T>
//inline PyArray_TYPES typeEnumFromType(void);

namespace opengm{
namespace python{
   
using namespace boost::python;

//template<class T, size_t DIM>
//class NumpyViewAccessor1d;

template<class V,size_t DIM=0>
class NumpyView{
public:
   typedef V ValueType;
   typedef V  * CastPtrType;
   typedef int const * ShapePtrType;
   typedef typename marray::View< V ,false >::iterator IteratorType;
   typedef typename marray::View< V ,false >::const_iterator ConstIteratorType;
   typedef size_t const *  ShapeIteratorType;
   
   NumpyView( ):allocFromCpp_(false){
   }
   NumpyView( boost::python::object  obj):allocFromCpp_(false){
      boost::python::numeric::array array = boost::python::extract<boost::python::numeric::array > (obj);
      void * voidDataPtr=PyArray_DATA(array.ptr());
      CastPtrType dataPtr = static_cast<CastPtrType>(voidDataPtr);
      size_t dimension =static_cast<size_t>(PyArray_NDIM(array.ptr()));

      npy_intp * shapePtr = PyArray_DIMS(array.ptr());
      npy_intp * stridePtr = PyArray_STRIDES(array.ptr());
      opengm::FastSequence<size_t> mystrides(dimension);
      for(size_t i=0;i<dimension;++i){
         mystrides[i]=(stridePtr[i])/sizeof(V);
      }
      view_.assign(shapePtr,shapePtr+dimension,mystrides.begin(),dataPtr,marray::FirstMajorOrder);
   }

   
   NumpyView( boost::python::numeric::array  array):allocFromCpp_(false){
      void * voidDataPtr=PyArray_DATA(array.ptr());
      CastPtrType dataPtr = static_cast<CastPtrType>(voidDataPtr);
      size_t dimension =static_cast<size_t>(PyArray_NDIM(array.ptr()));
      npy_intp * shapePtr = PyArray_DIMS(array.ptr());
      npy_intp * stridePtr = PyArray_STRIDES(array.ptr());
      opengm::FastSequence<size_t> mystrides(dimension);
      for(size_t i=0;i<dimension;++i){
         mystrides[i]=(stridePtr[i])/sizeof(V);
      }
      view_.assign(shapePtr,shapePtr+dimension,mystrides.begin(),dataPtr,marray::FirstMajorOrder);
   }


   size_t size()const {return view_.size();}
   size_t dimension()const{return view_.dimension();}
   size_t shape(const size_t i)const{return view_.shape(i);}
    size_t const * shapeBegin()const{return view_.shapeBegin();}
    size_t const * shapeEnd()const{return view_.shapeEnd();}
   void error(const std::string &reason=std::string(" "))const{throw opengm::RuntimeError(reason);}
   //ShapeIteratorType shapeBegin()const{return view_.shapeBegin();}
   //ShapeIteratorType shapeEnd()const{return view_.shapeBegin();}
   
   template<class X0>
   const ValueType & operator()(X0 x0)const{
      return view_(x0);
   }
   const ValueType & operator()(const size_t x0,const size_t x1)const{
      return view_(x0,x1);
   }
   const ValueType & operator()(const size_t x0,const size_t x1,const size_t x2)const{
      return view_(x0,x1,x2);
   }
   const ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3)const{
      return view_(x0,x1,x2,x3);
   }
   const ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4)const{
      return view_(x0,x1,x2,x3,x4);
   }
   /*
   const ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4,const size_t x5)const{
      return view_(x0,x1,x2,x3,x4,x5);
   }
   const ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4,const size_t x5,const size_t x6)const{
      return view_(x0,x1,x2,x3,x4,x5,x6);
   }
   const ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4,const size_t x5,const size_t x6,const size_t x7)const{
      return view_(x0,x1,x2,x3,x4,x5,x6,x7);
   }
   const ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4,const size_t x5,const size_t x6,const size_t x7,const size_t x8)const{
      return view_(x0,x1,x2,x3,x4,x5,x6,x7,x8);
   }
   const ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4,const size_t x5,const size_t x6,const size_t x7,const size_t x8,const size_t x9)const{
      return view_(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9);
   }
   */
   template<class ITERATOR>
   const ValueType & operator[](ITERATOR  iterator)const{
      return view_(iterator);
   }
   
   template<class X0>
   ValueType & operator()(X0 x0){
      return view_(x0);
   }
   ValueType & operator()(const size_t x0,const size_t x1){
      return view_(x0,x1);
   }
   ValueType & operator()(const size_t x0,const size_t x1,const size_t x2){
      return view_(x0,x1,x2);
   }
   ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3){
      return view_(x0,x1,x2,x3);
   }
   ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4){
      return view_(x0,x1,x2,x3,x4);
   }
   /*
   ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4,const size_t x5){
      return view_(x0,x1,x2,x3,x4,x5);
   }
   ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4,const size_t x5,const size_t x6){
      return view_(x0,x1,x2,x3,x4,x5,x6);
   }
   ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4,const size_t x5,const size_t x6,const size_t x7){
      return view_(x0,x1,x2,x3,x4,x5,x6,x7);
   }
   ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4,const size_t x5,const size_t x6,const size_t x7,const size_t x8){
      return view_(x0,x1,x2,x3,x4,x5,x6,x7,x8);
   }
   ValueType & operator()(const size_t x0,const size_t x1,const size_t x2,const size_t x3,const size_t x4,const size_t x5,const size_t x6,const size_t x7,const size_t x8,const size_t x9){
      return view_(x0,x1,x2,x3,x4,x5,x6,x7,x8,x9);
   }
   */
   template<class ITERATOR>
   ValueType & operator[](ITERATOR  iterator){
      return view_(iterator);
   }

   ConstIteratorType begin1d()const{ 
      return view_.begin();
   }
   ConstIteratorType end1d()const{ 
      return view_.end();
   }
   IteratorType begin1d(){ 
      return view_.begin();
   }
   IteratorType end1d(){ 
      return view_.end();   
   }

   ConstIteratorType begin()const{ 
      return view_.begin();
   }
   ConstIteratorType end()const{ 
      return view_.end();
   }
   IteratorType begin(){ 
      return view_.begin();
   }
   IteratorType end(){ 
      return view_.end();   
   }

   //boost::python::object arrayObject()const{
   //   return arrayObj_;
   //};
private:
   //boost::python::numeric::array arrayObj_;
   bool allocFromCpp_;
   marray::View< V ,false > view_;
   void * arrayData_;
};

}
}


#endif	/* NUMPYVIEW_INCL_HXX */