17 #ifndef AWALI_ALGOS_COPY_HH
18 # define AWALI_ALGOS_COPY_HH
20 # include <unordered_map>
28 namespace awali {
namespace sttc {
39 template <
typename AutIn,
typename AutOut,
typename InOutMap=std::unordered_map<state_t, state_t>>
47 template <
typename Pred>
54 for (
auto s:
in_->states())
58 for (
auto t :
in_->all_transitions())
63 out_->new_transition_copy(src->second, dst->second,
68 template <
typename Pred>
75 for (
auto s:
in_->states())
79 for (
auto t :
in_->all_transitions())
84 out_->new_transition(src->second, dst->second,
96 res[p.second] = p.first;
106 <<
" node [shape = box, style = rounded]\n";
109 o <<
" " << p.first - 2
110 <<
" [label = \"" << p.second - 2 <<
"\"]\n";
116 auto history = std::make_shared<single_history<AutIn>>(
in_);
117 out_->set_history(history);
118 for (
auto p:
in_->all_states()) {
120 if(
in_->has_name(p)) {
141 template <
typename AutIn,
typename AutOut,
typename Pred>
144 copy_into(
const AutIn& in, AutOut& out, Pred keep_state,
bool keep_history=
true,
bool transpose=
false)
152 template <
typename AutIn,
typename AutOut>
160 template <
typename AutIn,
typename AutOut,
typename Pred>
163 copy_support(
const AutIn& in, AutOut& out, Pred keep_state,
bool keep_history=
true)
166 copy.no_weight(keep_state);
171 template <
typename AutIn,
typename AutOut>
184 template <
typename AutIn,
185 typename AutOut =
typename AutIn::element_type::automaton_nocv_t,
189 copy(
const AutIn& input, Pred keep_state,
bool keep_history=
true,
bool transpose=
false)
196 res->set_name(input->get_name());
197 res->set_desc(input->get_desc());
202 template <
typename AutIn,
203 typename AutOut =
typename AutIn::element_type::automaton_nocv_t>
208 return sttc::copy<AutIn, AutOut>(input,
214 template <
typename AutIn,
215 typename AutOut =
typename AutIn::element_type::automaton_nocv_t>
218 copy(
const AutIn& input,
const std::set<state_t>& keep,
bool keep_history=
true,
bool transpose=
false)
220 return sttc::copy<AutIn, AutOut>
222 [&keep](
state_t s) {
return keep.find(s)!=keep.end(); }, keep_history,
transpose);
void copy_support(const AutIn &in, AutOut &out, Pred keep_state, bool keep_history=true)
Definition: copy.hh:163
void copy_into(const AutIn &in, AutOut &out, Pred keep_state, bool keep_history=true, bool transpose=false)
Copy an automaton.
Definition: copy.hh:144
AutOut transpose(Aut &aut, bool keep_history=true)
Definition: transpose.hh:79
AutOut copy(const AutIn &input, Pred keep_state, bool keep_history=true, bool transpose=false)
A copy of input keeping only its states that are accepted by keep_state.
Definition: copy.hh:189
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)
Definition: mutable_automaton.hh:915
Main namespace of Awali.
Definition: ato.hh:22
unsigned state_t
Definition: types.hh:21
Copy an automaton.
Definition: copy.hh:41
const AutIn & in_
Input automaton.
Definition: copy.hh:131
static std::ostream & print(const origins_t &orig, std::ostream &o)
Print the origins.
Definition: copy.hh:103
origins_t origins() const
Definition: copy.hh:92
const InOutMap & in_out_map() const
Definition: copy.hh:126
InOutMap out_state
input state -> output state.
Definition: copy.hh:135
void no_weight(Pred keep_state)
Definition: copy.hh:69
copier(const AutIn &in, AutOut &out)
Definition: copy.hh:42
void operator()(Pred keep_state, bool transpose=false)
Definition: copy.hh:48
std::map< state_t, state_t > origins_t
A map from result state to original state.
Definition: copy.hh:90
AutOut & out_
Output automaton.
Definition: copy.hh:133
void set_history()
Definition: copy.hh:115