Vcsn  2.2
Be Rational
divide.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/dyn/expression.hh>
4 #include <vcsn/dyn/polynomial.hh>
5 
6 namespace vcsn
7 {
8 
9  /*----------------------.
10  | ldiv(value, value). |
11  `----------------------*/
12 
14  template <typename ValueSet>
15  inline
16  typename ValueSet::value_t
17  ldiv(const ValueSet& vs,
18  const typename ValueSet::value_t& lhs,
19  const typename ValueSet::value_t& rhs)
20  {
21  return vs.ldiv(lhs, rhs);
22  }
23 
24 
25  namespace dyn
26  {
27  namespace detail
28  {
30  template <typename ExpressionSetLhs, typename ExpressionSetRhs>
32  ldiv_expression(const expression& lhs, const expression& rhs)
33  {
34  auto join_elts = join<ExpressionSetLhs, ExpressionSetRhs>(lhs, rhs);
35  return make_expression(std::get<0>(join_elts), ldiv(std::get<0>(join_elts),
36  std::get<1>(join_elts),
37  std::get<2>(join_elts)));
38  }
39 
41  template <typename PolynomialSetLhs, typename PolynomialSetRhs>
43  ldiv_polynomial(const polynomial& lhs, const polynomial& rhs)
44  {
45  auto join_elts = join<PolynomialSetLhs, PolynomialSetRhs>(lhs, rhs);
46  return make_polynomial(std::get<0>(join_elts), ldiv(std::get<0>(join_elts),
47  std::get<1>(join_elts),
48  std::get<2>(join_elts)));
49  }
50  }
51  }
52 
53  /*--------------------------------.
54  | lgcd(polynomial, polynomial). |
55  `--------------------------------*/
56 
58  template <typename ValueSet>
59  inline
60  typename ValueSet::value_t
61  lgcd(const ValueSet& vs,
62  const typename ValueSet::value_t& lhs,
63  const typename ValueSet::value_t& rhs)
64  {
65  return vs.lgcd(lhs, rhs);
66  }
67 
68 
69  namespace dyn
70  {
71  namespace detail
72  {
74  template <typename PolynomialSetLhs, typename PolynomialSetRhs>
76  lgcd_polynomial(const polynomial& lhs, const polynomial& rhs)
77  {
78  auto join_elts = join<PolynomialSetLhs, PolynomialSetRhs>(lhs, rhs);
79  return make_polynomial(std::get<0>(join_elts), lgcd(std::get<0>(join_elts),
80  std::get<1>(join_elts),
81  std::get<2>(join_elts)));
82  }
83  }
84  }
85 
86  /*----------------------.
87  | rdiv(value, value). |
88  `----------------------*/
89 
91  template <typename ValueSet>
92  inline
93  typename ValueSet::value_t
94  rdiv(const ValueSet& vs,
95  const typename ValueSet::value_t& lhs,
96  const typename ValueSet::value_t& rhs)
97  {
98  return vs.rdiv(lhs, rhs);
99  }
100 
101  namespace dyn
102  {
103  namespace detail
104  {
106  template <typename ExpressionSetLhs, typename ExpressionSetRhs>
107  expression
108  rdiv_expression(const expression& lhs, const expression& rhs)
109  {
110  auto join_elts = join<ExpressionSetLhs, ExpressionSetRhs>(lhs, rhs);
111  return make_expression(std::get<0>(join_elts), rdiv(std::get<0>(join_elts),
112  std::get<1>(join_elts),
113  std::get<2>(join_elts)));
114  }
115  }
116  }
117 }
expression rdiv(const expression &lhs, const expression &rhs)
Right-division of two expressions (lhs \ rhs).
polynomial lgcd(const polynomial &lhs, const polynomial &rhs)
Left greatest common divisor of two polynomials (lhs \ rhs).
std::shared_ptr< const detail::polynomial_base > polynomial
Definition: fwd.hh:70
polynomial make_polynomial(const PolynomialSet &ps, const typename PolynomialSet::value_t &p)
Definition: polynomial.hh:103
Definition: a-star.hh:8
ValueSet::value_t lgcd(const ValueSet &vs, const typename ValueSet::value_t &lhs, const typename ValueSet::value_t &rhs)
Left-division of values.
Definition: divide.hh:61
expression rdiv_expression(const expression &lhs, const expression &rhs)
Bridge (rdiv).
Definition: divide.hh:108
ValueSet::value_t rdiv(const ValueSet &vs, const typename ValueSet::value_t &lhs, const typename ValueSet::value_t &rhs)
Right-division of values.
Definition: divide.hh:94
expression ldiv_expression(const expression &lhs, const expression &rhs)
Bridge (ldiv).
Definition: divide.hh:32
polynomial lgcd_polynomial(const polynomial &lhs, const polynomial &rhs)
Bridge (lgcd).
Definition: divide.hh:76
polynomial ldiv_polynomial(const polynomial &lhs, const polynomial &rhs)
Bridge (ldiv).
Definition: divide.hh:43
std::shared_ptr< detail::expression_base > expression
Definition: expression.hh:92
expression make_expression(const ExpSet &rs, const typename ExpSet::value_t &r)
Definition: expression.hh:97
ValueSet::value_t ldiv(const ValueSet &vs, const typename ValueSet::value_t &lhs, const typename ValueSet::value_t &rhs)
Left-division of values.
Definition: divide.hh:17