1 #ifndef VCSN_ALGOS_COPY_HH
2 # define VCSN_ALGOS_COPY_HH
4 # include <unordered_map>
6 # include <vcsn/algos/fwd.hh>
29 template <
typename AutIn,
typename AutOut>
40 template <
typename Pred>
47 for (
auto s:
in_->states())
51 for (
auto t :
in_->all_transitions())
56 out_->new_transition_copy(src->second, dst->second,
62 using origins_t = std::map<out_state_t, in_state_t>;
68 res[p.second] = p.first;
78 <<
" node [shape = box, style = rounded]\n";
81 o <<
" " << p.first - 2
82 <<
" [label = \"" << p.second - 2 <<
"\"]\n";
92 std::unordered_map<in_state_t, out_state_t>
out_state;
98 template <
typename AutIn,
typename AutOut,
typename Pred>
101 copy_into(
const AutIn& in, AutOut& out, Pred keep_state)
104 return copy(keep_state);
107 template <
typename AutIn,
typename AutOut>
117 template <
typename Aut>
120 template <
typename Aut>
125 template <
typename Aut>
129 -> decltype(aut->context())
131 return aut->context();
135 template <std::
size_t Tape,
typename Aut>
139 -> decltype(aut->full_context())
141 return aut->full_context();
145 template <
typename Aut>
155 template <
typename Aut>
166 template <
typename AutIn,
167 typename AutOut =
typename AutIn::element_type::automaton_nocv_t,
171 copy(
const AutIn& input, Pred keep_state)
182 template <
typename AutIn,
183 typename AutOut =
typename AutIn::element_type::automaton_nocv_t>
188 return ::vcsn::copy<AutIn, AutOut>(input,
194 template <
typename AutIn,
195 typename AutOut =
typename AutIn::element_type::automaton_nocv_t>
200 return ::vcsn::copy<AutIn, AutOut>
207 template <
typename AutIn,
208 typename AutOut =
typename AutIn::element_type::automaton_nocv_t>
213 return ::vcsn::copy<AutIn, AutOut>
223 template <
typename Aut,
typename Ctx>
228 const auto& a = aut->as<Aut>();
229 const auto& c = ctx->as<Ctx>();
239 template <
typename Aut>
244 const auto& a = aut->as<Aut>();
262 template <
typename InRatExpSet,
typename OutRatExpSet = InRatExpSet>
267 const auto&
r = exp->as<InRatExpSet>();
268 const auto& ors = out_rs->as<OutRatExpSet>().
ratexpset();
284 #endif // !VCSN_ALGOS_COPY_HH
ratexp make_ratexp(const RatExpSet &rs, const typename RatExpSet::value_t &ratexp)
automaton copy_convert(const automaton &aut, const context &ctx)
Bridge.
state_t_of< AutIn > in_state_t
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
static auto context(const blind_automaton< Tape, Aut > &aut) -> decltype(aut->full_context())
OutRatExpSet::value_t copy(const InRatExpSet &in_rs, const OutRatExpSet &out_rs, const typename InRatExpSet::value_t &v)
AutOut & out_
Output automaton.
static std::ostream & print(const origins_t &orig, std::ostream &o)
Print the origins.
const AutIn & in_
Input automaton.
ratexp copy_ratexp(const ratexp &exp, const ratexpset &out_rs)
Bridge.
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
copier(const AutIn &in, AutOut &out)
std::shared_ptr< detail::blind_automaton_impl< Tape, Aut >> blind_automaton
A blind automaton as a shared pointer.
std::shared_ptr< detail::ratexp_base > ratexp
std::shared_ptr< detail::permutation_automaton_impl< Aut >> permutation_automaton
A permutation automaton as a shared pointer.
static auto context(const Aut &aut) -> decltype(aut->context())
AutOut copy(const AutIn &input, Pred keep_state)
A copy of input keeping only its states that are accepted by keep_state.
std::shared_ptr< const detail::ratexpset_base > ratexpset
void operator()(Pred keep_state)
automaton copy(const automaton &aut)
Bridge.
void copy_into(const AutIn &in, AutOut &out)
Provide a variadic mul on top of a binary mul(), and one().
std::shared_ptr< const detail::context_base > context
auto real_context(const Aut &aut) -> decltype(real_context_impl< Aut >::context(aut))
std::map< out_state_t, in_state_t > origins_t
A map from result state to original state.
static auto context(const permutation_automaton< Aut > &aut) -> decltype(real_context(aut->strip()))
state_t_of< AutOut > out_state_t
std::unordered_map< in_state_t, out_state_t > out_state
input state -> output state.
void copy_into(const AutIn &in, AutOut &out, Pred keep_state)
Copy an automaton.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
origins_t origins() const