16 template <
typename Aut>
20 "evaluate: requires free labelset");
26 using weight_t =
typename weightset_t::value_t;
56 auto ls = *
aut_->labelset();
57 for (
auto l : ls.letters_of(ls.delimit(word)))
59 v2.assign(v2.size(), zero);
60 for (
size_t s = 0; s < v1.size(); ++s)
61 if (!
ws_.is_zero(v1[s]))
62 for (
auto t :
aut_->out(s, l))
67 auto dst =
aut_->dst_of(t);
70 auto capacity = v2.capacity();
71 while (capacity <= dst)
75 v1.resize(dst + 1, zero);
76 v2.resize(dst + 1, zero);
83 ws_.mul(v1[s],
aut_->weight_of(t)));
87 return v1[
aut_->post()];
96 template <
typename Aut>
111 template <
typename Aut,
typename LabelSet>
115 const auto& a = aut->as<Aut>();
116 const auto& l = lbl->as<LabelSet>().
label();
118 const auto&
ctx = a->context();
std::shared_ptr< const detail::label_base > label
evaluator(const automaton_t &a)
std::vector< weight_t > weights_t
typename weightset_t::value_t weight_t
Container::value_type back(const Container &container)
The last member of this Container.
auto eval(const Aut &a, const word_t_of< Aut > &w) -> weight_t_of< Aut >
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
weightset_t_of< automaton_t > weightset_t
state_t_of< automaton_t > state_t
typename labelset_t_of< base_t< ValueSet >>::word_t word_t_of
weight eval(const automaton &aut, const label &lbl)
Bridge.
static dyn::context ctx(const driver &d)
Get the context of the driver.
std::shared_ptr< const detail::weight_base > weight
weight make_weight(const WeightSet &ws, const typename WeightSet::value_t &w)
std::shared_ptr< detail::automaton_base > automaton
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
weight_t operator()(const word_t &word) const
word_t_of< automaton_t > word_t
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of