OpenFst Example Operator Overloading

Quick snippet to drop into programs using OpenFst that overloads the * and + operators to perform the Times and Plus. I find this more readable when adding/multiplying many times.

inline LogArc::Weight operator+(const LogArc::Weight& a, const LogArc::Weight& b)

{

    return Plus(a,b);

}; 

 

inline LogArc::Weight operator*(const LogArc::Weight& a, const LogArc::Weight& b)

{

    return Times(a,b);

}  

This entry was posted by Edobashira. Bookmark the permalink.