4 #include <vcsn/algos/fwd.hh> 22 template <Automaton Aut>
23 class transpose_automaton_impl
24 :
public automaton_decorator<Aut>
35 template <Automaton Fresh>
42 template <Automaton Fresh>
51 template <
typename Ctx = context_t>
62 using kind_t =
typename automaton_t::element_type::kind_t;
64 using super_t::super_t;
69 static auto res =
symbol{
"transpose_automaton<" 76 o <<
"transpose_automaton<";
77 aut_->print_set(o, fmt);
92 -> decltype(transpose(vcsn::strip(this->naked_automaton()))) 94 return transpose(vcsn::strip(this->naked_automaton())); 99 auto automaton() const 101 return copy<const transpose_automaton_impl*, automaton_t>(this); 104 /*-------------------------------. 105 | const methods that transpose. | 106 `-------------------------------*/ 107 #define DEFINE(Signature, Value) \ 110 -> decltype(aut_->Value) \ 112 return aut_->Value; \ 115 DEFINE(all_in(state_t s), all_out(s)); 116 DEFINE(all_out(state_t s), all_in(s)); 117 DEFINE(dst_of(transition_t t), src_of(t)); 118 DEFINE(is_final(state_t s), is_initial(s)); 119 DEFINE(num_finals(), num_initials()); 120 DEFINE(num_initials(), num_finals()); 121 DEFINE(src_of(transition_t t), dst_of(t)); 122 DEFINE(is_initial(state_t s), is_final(s)); 124 DEFINE(is_lazy(state_t s), is_lazy_in(s)); 125 DEFINE(is_lazy_in(state_t s), is_lazy(s)); 127 DEFINE(get_transition(state_t s, state_t d, label_t l), 128 get_transition(d, s, aut_->labelset()->transpose(l))); 129 DEFINE(has_transition(transition_t t), 131 DEFINE(has_transition(state_t s, state_t d, label_t l), 132 has_transition(d, s, aut_->labelset()->transpose(l))); 133 DEFINE(label_of(transition_t t), 134 labelset()->transpose(aut_->label_of(t))); 137 DEFINE(get_initial_weight(state_t s), 138 weightset()->transpose(aut_->get_final_weight(s))); 141 DEFINE(get_final_weight(state_t s), 142 weightset()->transpose(aut_->get_initial_weight(s))); 145 DEFINE(weight_of(transition_t t), 146 weightset()->transpose(aut_->weight_of(t))); 151 /*-----------------------------------. 152 | non-const methods that transpose. | 153 `-----------------------------------*/ 155 #define DEFINE(Signature, Value) \ 158 -> decltype(aut_->Value) \ 160 return aut_->Value; \ 163 DEFINE(set_lazy(state_t s, bool l = true), set_lazy_in(s, l)); 164 DEFINE(set_lazy_in(state_t s, bool l = true), set_lazy(s, l)); 166 DEFINE(set_initial(state_t s), set_final(s)); 167 DEFINE(set_final(state_t s), set_initial(s)); 168 DEFINE(unset_initial(state_t s), unset_final(s)); 169 DEFINE(unset_final(state_t s), unset_initial(s)); 171 DEFINE(set_weight(transition_t t, weight_t k), 172 set_weight(t, aut_->weightset()->transpose(k))); 173 DEFINE(add_weight(transition_t t, weight_t k), 174 add_weight(t, aut_->weightset()->transpose(k))); 175 DEFINE(lweight(transition_t t, weight_t k), 176 lweight(t, aut_->weightset()->transpose(k))); 177 DEFINE(rweight(transition_t t, weight_t k), 178 rweight(t, aut_->weightset()->transpose(k))); 180 DEFINE(del_transition(transition_t t), del_transition(t)); 181 DEFINE(del_transition(state_t s, state_t d, label_t l), 182 del_transition(d, s, aut_->labelset()->transpose(l))); 184 DEFINE(add_transition(state_t s, state_t d, label_t l, weight_t k), 186 aut_->labelset()->transpose(l), 187 aut_->weightset()->transpose(k))); 188 DEFINE(add_transition(state_t s, state_t d, label_t l), 189 add_transition(d, s, aut_->labelset()->transpose(l))); 191 DEFINE(new_transition(state_t s, state_t d, label_t l, weight_t k), 193 aut_->labelset()->transpose(l), 194 aut_->weightset()->transpose(k))); 195 DEFINE(new_transition(state_t s, state_t d, label_t l), 197 aut_->labelset()->transpose(l))); 199 DEFINE(set_transition(state_t s, state_t d, label_t l, weight_t k), 201 aut_->labelset()->transpose(l), 202 aut_->weightset()->transpose(k))); 203 DEFINE(set_initial(state_t s, weight_t k), 204 set_final(s, aut_->weightset()->transpose(k))); 205 DEFINE(set_final(state_t s, weight_t k), 206 set_initial(s, aut_->weightset()->transpose(k))); 207 DEFINE(add_initial(state_t s, weight_t k), 208 add_final(s, aut_->weightset()->transpose(k))); 209 DEFINE(add_final(state_t s, weight_t k), 210 add_initial(s, aut_->weightset()->transpose(k))); 212 template <Automaton A> 213 DEFINE(add_transition_copy(state_t src, state_t dst, 215 transition_t_of<A> t, 216 bool transpose = false), 217 add_transition_copy(dst, src, aut, t, !transpose)); 219 template <Automaton A> 220 DEFINE(new_transition_copy(state_t src, state_t dst, 222 transition_t_of<A> t, 223 bool transpose = false), 224 new_transition_copy(dst, src, aut, t, !transpose)); 230 /*-----------------------------------. 231 | constexpr methods that transpose. | 232 `-----------------------------------*/ 234 #define DEFINE(Signature, Value) \ 238 -> decltype(automaton_t::element_type::Value) \ 240 return automaton_t::element_type::Value; \ 243 DEFINE(post(), pre()); 244 DEFINE(pre(), post()); 251 template <Automaton Aut> 253 transpose(const transpose_automaton<Aut>& aut) 255 return aut->naked_automaton(); 259 template <Automaton Aut> 260 transpose_automaton<Aut> 263 return make_shared_ptr<transpose_automaton<Aut>>(aut); 271 template <Automaton Aut> 273 transpose(automaton& aut) 275 auto& a = aut->as<Aut>(); 276 return vcsn::transpose(a); 282 /*------------------------------. 283 | dyn::transpose(expression). | 284 `------------------------------*/ 290 template <typename ExpSet> 292 transpose_expression(const expression& exp) 294 const auto& e = exp->as<ExpSet>(); 295 return {e.valueset(), ::vcsn::transpose(e.valueset(), e.value())}; 300 /*----------------------------------. 301 | dyn::transposition(expression). | 302 `----------------------------------*/ 308 template <typename ExpSet> 310 transposition_expression(const expression& exp) 312 const auto& e = exp->as<ExpSet>(); 313 return {e.valueset(), e.valueset().transposition(e.value())}; typename automaton_t::element_type::kind_t kind_t
typename detail::weightset_t_of_impl< base_t< ValueSet > >::type weightset_t_of
typename detail::transition_t_of_impl< base_t< ValueSet > >::type transition_t_of
typename detail::state_t_of_impl< base_t< ValueSet > >::type state_t_of
transpose_automaton< automaton_t > self_t
labelset_t_of< automaton_t > labelset_t
boost::flyweight< std::string, boost::flyweights::no_tracking, boost::flyweights::intermodule_holder > symbol
An internalized string.
automaton_t aut_
The wrapped automaton, possibly const.
transition_t_of< automaton_t > transition_t
typename detail::context_t_of_impl< base_t< ValueSet > >::type context_t_of
An input/output format for valuesets.
typename detail::labelset_t_of_impl< base_t< ValueSet > >::type labelset_t_of
std::ostream & print_set(std::ostream &o, format fmt={}) const
weightset_t_of< automaton_t > weightset_t
typename detail::label_t_of_impl< base_t< ValueSet > >::type label_t_of
Aut automaton_t
The type of automaton to wrap.
typename fresh_impl_< fresh_automaton_t_of< automaton_t, Ctx > >::type fresh_automaton_t
The type to use to build an automaton of the same type: remove the inner const-volatile qualifiers...
std::shared_ptr< detail::transpose_automaton_impl< Aut > > transpose_automaton
An automaton wrapper that presents the transposed automaton.
transpose_automaton< Fresh > type
label_t_of< automaton_t > label_t
Aggregate an automaton, and forward calls to it.
context_t_of< automaton_t > context_t
weight_t_of< automaton_t > weight_t
typename detail::weight_t_of_impl< base_t< ValueSet > >::type weight_t_of
The transpose of a fresh non-transposed automaton.
state_t_of< automaton_t > state_t