29 template <
typename Context, direction Dir>
71 for (
const auto& m: p)
76 template <direction D = Dir>
84 template <direction D = Dir>
99 const auto& ls = *
ctx_.labelset();
101 s =
next_(s, ls.special());
108 res_->add_transition(s,
res_->post(), ls.special(), wgt);
115 auto ts =
res_->out(s, l);
116 assert(ts.size() == 0 || ts.size() == 1);
119 auto d =
res_->new_state();
120 res_->new_transition(s, d, l);
137 template <direction Dir,
typename PolynomialSet>
152 template <
typename PolynomialSet>
153 mutable_automaton<detail::free_context<context_t_of<PolynomialSet>>>
154 trie(
const PolynomialSet& ps,
const typename PolynomialSet::value_t& p)
156 auto t = detail::make_trie_builder<direction::forward>(ps);
166 template <
typename PolynomialSet>
167 mutable_automaton<detail::free_context<context_t_of<PolynomialSet>>>
168 cotrie(
const PolynomialSet& ps,
const typename PolynomialSet::value_t& p)
170 auto t = detail::make_trie_builder<direction::backward>(ps);
180 template <
typename PolynomialSet>
184 const auto& p = poly->as<PolynomialSet>();
189 template <
typename PolynomialSet>
193 const auto& p = poly->as<PolynomialSet>();
208 template <
typename PolynomialSet>
209 mutable_automaton<detail::free_context<context_t_of<PolynomialSet>>>
210 trie(
const PolynomialSet& ps, std::istream&
is)
212 auto t = detail::make_trie_builder<direction::forward>(ps);
213 while (
auto m = ps.conv_monomial(is))
223 template <
typename PolynomialSet>
224 mutable_automaton<detail::free_context<context_t_of<PolynomialSet>>>
227 auto t = detail::make_trie_builder<direction::backward>(ps);
228 while (
auto m = ps.conv_monomial(is))
238 template <
typename Context,
typename Istream>
242 const auto& c = ctx->as<Context>();
248 template <
typename Context,
typename Istream>
252 const auto& c = ctx->as<Context>();
automaton trie(const polynomial &poly)
Bridge.
work_automaton_t res_
The automaton being built.
Container::value_type front(const Container &container)
The first member of this Container.
Build a trie automaton (prefix-tree-like automaton).
state_t_of< automaton_t > state_t
std::shared_ptr< const detail::context_base > context
A dyn::context.
auto label_of(const welement< Label, Weight > &m) -> decltype(m.label())
weight_t_of< context_t > weight_t
void add(const word_t &l, const weight_t &w)
Add a monomial.
std::istringstream is
The input stream: the specification to translate.
typename polynomialset_t::value_t polynomial_t
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
auto result() -> enable_if_t< D==direction::forward, automaton_t >
Get the result for the forward trie.
typename std::enable_if< Cond, T >::type enable_if_t
void add(const monomial_t &m)
Add a monomial.
typename polynomialset_t::monomial_t monomial_t
typename labelset_t_of< base_t< ValueSet >>::letter_t letter_t_of
auto result() -> enable_if_t< D==direction::backward, automaton_t >
Get the result for a backward trie.
SharedPtr make_shared_ptr(Args &&...args)
Same as std::make_shared, but parameterized by the shared_ptr type, not the (pointed to) element_type...
Aut transpose(const transpose_automaton< Aut > &aut)
automaton cotrie(const polynomial &poly)
Bridge.
automaton cotrie_stream(const context &ctx, std::istream &is)
Bridge (cotrie).
typename labelset_t_of< base_t< ValueSet >>::word_t word_t_of
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
static dyn::context ctx(const driver &d)
Get the context of the driver.
letter_t_of< context_t > letter_t
automaton trie_stream(const context &ctx, std::istream &is)
Bridge (trie).
Provide a variadic mul on top of a binary mul(), and one().
std::shared_ptr< detail::transpose_automaton_impl< Aut >> transpose_automaton
An automaton wrapper that presents the transposed automaton.
auto make_word_polynomialset(const Ctx &ctx) -> word_polynomialset_t< Ctx >
The polynomialset of words of a labelset (not necessarily on words itself).
trie_builder(const context_t &c)
std::shared_ptr< detail::automaton_base > automaton
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
auto weight_of(const welement< Label, Weight > &m) -> decltype(m.weight())
mutable_automaton< detail::free_context< context_t_of< PolynomialSet > > > trie(const PolynomialSet &ps, const typename PolynomialSet::value_t &p)
Make a trie-like mutable_automaton for a finite series given as a polynomial.
free_context< context< LabelSet, WeightSet > > make_free_context(const context< LabelSet, WeightSet > &c)
The free context for c.
std::shared_ptr< const detail::polynomial_base > polynomial
conditional_t< Dir==direction::forward, automaton_t, transpose_automaton< automaton_t >> work_automaton_t
The type of the automaton we work on.
labelset_t_of< context_t > labelset_t
state_t next_(state_t s, letter_t l)
Follow a transition, possibly creating it.
word_t_of< context_t > word_t
mutable_automaton< detail::free_context< context_t_of< PolynomialSet > > > cotrie(const PolynomialSet &ps, const typename PolynomialSet::value_t &p)
Make a cotrie-like mutable_automaton for a finite series given as a polynomial.
trie_builder< free_context< context_t_of< PolynomialSet > >, Dir > make_trie_builder(const PolynomialSet &ps)
Instantiate a trie-builder for this type of polynomialset.
const context_t & ctx_
The context of the automaton: letterized.
void add_(const word_t &lbl, const weight_t &wgt)
Add a monomial.
letterized_t< labelset_t >::value_t padding_
Padding, in case it is needed.
constant< type_t::one, Context > one
typename letterized_traits< LabelSet >::labelset_t letterized_t
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
mutable_automaton< context_t > automaton_t
The type of the result.
typename std::conditional< B, T, U >::type conditional_t
void add(const polynomial_t &p)
Add a polynomial.
typename detail::weight_t_of_impl< base_t< ValueSet >>::type weight_t_of