40 #ifndef FST_EXPECTATION_WEIGHT_H_ 41 #define FST_EXPECTATION_WEIGHT_H_ 61 template <
class W1,
class W2>
96 static const std::string &
Type() {
97 static const std::string *
const type =
98 new std::string(
"expectation_" + W1::Type() +
"_" + W2::Type());
113 return W1::Properties() & W2::Properties() &
118 template <
class W1,
class W2>
125 template <
class W1,
class W2>
141 template <
class W1,
class W2>
165 const auto w11 = w1.
Value1();
166 const auto w12 = w1.
Value2();
167 const auto w21 = w2.
Value1();
168 const auto w22 = w2.
Value2();
169 const W1 q1 =
Divide(w11, w21, typ);
181 template <
class W1,
class W2>
199 adder1_.Reset(w.Value1());
200 adder2_.Reset(w.Value2());
211 template <
class W1,
class W2>
218 bool allow_zero =
true)
219 : generate_(seed, allow_zero) {}
229 #endif // FST_EXPECTATION_WEIGHT_H_ static const ExpectationWeight & One()
Weight operator()() const
ErrorWeight Plus(const ErrorWeight &, const ErrorWeight &)
static const ExpectationWeight & Zero()
ErrorWeight Times(const ErrorWeight &, const ErrorWeight &)
Weight Add(const Weight &w)
const W2 & Value2() const
constexpr uint64_t kIdempotent
ExpectationWeight< typename W1::ReverseWeight, typename W2::ReverseWeight > ReverseWeight
constexpr uint64_t kRightSemiring
ExpectationWeight Quantize(float delta=kDelta) const
WeightGenerate(uint64_t seed=std::random_device()(), bool allow_zero=true)
void Reset(Weight w=Weight::Zero())
constexpr uint64_t kCommutative
ExpectationWeight(const W1 &w1, const W2 &w2)
static constexpr uint64_t Properties()
LogWeightTpl< T > Minus(const LogWeightTpl< T > &w1, const LogWeightTpl< T > &w2)
ErrorWeight Divide(const ErrorWeight &, const ErrorWeight &)
ExpectationWeight(const PairWeight< W1, W2 > &weight)
ReverseWeight Reverse() const
static const std::string & Type()
constexpr uint64_t kLeftSemiring
const W1 & Value1() const
static const ExpectationWeight & NoWeight()