]> www.ginac.de Git - ginac.git/blob - ginac/polynomial/interpolate_padic_uvar.h
Renamed files *.tcc and *.hpp to *.h.
[ginac.git] / ginac / polynomial / interpolate_padic_uvar.h
1 #ifndef GINAC_UPOLY_INTERPOLATE_PADIC_TCC
2 #define GINAC_UPOLY_INTERPOLATE_PADIC_TCC
3 #include "ring_traits.h"
4
5 namespace cln
6 {
7 static inline cln::cl_I smod(const cln::cl_I& x, const cln::cl_I y)
8 {
9         cln::cl_I r = mod(x, y);
10         const cln::cl_I y_2 = y >> 1;
11         if (r > y_2)
12                 r = r - y;
13         return r;
14 }
15
16 } // namespace cln
17
18 namespace GiNaC
19 {
20
21 template<typename T> static void
22 interpolate(T& g, const typename T::value_type& gamma,
23             const typename T::value_type& modulus,
24             const std::size_t degree_hint = 1)
25 {
26         typedef typename T::value_type ring_t;
27         g.clear();
28         g.reserve(degree_hint);
29         ring_t e = gamma;
30         while (!zerop(e)) {
31                 const ring_t gi = smod(e, modulus);
32                 g.push_back(gi);
33                 e = exquo(e - gi, modulus);
34         }
35 }
36
37 } // namespace GiNaC
38
39 #endif // GINAC_UPOLY_INTERPOLATE_PADIC_TCC
40