1 #ifndef VCSN_ALGOS_EVAL_HH
2 # define VCSN_ALGOS_EVAL_HH
17 template <
typename Aut>
21 "evaluate: requires free labelset");
27 using weight_t =
typename weightset_t::value_t;
35 ,
ws_(*
a_->weightset())
47 const auto& states =
a_->states();
48 size_t last_state = *std::max_element(std::begin(states),
54 v1[
a_->pre()] =
ws_.one();
58 auto ls = *
a_->labelset();
59 for (
auto l : ls.letters_of(ls.delimit(word)))
61 v2.assign(v2.size(), zero);
62 for (
size_t s = 0; s < v1.size(); ++s)
63 if (!
ws_.is_zero(v1[s]))
64 for (
auto t :
a_->out(s, l))
69 ws_.add(v2[
a_->dst_of(t)],
70 ws_.mul(v1[s],
a_->weight_of(t)));
73 return v1[
a_->post()];
82 template <
typename Aut>
97 template <
typename Aut,
typename LabelSet>
102 const auto& a = aut->as<Aut>();
105 const auto& ctx = a->context();
117 #endif // !VCSN_ALGOS_EVAL_HH
std::vector< weight_t > weights_t
typename weightset_t::value_t weight_t
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
typename labelset_t_of< automaton_t >::word_t word_t
state_t_of< automaton_t > state_t
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
std::shared_ptr< const detail::weight_base > weight
weightset_t_of< automaton_t > weightset_t
auto eval(const automaton &aut, const label &lbl) -> weight
Bridge.
weight_t operator()(const word_t &word) const
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::shared_ptr< const detail::label_base > label
weight make_weight(const WeightSet &ws, const typename WeightSet::value_t &w)
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
evaluator(const automaton_t &a)
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto eval(const Aut &a, const typename labelset_t_of< Aut >::word_t &w) -> weight_t_of< Aut >