Vcsn  2.4
Be Rational
divide.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/dyn/value.hh>
4 
5 namespace vcsn
6 {
7 
8  /*-------------------------.
9  | ldivide(value, value). |
10  `-------------------------*/
11 
13  template <typename ValueSet>
14  typename ValueSet::value_t
15  ldivide(const ValueSet& vs,
16  const typename ValueSet::value_t& lhs,
17  const typename ValueSet::value_t& rhs)
18  {
19  return vs.ldivide(lhs, rhs);
20  }
21 
22 
23  namespace dyn
24  {
25  namespace detail
26  {
28  template <typename ExpansionSetLhs, typename ExpansionSetRhs>
29  expansion
30  ldivide_expansion(const expansion& lhs, const expansion& rhs)
31  {
32  auto join_elts = join<ExpansionSetLhs, ExpansionSetRhs>(lhs, rhs);
33  return {std::get<0>(join_elts), ldivide(std::get<0>(join_elts),
34  std::get<1>(join_elts),
35  std::get<2>(join_elts))};
36  }
37 
39  template <typename ExpressionSetLhs, typename ExpressionSetRhs>
41  ldivide_expression(const expression& lhs, const expression& rhs)
42  {
43  auto join_elts = join<ExpressionSetLhs, ExpressionSetRhs>(lhs, rhs);
44  return {std::get<0>(join_elts), ldivide(std::get<0>(join_elts),
45  std::get<1>(join_elts),
46  std::get<2>(join_elts))};
47  }
48 
50  template <typename LabelSetLhs, typename LabelSetRhs>
51  label
52  ldivide_label(const label& lhs, const label& rhs)
53  {
54  auto join_elts = join<LabelSetLhs, LabelSetRhs>(lhs, rhs);
55  return {std::get<0>(join_elts), ldivide(std::get<0>(join_elts),
56  std::get<1>(join_elts),
57  std::get<2>(join_elts))};
58  }
59 
61  template <typename PolynomialSetLhs, typename PolynomialSetRhs>
63  ldivide_polynomial(const polynomial& lhs, const polynomial& rhs)
64  {
65  auto join_elts = join<PolynomialSetLhs, PolynomialSetRhs>(lhs, rhs);
66  return {std::get<0>(join_elts), ldivide(std::get<0>(join_elts),
67  std::get<1>(join_elts),
68  std::get<2>(join_elts))};
69  }
70 
72  template <typename WeightSetLhs, typename WeightSetRhs>
73  weight
74  ldivide_weight(const weight& lhs, const weight& rhs)
75  {
76  auto join_elts = join<WeightSetLhs, WeightSetRhs>(lhs, rhs);
77  return {std::get<0>(join_elts), ldivide(std::get<0>(join_elts),
78  std::get<1>(join_elts),
79  std::get<2>(join_elts))};
80  }
81  }
82  }
83 
84  /*--------------------------------.
85  | lgcd(polynomial, polynomial). |
86  `--------------------------------*/
87 
89  template <typename ValueSet>
90  typename ValueSet::value_t
91  lgcd(const ValueSet& vs,
92  const typename ValueSet::value_t& lhs,
93  const typename ValueSet::value_t& rhs)
94  {
95  return vs.lgcd(lhs, rhs);
96  }
97 
98 
99  namespace dyn
100  {
101  namespace detail
102  {
104  template <typename PolynomialSetLhs, typename PolynomialSetRhs>
105  polynomial
106  lgcd_polynomial(const polynomial& lhs, const polynomial& rhs)
107  {
108  auto join_elts = join<PolynomialSetLhs, PolynomialSetRhs>(lhs, rhs);
109  return {std::get<0>(join_elts), lgcd(std::get<0>(join_elts),
110  std::get<1>(join_elts),
111  std::get<2>(join_elts))};
112  }
113  }
114  }
115 
116  /*-------------------------.
117  | rdivide(value, value). |
118  `-------------------------*/
119 
121  template <typename ValueSet>
122  typename ValueSet::value_t
123  rdivide(const ValueSet& vs,
124  const typename ValueSet::value_t& lhs,
125  const typename ValueSet::value_t& rhs)
126  {
127  return vs.rdivide(lhs, rhs);
128  }
129 
130  namespace dyn
131  {
132  namespace detail
133  {
135  template <typename LabelSetLhs, typename LabelSetRhs>
136  label
137  rdivide_label(const label& lhs, const label& rhs)
138  {
139  auto join_elts = join<LabelSetLhs, LabelSetRhs>(lhs, rhs);
140  return {std::get<0>(join_elts), rdivide(std::get<0>(join_elts),
141  std::get<1>(join_elts),
142  std::get<2>(join_elts))};
143  }
144 
146  template <typename ExpressionSetLhs, typename ExpressionSetRhs>
147  expression
148  rdivide_expression(const expression& lhs, const expression& rhs)
149  {
150  auto join_elts = join<ExpressionSetLhs, ExpressionSetRhs>(lhs, rhs);
151  return {std::get<0>(join_elts), rdivide(std::get<0>(join_elts),
152  std::get<1>(join_elts),
153  std::get<2>(join_elts))};
154  }
155 
157  template <typename WeightSetLhs, typename WeightSetRhs>
158  weight
159  rdivide_weight(const weight& lhs, const weight& rhs)
160  {
161  auto join_elts = join<WeightSetLhs, WeightSetRhs>(lhs, rhs);
162  return {std::get<0>(join_elts), rdivide(std::get<0>(join_elts),
163  std::get<1>(join_elts),
164  std::get<2>(join_elts))};
165  }
166  }
167  }
168 }
value_impl< detail::expansion_tag > expansion
Definition: fwd.hh:24
polynomial lgcd(const polynomial &lhs, const polynomial &rhs)
Left greatest common divisor of two polynomials (lhs \ rhs).
weight ldivide_weight(const weight &lhs, const weight &rhs)
Bridge (ldivide).
Definition: divide.hh:74
automaton rdivide(const automaton &aut1, const automaton &aut2)
Bridge.
Definition: conjunction.hh:767
polynomial ldivide_polynomial(const polynomial &lhs, const polynomial &rhs)
Bridge (ldivide).
Definition: divide.hh:63
expression ldivide_expression(const expression &lhs, const expression &rhs)
Bridge (ldivide).
Definition: divide.hh:41
Definition: a-star.hh:8
label rdivide_label(const label &lhs, const label &rhs)
Bridge (rdivide).
Definition: divide.hh:137
weight rdivide_weight(const weight &lhs, const weight &rhs)
Bridge (rdivide).
Definition: divide.hh:159
expression rdivide_expression(const expression &lhs, const expression &rhs)
Bridge (rdivide).
Definition: divide.hh:148
automaton ldivide(const automaton &aut1, const automaton &aut2)
Bridge (ldivide).
Definition: conjunction.hh:732
value_impl< detail::label_tag > label
Definition: fwd.hh:26
A dyn Value/ValueSet.
Definition: fwd.hh:23
value_impl< detail::expression_tag > expression
Definition: fwd.hh:25
expansion ldivide_expansion(const expansion &lhs, const expansion &rhs)
Bridge (ldivide).
Definition: divide.hh:30
auto ldivide(const Aut1 &lhs, const Aut2 &rhs, auto_tag={})
Compute the left quotient.
Definition: conjunction.hh:684
value_impl< detail::polynomial_tag > polynomial
Definition: fwd.hh:27
polynomial lgcd_polynomial(const polynomial &lhs, const polynomial &rhs)
Bridge (lgcd).
Definition: divide.hh:106
label ldivide_label(const label &lhs, const label &rhs)
Bridge (ldivide).
Definition: divide.hh:52