diff options
author | jfouet <jfouet@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-16 14:57:24 +0400 |
---|---|---|
committer | jfouet <jfouet@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-16 14:57:24 +0400 |
commit | e9df80a05c442b8b22aad79206872b90ab8c97c1 (patch) | |
tree | 74ddf98cf565dad31ef72c7f2219ae795c4d08d6 /mert/Point.cpp | |
parent | bb42cb0dd591fa91d3ae63a2380a1ba6caed83a2 (diff) |
bugfixes
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1726 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/Point.cpp')
-rw-r--r-- | mert/Point.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/mert/Point.cpp b/mert/Point.cpp index 2fc365baf..18bc8e521 100644 --- a/mert/Point.cpp +++ b/mert/Point.cpp @@ -13,7 +13,9 @@ map<unsigned,statscore_t> Point::fixedweights; unsigned Point::pdim=0; unsigned Point::ncall=0; -void Point::Randomize(const parameters_t& min,const parameters_t& max){ +void Point::Randomize(const vector<parameter_t>& min,const vector<parameter_t>& max){ + assert(min.size()==Point::dim); + assert(max.size()==Point::dim); for (int i=0; i<size(); i++) operator[](i)= min[i] + (float)random()/(float)RAND_MAX * (float)(max[i]-min[i]); } @@ -29,6 +31,19 @@ void Point::Normalize(){ } } +//Can initialize from a vector of dim or pdim +Point::Point(const vector<parameter_t>& init):vector<parameter_t>(Point::dim){ + if(init.size()==dim){ + for (int i=0; i<Point::dim; i++) + operator[](i)=init[i]; + }else{ + assert(init.size()==pdim); + for (int i=0; i<Point::dim; i++) + operator[](i)=init[optindices[i]]; + } +}; + + double Point::operator*(const FeatureStats& F)const{ ncall++;//to track performance double prod=0.0; @@ -61,15 +76,15 @@ Point Point::operator*(float l)const{ }; ostream& operator<<(ostream& o,const Point& P){ - parameters_t w=P.GetAllWeights(); + vector<parameter_t> w=P.GetAllWeights(); for(int i=0;i<Point::pdim;i++) o<<w[i]<<' '; o<<endl; return o; }; -parameters_t Point::GetAllWeights()const{ - parameters_t w; +vector<parameter_t> Point::GetAllWeights()const{ + vector<parameter_t> w; if(OptimizeAll()){ w=*this; }else{ |