diff options
author | redpony <redpony@ca354974-eb3a-0410-8f5c-d3948404989b> | 2007-09-25 06:39:22 +0400 |
---|---|---|
committer | redpony <redpony@ca354974-eb3a-0410-8f5c-d3948404989b> | 2007-09-25 06:39:22 +0400 |
commit | 2429fa62d9fb266d42d9af8efd4a861627f0858c (patch) | |
tree | 7403fdcb73ea7c17f6065c4c349f7fd652884480 | |
parent | 4bf5e78d59d755f5f97a78b5ff76829c81b16a80 (diff) |
a few fixes for the Intel optimizing compiler
-rw-r--r-- | GIZA++-v2/Perplexity.h | 10 | ||||
-rw-r--r-- | GIZA++-v2/Pointer.h | 4 | ||||
-rw-r--r-- | GIZA++-v2/Vector.h | 4 | ||||
-rw-r--r-- | GIZA++-v2/WordClasses.h | 2 | ||||
-rw-r--r-- | GIZA++-v2/logprob.cpp | 13 | ||||
-rw-r--r-- | GIZA++-v2/logprob.h | 21 | ||||
-rw-r--r-- | GIZA++-v2/model1.h | 12 |
7 files changed, 27 insertions, 39 deletions
diff --git a/GIZA++-v2/Perplexity.h b/GIZA++-v2/Perplexity.h index e363680..b06b3dc 100644 --- a/GIZA++-v2/Perplexity.h +++ b/GIZA++-v2/Perplexity.h @@ -75,25 +75,25 @@ class Perplexity { sum = 0 ; wc = 0 ; } - const size_t size()const{return(min(perp.size(), ce.size()));} + size_t size() const {return(min(perp.size(), ce.size()));} inline void addFactor(const double p, const double count, const int l, const int m,bool withPoisson) { wc += count * m ; // number of french words sum += count * ( (withPoisson?((*E_M_L)(l, m)):0.0) + p) ; } - inline double perplexity() { + inline double perplexity() const { return exp( -1*sum / wc); } - inline double cross_entropy() { + inline double cross_entropy() const { return (-1.0*sum / (log(double(CROSS_ENTROPY_BASE)) * wc)); } - inline double word_count() { + inline double word_count() const { return wc; } - inline double getSum(){ + inline double getSum() const { return sum ; } diff --git a/GIZA++-v2/Pointer.h b/GIZA++-v2/Pointer.h index c6a2dc0..7d786e5 100644 --- a/GIZA++-v2/Pointer.h +++ b/GIZA++-v2/Pointer.h @@ -38,7 +38,7 @@ class SmartPointer {return *p;} inline T*operator->() const {return p;} - inline operator const bool() const + inline operator bool() const {return p!=0;} inline T*ptr() const { return p; } @@ -59,7 +59,7 @@ class SmartPointerConst {return *p;} inline const T*operator->() const {return p;} - inline operator const bool() const + inline operator bool() const {return p!=0;} inline const T*ptr() const { return p; } diff --git a/GIZA++-v2/Vector.h b/GIZA++-v2/Vector.h index a550e82..d0d5d1f 100644 --- a/GIZA++-v2/Vector.h +++ b/GIZA++-v2/Vector.h @@ -210,7 +210,7 @@ template<class T> class Vector { return maxWritten; } int findMax() const; int findMin() const; - const void errorAccess(int n) const; + void errorAccess(int n) const; inline T*getPointerToData(){return p;} inline T*begin(){return p;} inline T*end(){return p+maxWritten+1;} @@ -333,7 +333,7 @@ template<class T> bool operator<(const Vector<T> &x, const Vector<T> &y) } -template<class T> const void Vector<T>:: errorAccess(int n) const +template<class T> void Vector<T>:: errorAccess(int n) const { cerr << "ERROR: Access to array element " << n << " (" << maxWritten << ", " << realSize << ", " << (void*)p << ")\n"; diff --git a/GIZA++-v2/WordClasses.h b/GIZA++-v2/WordClasses.h index 1fea083..d8431f8 100644 --- a/GIZA++-v2/WordClasses.h +++ b/GIZA++-v2/WordClasses.h @@ -73,7 +73,7 @@ class WordClasses else return 0; } - const int operator()(const string&x)const + int operator()(const string&x)const { if( Sc2int.count(x) ) return Sc2int.find(x)->second; diff --git a/GIZA++-v2/logprob.cpp b/GIZA++-v2/logprob.cpp index 8134b77..9035f80 100644 --- a/GIZA++-v2/logprob.cpp +++ b/GIZA++-v2/logprob.cpp @@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#pragma implementation // Routines to perform integer exponential arithmetic. // A number x is represented as n, where x = b**n. @@ -63,7 +62,7 @@ const LogProb LogProb::minus16(1e-16); int LogProb::Initialize() { int nbytes = sizeof(double)*(nmax-nmin+1) + sizeof(int)*(0-tblbnd+1); - cerr << nbytes << " bytes used for LogProb tables (C++ version)\n"; + std::cerr << nbytes << " bytes used for LogProb tables (C++ version)\n"; ntof = new double[nmax-nmin+1]; addtbl = new int[-tblbnd+1]; subtbl = new int[-tblbnd+1]; @@ -75,7 +74,7 @@ int LogProb::Initialize() // if (!ifs) // { int i; - cerr << "Building integer logs conversion tables\n"; + std::cerr << "Building integer logs conversion tables\n"; ntof[0] = 0 ; for (i=nmin+1; i<=nmax; ++i) @@ -140,7 +139,7 @@ LogProb& LogProb::operator-=(const LogProb &subs) { if (a < 0) { - cerr << "WARNING(logprob): Invalid arguments to nsub" <<(*this)<< " " << subs << endl; + std::cerr << "WARNING(logprob): Invalid arguments to nsub" <<(*this)<< " " << subs << std::endl; //abort(); } logr = zeron; @@ -153,9 +152,3 @@ LogProb& LogProb::operator-=(const LogProb &subs) } - - - - - - diff --git a/GIZA++-v2/logprob.h b/GIZA++-v2/logprob.h index feaf7cb..14696ac 100644 --- a/GIZA++-v2/logprob.h +++ b/GIZA++-v2/logprob.h @@ -22,8 +22,6 @@ USA. #ifndef _LOGPROB_H #define _LOGPROB_H -#pragma interface - // Routines to perform integer exponential arithmetic. // A number x is represented as n, where x = b**n // It is assumed that b > 1, something like b = 1.001 @@ -61,10 +59,10 @@ public: int operator!() const { return logr == zeron; } // iostream friend specifications - friend ostream& operator<<(ostream& os, const LogProb &obj); - friend istream& operator>>(istream& is, LogProb &obj); - friend ostream& operator<<=(ostream& os, const LogProb &obj); - friend istream& operator>>=(istream& is, LogProb &obj); + friend std::ostream& operator<<(std::ostream& os, const LogProb &obj); + friend std::istream& operator>>(std::istream& is, LogProb &obj); + friend std::ostream& operator<<=(std::ostream& os, const LogProb &obj); + friend std::istream& operator>>=(std::istream& is, LogProb &obj); // arithmetic operators LogProb &operator+=(const LogProb &add) // logr2 = logb ( b**logr2 + b**logr1 ) @@ -190,12 +188,12 @@ public: }; // iostream friend operators -inline ostream &operator<<(ostream& os, const LogProb &obj) +inline std::ostream &operator<<(std::ostream& os, const LogProb &obj) { return os << (double) obj; // output in linear domain, b**logr } -inline istream &operator>>(istream& is, LogProb &obj) +inline std::istream &operator>>(std::istream& is, LogProb &obj) { double d; is >> d; @@ -203,13 +201,13 @@ inline istream &operator>>(istream& is, LogProb &obj) return is; } -inline ostream &operator<<=(ostream& os, const LogProb &obj) // write binary +inline std::ostream &operator<<=(std::ostream& os, const LogProb &obj) // write binary { os.write((const char *)&obj.logr, sizeof(obj.logr)); return os; } -inline istream &operator>>=(istream& is, LogProb &obj) +inline std::istream &operator>>=(std::istream& is, LogProb &obj) { is.read((char *)&obj.logr, sizeof(obj.logr)); return is; @@ -217,6 +215,3 @@ inline istream &operator>>=(istream& is, LogProb &obj) #endif - - - diff --git a/GIZA++-v2/model1.h b/GIZA++-v2/model1.h index ef16a29..a49b2c6 100644 --- a/GIZA++-v2/model1.h +++ b/GIZA++-v2/model1.h @@ -99,12 +99,12 @@ public: void load_table(const char* tname); void readVocabFile(const char* fname, Vector<WordEntry>& vlist, int& vsize, int& total); - inline const Vector<WordEntry>& getEnglishVocabList(void)const {return Elist.getVocabList();}; - inline const Vector<WordEntry>& getFrenchVocabList(void)const {return Flist.getVocabList();}; - inline const double getETotalWCount(void) const {return eTotalWCount;}; - inline const double getFTotalWCount(void) const {return fTotalWCount;}; - inline const int getNoEnglishWords(void) const {return noEnglishWords;}; - inline const int getNoFrenchWords(void) const {return noFrenchWords;}; + inline Vector<WordEntry>& getEnglishVocabList(void)const {return Elist.getVocabList();}; + inline Vector<WordEntry>& getFrenchVocabList(void)const {return Flist.getVocabList();}; + inline double getETotalWCount(void) const {return eTotalWCount;}; + inline double getFTotalWCount(void) const {return fTotalWCount;}; + inline int getNoEnglishWords(void) const {return noEnglishWords;}; + inline int getNoFrenchWords(void) const {return noFrenchWords;}; inline tmodel<COUNT, PROB>& getTTable(void) {return tTable;}; inline string& getEFFilename(void) {return efFilename;}; private: |