/usr/include/opengm/inference/dualdecomposition/dddualvariableblock.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 | #pragma once
#ifndef OPENGM_DD_DUALVARIABLEBLOCK_HXX
#define OPENGM_DD_DUALVARIABLEBLOCK_HXX
#include "opengm/datastructures/marray/marray.hxx"
#include "opengm/graphicalmodel/decomposition/graphicalmodeldecomposition.hxx"
namespace opengm {
/// \cond HIDDEN_SYMBOLS
template<class DUALVAR = marray::Marray<double> >
class DDDualVariableBlock{
public:
typedef DUALVAR DualVariableType;
typedef typename DUALVAR::ValueType ValueType;
typedef typename GraphicalModelDecomposition::SubFactor SubFactorType;
typedef typename GraphicalModelDecomposition::SubFactorListType SubFactorListType;
// Methods
DDDualVariableBlock(){};
template<class ITERATOR> DDDualVariableBlock(const SubFactorListType& subFactorList, ITERATOR shapeBegin, ITERATOR shapeEnd);
std::vector<DUALVAR*> getPointers();
void test() const;
// Members
std::vector<DualVariableType> duals_;
const SubFactorListType* subFactorList_;
};
template<class DUALVAR = marray::Marray<double> >
class DDDualVariableBlock2{
public:
typedef DUALVAR DualVariableType;
typedef typename DUALVAR::ValueType ValueType;
typedef typename GraphicalModelDecomposition::SubFactor SubFactorType;
typedef typename GraphicalModelDecomposition::SubFactorListType SubFactorListType;
// Methods
DDDualVariableBlock2(){};
template<class ITERATOR> DDDualVariableBlock2(const SubFactorListType& subFactorList, ITERATOR shapeBegin, ITERATOR shapeEnd);
std::vector<DUALVAR*> getPointers();
void test() const;
// Members
std::vector<DualVariableType> duals_;
std::vector<DualVariableType> duals2_;
const SubFactorListType* subFactorList_;
};
/////////////////////////////////
////////////////////////////////
template<class DUALVAR>
template<class ITERATOR>
DDDualVariableBlock<DUALVAR>::DDDualVariableBlock
(
const typename GraphicalModelDecomposition::SubFactorListType& subFactorList,
ITERATOR shapeBegin,
ITERATOR shapeEnd
)
{
const size_t numDuals = subFactorList.size();
duals_.resize(numDuals, DUALVAR(shapeBegin,shapeEnd,0));
subFactorList_ = &subFactorList;
}
template<>
template<class ITERATOR>
DDDualVariableBlock<marray::View<double,false> >::DDDualVariableBlock
(
const SubFactorListType& subFactorList,
ITERATOR shapeBegin,
ITERATOR shapeEnd
)
{
const size_t numDuals = subFactorList.size();
double tmp;
duals_.resize(numDuals, marray::View<double,false>(shapeBegin,shapeEnd,&tmp));
subFactorList_ = &subFactorList;
}
template<>
template<class ITERATOR>
DDDualVariableBlock<marray::View<float,false> >::DDDualVariableBlock
(
const SubFactorListType& subFactorList,
ITERATOR shapeBegin,
ITERATOR shapeEnd
)
{
const size_t numDuals = subFactorList.size();
double tmp;
duals_.resize(numDuals, marray::View<float,false>(shapeBegin,shapeEnd,&tmp));
subFactorList_ = &subFactorList;
}
template<class DUALVAR>
std::vector<DUALVAR*> DDDualVariableBlock<DUALVAR>::getPointers()
{
std::vector<DualVariableType*> ret(duals_.size());
for(size_t i=0; i<duals_.size(); ++i) ret[i] = &(duals_[i]);
return ret;
}
template<class DUALVAR>
void DDDualVariableBlock<DUALVAR>::test() const
{
marray::Marray<double> temp(duals_[0].shapeBegin(), duals_[0].shapeEnd() ,0);
for(size_t i=0; i<duals_.size(); ++i) {
temp += duals_[i];
}
//std::cout<<" temp size "<<temp.size()<<"\n";
for(size_t j=0; j<temp.size(); ++j) {
if( (temp(j)<0.001 && temp(j)>-0.001)==false ){
std::cout<<"temp("<<j<<") = "<<temp(j)<<"\n";
}
//OPENGM_ASSERT(temp(i)<0.00001 && temp(i)>-0.00001);
}
}
////////////////////////////////////////
template<class DUALVAR>
template<class ITERATOR>
DDDualVariableBlock2<DUALVAR>::DDDualVariableBlock2
(
const typename GraphicalModelDecomposition::SubFactorListType& subFactorList,
ITERATOR shapeBegin,
ITERATOR shapeEnd
)
{
const size_t numDuals = subFactorList.size();
duals_.resize(numDuals, DUALVAR(shapeBegin,shapeEnd,0));
duals2_.resize(numDuals, DUALVAR(shapeBegin,shapeEnd,0));
subFactorList_ = &subFactorList;
}
template<>
template<class ITERATOR>
DDDualVariableBlock2<marray::View<double,false> >::DDDualVariableBlock2
(
const SubFactorListType& subFactorList,
ITERATOR shapeBegin,
ITERATOR shapeEnd
)
{
const size_t numDuals = subFactorList.size();
double tmp;
duals_.resize(numDuals, marray::View<double,false>(shapeBegin,shapeEnd,&tmp));
duals2_.resize(numDuals, marray::View<double,false>(shapeBegin,shapeEnd,&tmp));
subFactorList_ = &subFactorList;
}
template<>
template<class ITERATOR>
DDDualVariableBlock2<marray::View<float,false> >::DDDualVariableBlock2
(
const SubFactorListType& subFactorList,
ITERATOR shapeBegin,
ITERATOR shapeEnd
)
{
const size_t numDuals = subFactorList.size();
float tmp;
duals_.resize(numDuals, marray::View<float,false>(shapeBegin,shapeEnd,&tmp));
duals2_.resize(numDuals, marray::View<float,false>(shapeBegin,shapeEnd,&tmp));
subFactorList_ = &subFactorList;
}
template<class DUALVAR>
std::vector<DUALVAR*> DDDualVariableBlock2<DUALVAR>::getPointers()
{
std::vector<DualVariableType*> ret(duals_.size());
for(size_t i=0; i<duals_.size(); ++i) ret[i] = &(duals_[i]);
return ret;
}
template<class DUALVAR>
void DDDualVariableBlock2<DUALVAR>::test() const
{
marray::Marray<double> temp(duals_[0].shapeBegin(),duals_[0].shapeEnd(),0);
for(size_t i=0; i<duals_.size(); ++i) temp += duals_[i];
for(size_t i=0; i<temp.size(); ++i) OPENGM_ASSERT(temp(i)<0.00001 && temp(i)>-0.00001);
}
/// \endcond HIDDEN_SYMBOLS
} // namespace opengm
#endif
|