diff options
author | jfouet <jfouet@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-14 15:32:17 +0400 |
---|---|---|
committer | jfouet <jfouet@1f5c12ca-751b-0410-a591-d2e778427230> | 2008-05-14 15:32:17 +0400 |
commit | 43ba7835bb4a96c1886833f7804930727ef81cb8 (patch) | |
tree | 83cbbf187476aed69481c59c5385f0e162605a91 /mert/Point.cpp | |
parent | 36b25323c954a72a7b9b83bc6310c5f43ffa794d (diff) |
class to inplement a set of lambda parameter and their stat score
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1642 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/Point.cpp')
-rw-r--r-- | mert/Point.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mert/Point.cpp b/mert/Point.cpp new file mode 100644 index 000000000..2e6ebc425 --- /dev/null +++ b/mert/Point.cpp @@ -0,0 +1,25 @@ +#include "Point.h" +#include<cmath> + +using namespace std; +void Point::randomize(const vector<lambda>& min,const vector<lambda>& max){ + for (int i=0; i<size(); i++) + operator[](i)= min[i] + (float)random()/RAND_MAX * (max[i]-min[i]); +} + +void Point::normalize(){ + lambda norm=0.0; + for (int i=0; i<size(); i++) + norm+= operator[](i)*operator[](i); + if(norm!=0.0){ + norm=sqrt(norm); + for (int i=0; i<size(); i++) + operator[](i)/=norm; + } +} + +double Point::operator*(FeatureStats& F)const{ + double prod=0.0; +for (int i=0; i<size(); i++) + prod+= operator[](i)*F.get(i); +} |