1 #ifndef GINAC_RING_TRAITS_HPP
2 #define GINAC_RING_TRAITS_HPP
3 #include <cln/integer.h>
4 #include <cln/modinteger.h>
8 static inline cln::cl_I div(const cln::cl_I& x, const cln::cl_I& y)
10 return cln::exquo(x, y);
13 /// Exact integer division.
14 /// Check if y divides x, if yes put the quotient into q, otherwise don't
15 /// touch q. Returns true if y divides x and false if not.
16 static inline bool div(cln::cl_I& q, const cln::cl_I& x, const cln::cl_I& y)
18 const cln::cl_I_div_t qr = cln::truncate2(x, y);
19 if (zerop(qr.remainder)) {
26 static inline cln::cl_I get_ring_elt(const cln::cl_I& sample, const int val)
28 return cln::cl_I(val);
31 static inline cln::cl_MI get_ring_elt(const cln::cl_MI& sample, const int val)
33 return sample.ring()->canonhom(val);
37 static inline T the_one(const T& sample)
39 return get_ring_elt(sample, 1);
44 #endif // GINAC_RING_TRAITS_HPP