1 #ifndef VCSN_ALGOS_GRAIL_HH
2 # define VCSN_ALGOS_GRAIL_HH
26 template <
typename Aut>
75 const std::string& fmt =
"text")
78 return ps_.
print(entry, os, fmt,
", ");
84 std::vector<transition_t> ts;
85 for (
auto t :
aut_->out(s))
92 (std::forward_as_tuple(
aut_->label_of(l),
aut_->dst_of(l))
93 < std::forward_as_tuple(
aut_->label_of(r),
aut_->dst_of(r)));
106 for (
auto s:
aut_->states())
124 for (
auto t:
aut_->initial_transitions())
125 res.emplace_back(
aut_->dst_of(t));
134 for (
auto t:
aut_->final_transitions())
135 res.emplace_back(
aut_->src_of(t));
165 template <
typename Aut>
169 "fado: requires letter or nullable labels");
171 "fado: requires Boolean weights");
183 using super_t::super_t;
191 os_ << (is_deter ?
"@DFA" :
"@NFA");
202 template <
typename A>
203 typename std::enable_if<labelset_t_of<A>::is_free(),
210 template <
typename A>
211 typename std::enable_if<!labelset_t_of<A>::is_free(),
221 template <
typename Aut>
223 fado(
const Aut& aut, std::ostream& out)
240 template <
typename Aut,
typename Ostream>
243 return fado(aut->as<Aut>(), out);
247 (
const automaton& aut, std::ostream& out)
265 template <
typename Aut>
269 "grail: requires letter or nullable labels");
271 "grail:requires Boolean weights");
286 using super_t::super_t;
293 const char* sep =
"";
305 aut_->print_state(s,
os_) <<
" -| (FINAL)";
311 template <
typename Aut>
313 grail(
const Aut& aut, std::ostream& out)
325 template <
typename Aut,
typename Ostream>
328 return grail(aut->as<Aut>(), out);
332 (
const automaton& aut, std::ostream& out)
338 #endif // !VCSN_ALGOS_GRAIL_HH
Linear combination of labels: map labels to weights.
bool is_deterministic(const Aut &aut, state_t_of< Aut > s)
Whether state s is deterministic in aut.
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
std::ostream & print_entry_(state_t src, state_t dst, std::ostream &os, const std::string &fmt="text")
The labels and weights of transitions from src to dst.
const weightset_t & ws_
Short-hand to the weightset.
virtual void output_transition_(transition_t t)
Output the transition t.
outputter(const automaton_t &aut, std::ostream &out)
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
const labelset_t_of< automaton_t > & ls_
Short-hand to the labelset.
states_t initials_()
The list of initial states, sorted.
void output_state_(const state_t s)
Output transitions, sorted lexicographically on (Label, Dest).
weight_t_of< automaton_t > weight_t
std::enable_if<!labelset_t_of< A >::is_free(), bool >::type is_deterministic_(const A &)
std::ostream & os_
Output stream.
typename detail::context_t_of_impl< base_t< ValueSet >>::type context_t_of
transition_t_of< automaton_t > transition_t
auto sort(const Aut &a) -> permutation_automaton< Aut >
std::ostream & grail(const automaton &aut, std::ostream &out)
Bridge.
void operator()()
Actually output aut_ on os_.
Factor common bits in automaton formatting.
std::ostream & grail(const Aut &aut, std::ostream &out)
typename detail::label_t_of_impl< base_t< ValueSet >>::type label_t_of
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
Format an automaton into Fado.
std::ostream & fado(const automaton &aut, std::ostream &out)
Bridge.
std::ostream & print(const monomial_t &m, std::ostream &out, symbol format=symbol{"text"}) const
Print a monomial.
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
context_t_of< automaton_t > context_t
weightset_t_of< automaton_t > weightset_t
const polynomialset< context_t_of< automaton_t > > ps_
Short-hand to the polynomialset used to print the entries.
Provide a variadic mul on top of a binary mul(), and one().
polynomialset< context_t_of< Aut > >::value_t get_entry(const Aut &aut, state_t_of< Aut > s, state_t_of< Aut > d)
The entry between two states of an automaton.
label_t_of< automaton_t > label_t
std::ostringstream os
The output stream: the corresponding C++ snippet to compile.
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of
states_t finals_()
The list of final states, sorted.
void list_states_(const states_t &ss)
List names of states in ss, preceded by ' '.
Format an automaton into Fado.
void output_transitions_()
Output transitions, sorted lexicographically.
const automaton_t & aut_
The automaton we have to output.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
state_t_of< automaton_t > state_t
std::ostream & fado(const Aut &aut, std::ostream &out)
std::enable_if< labelset_t_of< A >::is_free(), bool >::type is_deterministic_(const A &a)
std::vector< state_t > states_t
A list of states.
virtual std::string label_(const label_t &l)
Convert a label to its representation.
void operator()()
Actually output aut_ on os_.
std::string to_string(direction d)
Conversion to string.