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())
137 template <
typename AutIn,
typename AutOut,
typename Pred>
140 copy_into(
const AutIn& in, AutOut& out, Pred keep_state,
bool keep_history=
true,
bool transpose=
false)
148 template <
typename AutIn,
typename AutOut>
156 template <
typename AutIn,
typename AutOut,
typename Pred>
159 copy_support(
const AutIn& in, AutOut& out, Pred keep_state,
bool keep_history=
true)
162 copy.no_weight(keep_state);
167 template <
typename AutIn,
typename AutOut>
180 template <
typename AutIn,
181 typename AutOut =
typename AutIn::element_type::automaton_nocv_t,
185 copy(
const AutIn& input, Pred keep_state,
bool keep_history=
true,
bool transpose=
false)
192 res->set_name(input->get_name());
193 res->set_desc(input->get_desc());
198 template <
typename AutIn,
199 typename AutOut =
typename AutIn::element_type::automaton_nocv_t>
204 return sttc::copy<AutIn, AutOut>(input,
210 template <
typename AutIn,
211 typename AutOut =
typename AutIn::element_type::automaton_nocv_t>
214 copy(
const AutIn& input,
const std::set<state_t>& keep,
bool keep_history=
true,
bool transpose=
false)
216 return sttc::copy<AutIn, AutOut>
218 [&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:159
void copy_into(const AutIn &in, AutOut &out, Pred keep_state, bool keep_history=true, bool transpose=false)
Copy an automaton.
Definition: copy.hh:140
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:185
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)
Definition: mutable_automaton.hh:911
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:127
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:122
InOutMap out_state
input state -> output state.
Definition: copy.hh:131
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:129
void set_history()
Definition: copy.hh:115