Vcsn  2.2
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/polynomial.hh>
7 #include <vcsn/misc/name.hh> // integral_constant
8 #include <vcsn/dyn/label.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 make_context(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()), rs.identities());
45  }
46  }
47 
48  /*-----------------------.
49  | project(polynomial). |
50  `-----------------------*/
51 
52  namespace detail
53  {
55  template <size_t Tape, typename ValueSet>
56  auto project(const ValueSet& vs,
57  const typename ValueSet::value_t& v)
58  {
59  static_assert(Tape < labelset_t_of<ValueSet>::size(),
60  "project: invalid tape number");
61  return vs.template project<Tape>(v);
62  }
63 
65  template <size_t Tape, typename Context, wet_kind_t Kind>
67  {
68  static_assert(Tape < labelset_t_of<Context>::size(),
69  "project: invalid tape number");
70  auto ctx_out = vcsn::detail::project<Tape>(ps.context());
71  return make_polynomialset(ctx_out);
72  }
73  }
74 
75  namespace dyn
76  {
77  namespace detail
78  {
80  template <typename PolynomialSet, typename Tape>
83  {
84  constexpr auto tape = Tape::value;
85  auto& p = poly->as<PolynomialSet>();
86  const auto& ps_in = p.polynomialset();
87  auto ps_out = vcsn::detail::project<tape>(ps_in);
88  return make_polynomial(ps_out,
89  vcsn::detail::project<tape>(ps_in,
90  p.polynomial()));
91  }
92  }
93  }
94 
95  /*------------------.
96  | project(label). |
97  `------------------*/
98 
99  namespace dyn
100  {
101  namespace detail
102  {
104  template <typename Label, typename Tape>
105  label
107  {
108  constexpr auto tape = Tape::value;
109  const auto& l = lbl->as<Label>();
110  const auto& ls = l.labelset();
111  return make_label(ls.template set<tape>(), std::get<tape>(l.label()));
112  }
113  }
114  }
115 }
std::shared_ptr< const detail::polynomial_base > polynomial
Definition: fwd.hh:70
auto project(const expressionset< Context > &rs)
Project an expressionset to one tape.
Definition: project.hh:40
polynomial make_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &p)
Definition: polynomial.hh:103
label project_label(const label &lbl, integral_constant)
Bridge (project).
Definition: project.hh:106
A simple placeholder for integral constants.
Definition: name.hh:198
Definition: a-star.hh:8
polynomial project_polynomial(const polynomial &poly, integral_constant)
Bridge (project).
Definition: project.hh:82
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
Definition: traits.hh:55
label make_label(const LabelSet &ls, const typename LabelSet::value_t &l)
Definition: label.hh:80
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
std::shared_ptr< const detail::label_base > label
Definition: fwd.hh:61
context project_context(const context &ctx, integral_constant)
Bridge (project).
Definition: project.hh:23
context make_context(const std::string &name)
Bridge.
Definition: make-context.hh:45
std::shared_ptr< const detail::context_base > context
A dyn::context.
Definition: fwd.hh:43
auto rs
Definition: lift.hh:151
expressionset< Context > make_expressionset(const Context &ctx, rat::identities identities={})
Shorthand to expressionset constructor.
static dyn::context ctx(const driver &d)
Get the context of the driver.
Definition: parse.cc:82
polynomialset< Context, Kind > make_polynomialset(const Context &context)