25 template <
typename Aut>
29 auto inis = a->initial_transitions();
32 && a->weightset()->is_one(a->weight_of(inis.front()))
34 && a->in(a->dst_of(inis.front())).empty();
38 template <
typename Aut>
51 template <
typename Aut>
56 const auto& a = aut->as<Aut>();
61 template <
typename Aut>
66 const auto& a = aut->as<Aut>();
79 template <
typename Aut>
86 const auto& ws = *aut->weightset();
87 const auto& inits = aut->initial_transitions();
88 std::vector<transition_t_of<Aut>> initials{begin(inits), end(inits)};
93 auto ini = aut->new_state();
94 for (
auto ti: initials)
97 auto i = aut->dst_of(ti);
98 auto wi = aut->weight_of(ti);
99 for (
auto t: aut->all_out(i))
100 aut->new_transition(ini, aut->dst_of(t), aut->label_of(t),
101 ws.mul(wi, aut->weight_of(t)));
102 aut->del_transition(ti);
106 if (aut->all_in(i).empty())
111 aut->set_initial(ini);
114 template <
typename Aut>
117 -> decltype(
copy(aut))
119 auto res =
copy(aut);
124 template <
typename Aut>
127 -> decltype(
copy(aut))
138 template <
typename Aut>
143 const auto& a = aut->as<Aut>();
148 template <
typename Aut>
153 const auto& a = aut->as<Aut>();
170 template <
typename Aut,
173 :
public ExpSet::const_visitor
182 using super_t =
typename expressionset_t::const_visitor;
185 constexpr
static const char*
me() {
return "standard"; }
208 virtual
void visit(const tuple_t&,
std::true_type)
override
210 raise(
me(),
": tuple is not supported");
220 auto i =
res_->new_state();
227 auto i =
res_->new_state();
228 auto f =
res_->new_state();
230 res_->new_transition(i, f, e.value());
240 for (
auto t:
res_->final_transitions())
241 res.insert(
res_->src_of(t));
248 e.head()->accept(*
this);
250 for (
auto c: e.tail())
256 res_->add_transition(initial,
273 e.head()->accept(*
this);
277 for (
auto c: e.tail())
288 if (!
has(other_finals,
res_->src_of(t1)))
302 auto s1 =
res_->src_of(t1);
303 auto w1 =
res_->weight_of(t1);
304 res_->del_transition(t1);
306 res_->set_transition(s1,
309 ws_.mul(w1,
res_->weight_of(t2)));
320 e.sub()->accept(*
this);
327 res_->lmul_weight(ti, w);
328 for (
auto tf:
res_->final_transitions())
330 && !
has(other_finals,
res_->src_of(tf)))
340 ws_.mul(
res_->weight_of(tf),
res_->weight_of(ti)));
342 for (
auto tf:
res_->final_transitions())
343 res_->rmul_weight(tf, w);
349 e.sub()->accept(*
this);
351 res_->lmul_weight(t, e.weight());
357 e.sub()->accept(*
this);
358 for (
auto t:
res_->final_transitions())
359 if (!
has(other_finals,
res_->src_of(t)))
360 res_->rmul_weight(t, e.weight());
377 template <
typename Aut,
391 template <
typename ExpSet>
397 using expressionset_t = ExpSet;
400 const auto& e = exp->as<expressionset_t>();
401 return make_automaton(::vcsn::standard<automaton_t>(e.expressionset(),
std::vector< typename Cont::value_type > make_vector(const Cont &cont)
The content of cont as a vector.
auto costandard(const Aut &aut) -> decltype(copy(aut))
automaton costandard(const automaton &aut)
Bridge.
const expressionset_t & rs_
automaton standard_expression(const expression &exp)
Bridge (standard).
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
bool is_costandard(const Aut &a)
Whether a is costandard.
typename expressionset_t::const_visitor super_t
VCSN_RAT_VISIT(lweight, e)
SharedPtr make_shared_ptr(Args &&...args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
Aut transpose(const transpose_automaton< Aut > &aut)
automaton standard(const automaton &aut)
Bridge.
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
AutOut copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans)
A copy of input keeping only its states that are accepted by keep_state.
bool is_standard(const Aut &a)
Whether a is standard.
weight_t_of< expressionset_t > weight_t
Provide a variadic mul on top of a binary mul(), and one().
std::shared_ptr< detail::automaton_base > automaton
typename super_t::tuple_t tuple_t
bool is_costandard(const automaton &aut)
Bridge.
weightset_t_of< expressionset_t > weightset_t
std::set< state_t > states_t
The current set of final states.
automaton_t operator()(const typename expressionset_t::value_t &v)
virtual void visit(const tuple_t &, std::true_type) override
ATTRIBUTE_PURE bool has(const std::deque< T, Allocator > &s, const T &e)
Whether e is member of s.
An inner node implementing a weight.
Build a standard automaton from an expression.
std::shared_ptr< detail::expression_base > expression
auto standard(const Aut &aut) -> decltype(copy(aut))
VCSN_RAT_VISIT(rweight, e)
void standard_here(Aut &aut)
Turn aut into a standard automaton.
bool is_standard(const automaton &aut)
Bridge.
state_t_of< automaton_t > state_t
standard_visitor(const expressionset_t &rs)
static constexpr const char * me()
Name of this algorithm, for error messages.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
An inner node with multiple children.
#define VCSN_RAT_UNSUPPORTED(Type)
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of