add const get accesor to FeatureDataand Array

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1639 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
jfouet 2008-05-14 11:11:55 +00:00
parent b68b41f7e2
commit 40c93618fc
4 changed files with 18 additions and 16 deletions

View File

@ -45,6 +45,7 @@ public:
inline void setIndex(size_t value){ idx=value; }
inline FeatureStats get(int i){ return array_.at(i); }
inline FeatureStats get(int i)const{ return array_.at(i); }
void add(FeatureStats e){ array_.push_back(e); }
inline size_t size(){ return array_.size(); }

View File

@ -36,10 +36,11 @@ public:
inline void clear() { array_.clear(); }
inline FeatureArray get(int i){ return array_.at(i); }
inline FeatureArray get(int i)const{ return array_.at(i); }
inline bool exists(int i){ return (i<array_.size())?true:false; }
inline FeatureStats get(int i, int j){ return array_.at(i).get(j); }
inline FeatureStats get(int i, int j)const{ return array_.at(i).get(j); }
void add(FeatureArray e){ array_.push_back(e); }
void add(FeatureStats e, int sent_idx);

View File

@ -1,6 +1,6 @@
OBJS= Util.o Timer.o Parameter.o \
ScoreStats.o ScoreArray.o ScoreData.o \
FeatureStats.o FeatureArray.o FeatureData.o
FeatureStats.o FeatureArray.o FeatureData.o Optimizer.o Point.o
CFLAGS=-O3 -DTRACE_ENABLE
GCC=g++

View File

@ -24,9 +24,9 @@ float intersect (float b1,m1,b2,m2){
return((b2-b1)/(m2-m1));
}
statscore Optimizer::LineOptimize(const point& start,point direction,point& best){
statscore Optimizer::LineOptimize(const Point& start,Point direction,Point& best){
direction.normalize();//we pass by value so changing is ok
// we are looking for the best point on the line y=start+x*direction
// we are looking for the best Point on the line y=start+x*direction
vector< vector<float,unsigned> > onebest;
float min_int=0.00001;
multimap<float,unsigned> thresholdlist;
@ -56,13 +56,13 @@ statscore Optimizer::LineOptimize(const point& start,point direction,point& best
leftmost=it2;//this is the new reference
}
}
/* Require that the intersection point be at least min_int
/* Require that the intersection Point be at least min_int
to the right of the previous one. If not, we replace the
previous intersection point with this one. Yes, it can even
happen that the new intersection point is slightly to the
previous intersection Point with this one. Yes, it can even
happen that the new intersection Point is slightly to the
left of the old one, because of numerical imprecision. We
don't check that the new point is also min_interval to the
right of the penultimate one. In that case, the points would
don't check that the new Point is also min_interval to the
right of the penultimate one. In that case, the Points would
switch places in the sort, resulting in a bogus score for
that inteval. */
@ -92,16 +92,16 @@ do{
};
point SimpleOptimizer::run(const point& init){
Point SimpleOptimizer::run(const Point& init){
assert(dimension==init.size());
point cur=init;
Point cur=init;
statscore prevscore=FLT_MAX;
statscore bestscore=FLT_MAX;
do{
point best(dimension);
point linebest(dimension);
Point best(dimension);
Point linebest(dimension);
for(int d=0;d<dimension;d++){
point direction(dimension);
Point direction(dimension);
direction[d]=1.0;
statscore curscore=LineOptimize(cur,direction,linebest);//find the minimum on the line
if(curscore<bestscore){