20 #ifndef FST_POWER_WEIGHT_H_ 21 #define FST_POWER_WEIGHT_H_ 42 template <
class W,
size_t n>
52 template <
class Iterator>
58 const W &default_weight = W::Zero())
59 :
TupleWeight<W, n>(index, weight, default_weight) {}
76 static const std::string &
Type() {
77 static const std::string *
const type =
78 new std::string(W::Type() +
"_^" + std::to_string(n));
83 return W::Properties() &
97 template <
class W,
size_t n>
101 for (
size_t i = 0; i < n; ++i) {
108 template <
class W,
size_t n>
112 for (
size_t i = 0; i < n; ++i) {
119 template <
class W,
size_t n>
124 for (
size_t i = 0; i < n; ++i) {
131 template <
class W,
size_t n>
135 for (
size_t i = 0; i < n; ++i) {
142 template <
class W,
size_t n>
146 for (
size_t i = 0; i < n; ++i) {
153 template <
class W,
size_t n>
156 for (
size_t i = 0; i < n; ++i) {
164 template <
class W,
size_t n>
171 bool allow_zero =
true)
172 : generate_(seed, allow_zero) {}
176 for (
size_t i = 0; i < n; ++i) result.
SetValue(i, generate_());
186 #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()