1 #ifndef VCSN_ALGOS_LIFT_HH
2 # define VCSN_ALGOS_LIFT_HH
22 template <
typename ValueSet>
25 using type =
typename ValueSet::context_t;
28 template <
typename Context>
34 template <
typename ValueSet>
37 template <
typename Context>
41 template <
typename Aut>
45 template <
typename RatExpSet>
50 template <
typename LabelSet,
typename WeightSet>
61 template <
typename Context>
62 lifted_ratexpset_t<ratexpset<Context>>
74 template <
typename Aut>
76 detail::lifted_automaton_t<Aut>
79 using auto_in_t =
typename Aut::element_type;
85 rs_in_t rs_in{a->context(), rs_in_t::identities_t::trivial};
90 auto_out_t res = make_shared_ptr<auto_out_t>(ctx_out);
91 std::map<state_in_t, state_out_t>
map;
92 map[a->pre()] = res->pre();
93 map[a->post()] = res->post();
94 for (
auto s: a->states())
95 map[s] = res->new_state();
97 for (
auto t: a->all_transitions())
98 if (a->src_of(t) == a->pre())
99 res->add_initial(map[a->dst_of(t)],
100 rs_in.lmul(a->weight_of(t), rs_in.one()));
101 else if (a->dst_of(t) == a->post())
102 res->add_final(map[a->src_of(t)],
103 rs_in.lmul(a->weight_of(t), rs_in.one()));
106 (map[a->src_of(t)], map[a->dst_of(t)],
108 rs_in.lmul(a->weight_of(t), rs_in.atom(a->label_of(t))));
117 template <
typename Aut>
121 const auto& a = aut->as<Aut>();
137 template <
typename Exp>
142 template <
typename RatExpSet>
145 lift(
const RatExpSet& rs,
const typename RatExpSet::value_t& e)
148 return lrs.lmul(e, lrs.one());
161 template <
typename RatExpSet>
165 const auto& e = exp->as<RatExpSet>();
177 #endif // !VCSN_ALGOS_LIFT_HH
ratexp make_ratexp(const RatExpSet &rs, const typename RatExpSet::value_t &ratexp)
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
std::shared_ptr< detail::ratexp_base > ratexp
Implementation of labels are ones: there is a single instance of label.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
ratexp lift_ratexp(const ratexp &exp)
Bridge.
automaton lift_automaton(const automaton &aut)
mutable_automaton< lifted_context_t< context_t_of< Aut >>> lifted_automaton_t
detail::lifted_automaton_t< Aut > lift(const Aut &a)
auto map(const std::tuple< Ts...> &ts, Fun f) -> decltype(map_tuple_(f, ts, make_index_sequence< sizeof...(Ts)>()))
Map a function on a tuple, return tuple of the results.
Provide a variadic mul on top of a binary mul(), and one().
typename ValueSet::context_t type
lifted_ratexpset_t< ratexpset< Context > > lift_ratexpset(const ratexpset< Context > &rs)
typename lifted_context_t< context_t_of< Exp >>::ratexp_t lifted_ratexp_t
typename context_of< ValueSet >::type context_of_t
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
lifted_context_t< context< LabelSet, WeightSet > > lift_context(const context< LabelSet, WeightSet > &ctx)