20 bool has_one = labelset_t_of<Aut>::has_one()>
26 using weight_t =
typename weightset_t::value_t;
46 :
ws_(*aut->weightset())
55 aut_dirty_ = make_shared_ptr<aut_dirty_t>(dirty_ctx);
56 aut_proper_ = make_shared_ptr<aut_proper_t>(proper_ctx);
61 pcopier([](
state_t) {
return true; },
63 return !aut->labelset()->is_one(aut->label_of(t));
67 return (!
in(aut, s, aut->labelset()->one()).empty()
68 || !
out(aut, s, aut->labelset()->one()).empty());
71 return aut->labelset()->is_one(aut->label_of(t));
75 const auto& dorigins = dcopier.state_map();
76 const auto& porigins = pcopier.state_map();
77 for (
const auto& dp : dorigins)
79 auto pp = porigins.find(dp.first);
80 assert(pp != porigins.end());
81 d2p_[dp.second] = pp->second;
82 p2d_[pp->second] = dp.second;
96 if (!
ws_.is_zero(dist_pq))
98 auto proper_q =
d2p_[dirty_q];
101 auto proper_p =
d2p_[dirty_p];
106 ws_.mul(dist_pq, w));
129 std::vector<state_proper_t>
d2p_;
131 std::vector<state_dirty_t>
p2d_;
133 std::vector<std::vector<weight_t>>
de_;
136 template <Automaton Aut>
state_t_of< aut_proper_t > state_proper_t
transition_t_of< automaton_t > transition_t
mutable_automaton< dirty_ctx_t > aut_dirty_t
Spontaneous automaton.
std::vector< std::vector< weight_t > > de_
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
fresh_automaton_t_of< Aut, proper_ctx_t > aut_proper_t
Proper automaton.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
size_t states_size(const Aut &aut)
The largest state number, plus one.
auto in(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions arriving to state s.
std::remove_cv_t< Aut > automaton_t
auto out(const Aut &aut, state_t_of< Aut > s)
Indexes of visible transitions leaving state s.
state_t_of< automaton_t > state_t
labelset_t_of< automaton_t > labelset_t
std::remove_cv_t< Aut > automaton_t
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
const weightset_t & ws_
Shorthand to the weightset.
aut_proper_t operator()()
auto copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans) -> decltype(keep_state(input->null_state()), keep_trans(input->null_transition()), make_fresh_automaton< AutIn, AutOut >(input))
A copy of input keeping only its states that are accepted by keep_state, and transitions accepted by ...
typename weightset_t::value_t weight_t
std::vector< state_proper_t > d2p_
dirty states -> proper states.
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
std::vector< std::vector< weight_t_of< Aut > > > all_distances(const Aut &aut)
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
Given an automaton type, the type of its copies.
bool prune_
Whether to prune states that become inaccessible.
auto all_in(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions entering state s.
epsilon_remover_distance(const automaton_t &aut, bool prune=true)
This class contains the core of the proper algorithm.
detail::copier< AutIn, AutOut > make_copier(const AutIn &in, AutOut &out, bool safe=true)
Build an automaton copier.
weightset_t_of< automaton_t > weightset_t
aut_proper_t aut_proper_
The automata we work on.
aut_proper_t operator()()
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::vector< state_dirty_t > p2d_
proper states -> dirty states.
state_t_of< aut_dirty_t > state_dirty_t
auto all_out(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions leaving state s.
fresh_automaton_t_of< automaton_t > aut_proper_t
epsilon_remover_distance(const automaton_t &aut, bool)
label_t_of< aut_proper_t > label_proper_t
auto make_proper_context(const context< LabelSet, WeightSet > &ctx) -> proper_context< context< LabelSet, WeightSet >>
From a context, its non-nullable context.