Vcsn  2.3
Be Rational
tuple.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/core/rat/fwd.hh>
4 #include <vcsn/dyn/value.hh>
6 
7 namespace vcsn
8 {
9  /*-----------------------------.
10  | tuple_context(context...). |
11  `-----------------------------*/
12 
13  template <typename... Ctx>
14  auto
15  tuple_context(Ctx&&... ctx)
18  {
19  auto ls = make_tupleset(*ctx.labelset()...);
20  auto ws = join(*ctx.weightset()...);
21  return {ls, ws};
22  }
23 
24 
25  /*---------------------------------------.
26  | tuple_expansionset(expansionset...). |
27  `---------------------------------------*/
28 
29  template <typename... ExpansionSets>
30  auto
31  tuple_expansionset(const ExpansionSets&... ess)
32  -> rat::expansionset<decltype(tuple_expressionset(ess.expressionset()...))>
33  {
34  return {tuple_expressionset(ess.expressionset()...)};
35  }
36 
37  /*------------------------.
38  | tuple(expression...). |
39  `------------------------*/
40 
41  template <typename ValueSet, typename... ValueSets>
42  typename ValueSet::value_t
43  tuple(const ValueSet& vs,
44  const typename ValueSets::value_t&... v)
45  {
46  return vs.tuple(v...);
47  }
48 
49  /*-----------------------------------------.
50  | tuple_expressionset(expressionset...). |
51  `-----------------------------------------*/
52 
53  template <typename... ExpSets>
54  auto
55  tuple_expressionset(const ExpSets&... rss)
56  -> expressionset<decltype(tuple_context(rss.context()...))>
57  {
58  auto ctx = tuple_context(rss.context()...);
59  auto ids = join(rss.identities()...);
60  return {ctx, ids};
61  }
62 
63  /*-----------------------.
64  | tuple(expansion...). |
65  `-----------------------*/
66 
67  namespace dyn
68  {
69  namespace detail
70  {
72  template <typename ExpansionSets, size_t... I>
73  expansion
74  tuple_(const std::vector<expansion>& es,
76  {
77  auto xs
79  (es[I]
80  ->template as<tuple_element_t<I, ExpansionSets>>()
81  .valueset()...);
82  return
83  {xs,
84  vcsn::tuple<decltype(xs), tuple_element_t<I, ExpansionSets>...>
85  (xs,
86  es[I]->template as<tuple_element_t<I, ExpansionSets>>()
87  .value()...)};
88  }
89 
91  template <typename ExpansionSets>
92  expansion
93  tuple_expansion(const std::vector<expansion>& es)
94  {
95  auto indices
97  return tuple_<ExpansionSets>(es, indices);
98  }
99  }
100  }
101 
102  /*------------------------.
103  | tuple(expression...). |
104  `------------------------*/
105 
106  namespace dyn
107  {
108  namespace detail
109  {
111  template <typename ExpSets, size_t... I>
112  expression
113  tuple_(const std::vector<expression>& es,
115  {
116  auto rs
118  (es[I]->template as<tuple_element_t<I, ExpSets>>().valueset()...);
119  return
120  {rs,
121  vcsn::tuple<decltype(rs), tuple_element_t<I, ExpSets>...>
122  (rs,
123  es[I]
124  ->template as<tuple_element_t<I, ExpSets>>().value()...)};
125  }
126 
128  template <typename ExpSets>
129  expression
130  tuple_expression(const std::vector<expression>& es)
131  {
132  auto indices
134  return tuple_<ExpSets>(es, indices);
135  }
136  }
137  }
138 
139 
140  /*-----------------------------------------.
141  | tuple_polynomialset(polynomialset...). |
142  `-----------------------------------------*/
143 
144  template <typename... PolynomialSets>
145  auto
146  tuple_polynomialset(const PolynomialSets&... pss)
147  -> polynomialset<decltype(tuple_context(pss.context()...))>
148  {
149  auto ctx = tuple_context(pss.context()...);
150  return {ctx};
151  }
152 
153 
154  /*------------------------.
155  | tuple(polynomial...). |
156  `------------------------*/
157 
158  namespace dyn
159  {
160  namespace detail
161  {
163  template <typename PolynomialSet, size_t... I>
164  polynomial
165  tuple_(const std::vector<polynomial>& polys,
167  {
168  auto ps
170  (polys[I]->template as<tuple_element_t<I, PolynomialSet>>().valueset()...);
171  return
172  {ps,
173  vcsn::tuple<decltype(ps), tuple_element_t<I, PolynomialSet>...>
174  (ps,
175  polys[I]
176  ->template as<tuple_element_t<I, PolynomialSet>>().value()...)};
177  }
178 
180  template <typename PolynomialSets>
181  polynomial
182  tuple_polynomial(const std::vector<polynomial>& ps)
183  {
184  auto indices
186  return tuple_<PolynomialSets>(ps, indices);
187  }
188  }
189  }
190 }
return v
Definition: multiply.hh:361
tupleset< ValueSets... > make_tupleset(const ValueSets &...vss)
Definition: tupleset.hh:1073
typename std::tuple_element< I, T >::type tuple_element_t
C++14.
Definition: tuple.hh:14
expression tuple_expression(const std::vector< expression > &es)
Bridge (tuple).
Definition: tuple.hh:130
auto join(const ValueSet &vs) -> ValueSet
The join of a single valueset.
Definition: join.hh:44
decltype(join(std::declval< ValueSets >()...)) join_t
The type of the join of the ValueSets.
Definition: join.hh:78
A dyn Value/ValueSet.
Definition: fwd.hh:23
polynomial tuple_polynomial(const std::vector< polynomial > &ps)
Bridge (tuple).
Definition: tuple.hh:182
ValueSet::value_t tuple(const ValueSet &vs, const typename ValueSets::value_t &...v)
Definition: tuple.hh:43
expansion tuple_expansion(const std::vector< expansion > &es)
Bridge (tuple).
Definition: tuple.hh:93
auto tuple_polynomialset(const PolynomialSets &...pss) -> polynomialset< decltype(tuple_context(pss.context()...))>
Definition: tuple.hh:146
auto rs
Definition: lift.hh:152
auto tuple_expansionset(const ExpansionSets &...ess) -> rat::expansionset< decltype(tuple_expressionset(ess.expressionset()...))>
Definition: tuple.hh:31
Definition: a-star.hh:8
value_impl< detail::polynomial_tag > polynomial
Definition: fwd.hh:27
auto tuple_expressionset(const ExpSets &...rss) -> expressionset< decltype(tuple_context(rss.context()...))>
Definition: tuple.hh:55
value_impl< detail::expansion_tag > expansion
Definition: fwd.hh:24
automaton tuple_(const std::vector< automaton > &as, vcsn::detail::index_sequence< I... >)
Bridge helper.
static identities ids(const driver &d)
Get the identities of the driver.
Definition: parse.cc:89
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
auto tuple_context(Ctx &&...ctx) -> context< tupleset< labelset_t_of< Ctx >... >, join_t< weightset_t_of< Ctx >... >>
Definition: tuple.hh:15
value_impl< detail::expression_tag > expression
Definition: fwd.hh:25