Vcsn  2.3a
Be Rational
project.hh
Go to the documentation of this file.
1 #pragma once
2 
4 #include <vcsn/dyn/context.hh>
5 #include <vcsn/dyn/value.hh>
7 #include <vcsn/dyn/name.hh> // integral_constant
8 #include <vcsn/dyn/value.hh>
9 
10 namespace vcsn
11 {
12  /*--------------------.
13  | project(context). |
14  `--------------------*/
15 
16  namespace dyn
17  {
18  namespace detail
19  {
21  template <typename Context, typename Tape>
22  context
24  {
25  auto& c = ctx->as<Context>();
26  return vcsn::detail::project<Tape::value>(c);
27  }
28  }
29  }
30 
31 
32  /*--------------------------.
33  | project(expressionset). |
34  `--------------------------*/
35 
36  namespace detail
37  {
39  template <size_t Tape, typename Context>
41  {
42  // Weirdly enough, GCC enters an endless loop of instantiation
43  // if we use this type as explicit function return type.
44  return make_expressionset(project<Tape>(rs.context()),
45  rs.identities());
46  }
47  }
48 
49  /*----------------------.
50  | project(expansion). |
51  `----------------------*/
52 
53  namespace detail
54  {
58  template <size_t Tape, typename ValueSet>
59  auto project(const ValueSet& vs,
60  const typename ValueSet::value_t& v)
61  {
62  static_assert(Tape < labelset_t_of<ValueSet>::size(),
63  "project: invalid tape number");
64  return vs.template project<Tape>(v);
65  }
66  }
67 
68  namespace dyn
69  {
70  namespace detail
71  {
73  template <typename ExpansionSet, typename Tape>
74  expansion
76  {
77  constexpr auto tape = Tape::value;
78  auto& x = exp->as<ExpansionSet>();
79  const auto& xs_in = x.valueset();
80  auto xs_out = xs_in.template project<tape>();
81  return {xs_out, vcsn::detail::project<tape>(xs_in, x.value())};
82  }
83  }
84  }
85 
86  /*-----------------------.
87  | project(expression). |
88  `-----------------------*/
89 
90  namespace dyn
91  {
92  namespace detail
93  {
95  template <typename ExpressionSet, typename Tape>
98  {
99  constexpr auto tape = Tape::value;
100  auto& r = exp->as<ExpressionSet>();
101  const auto& rs_in = r.valueset();
102  auto rs_out = vcsn::detail::project<tape>(rs_in);
103  return {rs_out, vcsn::detail::project<tape>(rs_in, r.value())};
104  }
105  }
106  }
107 
108  /*-----------------------.
109  | project(polynomial). |
110  `-----------------------*/
111 
112  namespace detail
113  {
115  template <size_t Tape, typename Context, wet_kind_t Kind>
117  {
118  static_assert(Tape < labelset_t_of<Context>::size(),
119  "project: invalid tape number");
120  auto ctx_out = vcsn::detail::project<Tape>(ps.context());
121  return make_polynomialset(ctx_out);
122  }
123  }
124 
125  namespace dyn
126  {
127  namespace detail
128  {
130  template <typename PolynomialSet, typename Tape>
131  polynomial
133  {
134  constexpr auto tape = Tape::value;
135  auto& p = poly->as<PolynomialSet>();
136  const auto& ps_in = p.valueset();
137  auto ps_out = vcsn::detail::project<tape>(ps_in);
138  return {ps_out, vcsn::detail::project<tape>(ps_in, p.value())};
139  }
140  }
141  }
142 
143  /*------------------.
144  | project(label). |
145  `------------------*/
146 
147  namespace dyn
148  {
149  namespace detail
150  {
152  template <typename Label, typename Tape>
153  label
155  {
156  constexpr auto tape = Tape::value;
157  const auto& l = lbl->as<Label>();
158  const auto& ls = l.valueset();
159  return {ls.template set<tape>(), std::get<tape>(l.value())};
160  }
161  }
162  }
163 }
label project_label(const label &lbl, integral_constant)
Bridge (project).
Definition: project.hh:154
context project_context(const context &ctx, integral_constant)
Bridge (project).
Definition: project.hh:23
Definition: a-star.hh:8
value_impl< detail::polynomial_tag > polynomial
Definition: fwd.hh:27
expansion project_expansion(const expansion &exp, integral_constant)
Bridge (project).
Definition: project.hh:75
auto project(const expressionset< Context > &rs)
Project an expressionset to one tape.
Definition: project.hh:40
expression project_expression(const expression &exp, integral_constant)
Bridge (project).
Definition: project.hh:97
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
Definition: traits.hh:63
auto & as()
Downcast to the exact type.
Definition: context.hh:36
Template-less root for contexts.
Definition: context.hh:16
A simple placeholder for integral constants.
Definition: name.hh:196
auto & as()
Extract wrapped typed value.
Definition: value.hh:53
value_impl< detail::label_tag > label
Definition: fwd.hh:26
automaton project(const automaton &aut, unsigned tape)
Keep a single tape from a multiple-tape automaton.
Definition: others.cc:113
auto rs
Definition: lift.hh:152
polynomial project_polynomial(const polynomial &poly, integral_constant)
Bridge (project).
Definition: project.hh:132
polynomialset< Context, Kind > make_polynomialset(const Context &context)
value_impl< detail::expansion_tag > expansion
Definition: fwd.hh:24
A dyn Value/ValueSet.
Definition: fwd.hh:23
auto make_expressionset(const context< LabelSet, WeightSet > &ctx, rat::identities ids={}) -> expressionset< context< LabelSet, WeightSet >>
Shorthand to expressionset constructor.
value_impl< detail::expression_tag > expression
Definition: fwd.hh:25
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46