20 #ifndef FST_POWER_WEIGHT_H_ 21 #define FST_POWER_WEIGHT_H_ 43 template <
class W,
size_t n>
53 template <
class Iterator>
59 const W &default_weight = W::Zero())
60 :
TupleWeight<W, n>(index, weight, default_weight) {}
77 static const std::string &
Type() {
78 static const std::string *
const type =
79 new std::string(W::Type() +
"_^" + std::to_string(n));
84 return W::Properties() &
98 template <
class W,
size_t n>
102 for (
size_t i = 0; i < n; ++i) {
109 template <
class W,
size_t n>
113 for (
size_t i = 0; i < n; ++i) {
120 template <
class W,
size_t n>
125 for (
size_t i = 0; i < n; ++i) {
132 template <
class W,
size_t n>
136 for (
size_t i = 0; i < n; ++i) {
143 template <
class W,
size_t n>
147 for (
size_t i = 0; i < n; ++i) {
154 template <
class W,
size_t n>
157 for (
size_t i = 0; i < n; ++i) {
165 template <
class W,
size_t n>
172 bool allow_zero =
true)
173 : generate_(seed, allow_zero) {}
177 for (
size_t i = 0; i < n; ++i) result.
SetValue(i, generate_());
187 #endif // FST_POWER_WEIGHT_H_ void SetValue(size_t i, const W &w)
PowerWeight< typename W::ReverseWeight, n > ReverseWeight
ErrorWeight Plus(const ErrorWeight &, const ErrorWeight &)
ErrorWeight Times(const ErrorWeight &, const ErrorWeight &)
PowerWeight(Iterator begin, Iterator end)
Weight operator()() const
constexpr uint64_t kIdempotent
ReverseWeight Reverse() const
WeightGenerate(uint64_t seed=std::random_device()(), bool allow_zero=true)
constexpr uint64_t kRightSemiring
W DotProduct(const PowerWeight< W, n > &w1, const PowerWeight< W, n > &w2)
const W & Value(size_t i) const
static const PowerWeight & NoWeight()
constexpr uint64_t kCommutative
PowerWeight(const TupleWeight< W, n > &weight)
static constexpr uint64_t Properties()
static const std::string & Type()
ErrorWeight Divide(const ErrorWeight &, const ErrorWeight &)
PowerWeight(size_t index, const W &weight, const W &default_weight=W::Zero())
static const PowerWeight & One()
constexpr uint64_t kLeftSemiring
PowerWeight Quantize(float delta=kDelta) const
static const PowerWeight & Zero()