16 #ifndef NLP_GRM2_SFST_STATIONARY_DISTRIB_H_ 17 #define NLP_GRM2_SFST_STATIONARY_DISTRIB_H_ 24 #include <fst/signed-log-weight.h> 25 #include <fst/vector-fst.h> 26 #include <fst/weight.h> 50 const fst::Fst<fst::SignedLog64Arc> &
fst,
51 std::vector<fst::SignedLog64Weight> *weight,
53 float delta = fst::kDelta,
70 const fst::Fst<Arc> &
fst,
71 std::vector<typename Arc::Weight> *weight,
72 typename Arc::Weight alpha,
73 typename Arc::Label phi_label = fst::kNoLabel,
74 float delta = fst::kDelta,
77 using Weight =
typename Arc::Weight;
78 using SLArc = f::SignedLog64Arc;
79 using SLWeight = SLArc::Weight;
81 f::VectorFst<SLArc> slfst;
83 f::WeightConvert<Weight, SLWeight> to_sl_convert;
84 auto slalpha = to_sl_convert(alpha);
86 std::vector<SLWeight> slweight;
91 f::WeightConvert<SLWeight, Weight> from_sl_convert;
93 for (
size_t i = 0; i < slweight.size(); ++i) {
95 if (
Less(w, SLWeight::Zero()))
97 weight->push_back(from_sl_convert(w));
104 #endif // NLP_GRM2_SFST_STATIONARY_DISTRIB_H_ bool Less(fst::LogWeightTpl< T > weight1, fst::LogWeightTpl< T > weight2)
const fst::SignedLog64Weight kReEntryWeight
constexpr size_t kMaxSDIters
void RmPhi(const fst::Fst< IArc > &ifst, fst::MutableFst< OArc > *ofst, typename IArc::Label phi_label=fst::kNoLabel, fst::MatcherRewriteMode rewrite_mode=fst::MATCHER_REWRITE_AUTO, const WC &weight_convert=WC())
bool StationaryDistrib(const fst::Fst< Arc > &fst, std::vector< typename Arc::Weight > *weight, typename Arc::Weight alpha, typename Arc::Label phi_label=fst::kNoLabel, float delta=fst::kDelta, size_t max_iters=internal::kMaxSDIters)
bool SignedStationaryDistrib(const fst::Fst< fst::SignedLog64Arc > &fst, std::vector< fst::SignedLog64Weight > *weight, fst::SignedLog64Weight alpha=internal::kReEntryWeight, float delta=fst::kDelta, size_t maxiters=internal::kMaxSDIters)