Vcsn  2.3
Be Rational
expand.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/algos/copy.hh>
5 #include <vcsn/dyn/value.hh>
6 
7 namespace vcsn
8 {
11  template <typename ExpSet>
12  typename ExpSet::value_t
13  expand(const ExpSet& rs, const typename ExpSet::value_t& r)
14  {
15  // FIXME: this does not work, but it should.
16  // return ::vcsn::rat::copy(rs,
17  // make_expressionset(rs, "distributive"),
18  // r);
19  return conv(make_expressionset(rs, "distributive"),
20  to_string(rs, r));
21  }
22 
23  namespace dyn
24  {
25  namespace detail
26  {
28  template <typename ExpSet>
30  expand(const expression& exp)
31  {
32  const auto& e = exp->as<ExpSet>();
33  return {e.valueset(), ::vcsn::expand(e.valueset(), e.value())};
34  }
35  }
36  }
37 }
ExpSet::value_t expand(const ExpSet &rs, const typename ExpSet::value_t &r)
Expand a typed expression, i.e., distribute multiplications over sums.
Definition: expand.hh:13
auto conv(const ValueSet &vs, const std::string &str, Args &&...args) -> decltype(vs.conv(std::declval< std::istream & >(), std::forward< Args >(args)...))
Parse str via vs.conv.
Definition: stream.hh:29
auto rs
Definition: lift.hh:152
Definition: a-star.hh:8
std::string to_string(direction d)
Conversion to string.
Definition: direction.cc:7
expression expand(const expression &exp)
Bridge.
Definition: expand.hh:30
auto make_expressionset(const context< LabelSet, WeightSet > &ctx, rat::identities ids={}) -> expressionset< context< LabelSet, WeightSet >>
Shorthand to expressionset constructor.
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
value_impl< detail::expression_tag > expression
Definition: fwd.hh:25